网络

Linux下常用的TCP/IP协议命令

ifconfig: display current config for all NIC’s
ifconfig dc0: display current config for dc0
ifconfig dc0:0 192.168.1.2: assign multiple IPs
ifconfig dc0:1 192.168.1.3: assign second IP
ifconfig dc0 down: disable network card
ifconfig dc0 up: enable network card
ifconfig dc0 inet 192.168.1.2 netmask 255.255.255.0: assign IP/subnet
route delete default && route add default 192.168.1.1: assign gateway
ping: test connectivity to destination
ping 192.168.1.1: ping destination IP
ping -c 5 192.168.1.1: ping 5 times
ping -i 5 192.168.1.1: 5 second interval between pings
traceroute: show route hops to destination
traceroute google.com: trace route to domain
traceroute -T 192.168.1.1: use TCP SYN trace
traceroute -I 192.168.1.1: use ICMP trace
netstat: show active connections and ports
netstat -tan: show active TCP connections
netstat -uan: show active UDP connections
netstat -s: show network statistics
netstat -l: show listening ports
netstat -rn: show routing table
nslookup: lookup DNS name servers and records
nslookup google.com: query DNS for domain
dig: lookup DNS records
dig google.com: standard DNS lookup
dig -x 192.168.1.1: reverse DNS lookup
dig google.com MX: query mail records
nmap: scan/audit ports and services
nmap 192.168.1.1: basic port scan
nmap -sS 192.168.1.1: TCP SYN scan
nmap -sU -p 53 192.168.1.1: UDP scan port 53
nmap -sV 192.168.1.1: detect service versions
nmap -O 192.168.1.1: detect OS fingerprint
tcpdump: capture packets for analysis
tcpdump -i eth0: capture on interface eth0
tcpdump -w output.pcap: save capture to file
tcpdump -r input.pcap: read packets from file
tcpdump tcp port 80: capture only TCP port 80
tcpdump ‘dst 192.168.1.1’: filter destination IP