Use a script to include these commonly used linux network operation commands.
#/bin/sh
# Viewing http request headers
tcpdump -s 1024 -l -A -n host 192.168.9.56tcpdump -s 1024 -l -A src 192.168.9.56 or dst 192.168.9.56sudo tcpdump -A -s 1492 dst port 80
# The host with the IP address 192.168.0.5 in the local network now communicates with the outside world
sudo tcpdump -i eth0 src host 192.168.0.5
# View the tcp packet of the http request of the network adapter eth0
tcpdump -i eth0 port httptcpdump -i eth0 port http or port smtp or port imap or port pop3 -l -A | egrep -i 'pass=|pwd=|log=|login=|user=|username=|pw=|passw=|passwd=|password=|pass:|user:|userna me:|password:|login:|pass |user '
# View tcp, upd, and icmp non-ssh packets
tcpdump -n -v tcp or udp or icmp and not port 22
# View the http request package
sudo tcpdump -i eth0 port 80 -w -
# Filter the http Response's get host header information
sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "GET \/.*|Host\: .*"
# DNS query request response package
sudo tcpdump -i en0 'udp port 53'
# Nmap-sP specify to use Ping echo for scanning/24 to view how many hosts in the target network are running
nmap -sP 192.168.0.1nmap -sP 192.168.0.0/24nmap -O www.baidu.com
# Netstat is mainly used for Linux/Unix hosts to view their network conditions, such as the opened ports, the user services and service statuses.
netstat -anetstat -nlp
# Netcat scan ports opened by machines
nc -z -v -n 172.31.100.7 21-25
# The netcat command will connect to open port 21 and print the banner information of the Service running on this port.
nc -v 172.31.100.7 21
# Route table of the output Network
route
# The result shows how long the server has been running, how many login users are there, and the overall load average evaluation of server performance ).
uptime
# Monitor the network card Traffic of eth1
iftop -i eth1
# Display traffic in bytes (bytes) (default: bits ):
iftop -B
# Directly display the IP address without reverse DNS resolution:
iftop -n
# The Connection port number is displayed directly, but the service name is not displayed:
iftop -N
# Display inbound and outbound traffic of a CIDR Block
iftop -F 192.168.1.0/24 or 192.168.1.0/255.255.255.0
# Nload, a real-time network traffic monitoring tool, to view the eth0 traffic of the Network Adapter
nload -n eth0
# View the traffic of each Nic
nload -h
# IPTraf is a network monitoring tool with more powerful functions than nload. It can monitor all traffic, IP traffic, protocol-based traffic, and set filters.
iptraf
# View the current configuration of the network interface and the interface Name:
ifconfig
# Open up) or close down) Adapter
Ifconfig <Network Name> <up | down>
# Assign an IP address to the adapter:
Ifconfig <Network Name> <IP address>
# Assign a second IP address to the adapter:
Ifconfig <Network Name: number of instances> <IP address>
# Display the driver information of a network adapter, which is suitable for querying software compatibility:
ethtool -i eth0
# Display network data:
ethtool -S
# Set the adapter connection speed (Mbps)
ethtool speed <10|100|1000>
# Iwconfig check basic Wi-Fi network settings, such as SSID, channel, and encryption. You can also modify some advanced settings, including the receipt sensitivity, RTS/CTS, fragments, and number of retries.
# Display the current wireless settings, including the Interface Name:
iwconfig
# Set the ESSID extension service to set the identifier) or network name:
Iwconfig <Interface Name> essid <Network Name>
#wgetwget -S --spider http://osswin.sourceforge.net/ 2>&1 | grep Mod
# View mac addresses
cat /sys/class/net/*/address
# View the ip address of eth0
ifconfig eth0 | awk '/inet addr/ {split ($2,A,":"); print A[2]}'
# Curl: view the domail name corresponding to the page
curl -s http://en.m.wikipedia.org/wiki/List_of_Internet_top-level_domains | sed -n '/<tr valign="top">/{s/<[^>]*>//g;p}'#talnettelnet localhost 6666
# View all network interfaces
awk '{print $1}' /proc/net/dev|grep :|sed "s/:.*//g"
# Viewing the DNS server version
nslookup -q=txt -class=CHAOS version.bind NS.PHX5.NEARLYFREESPEECH.NET