| name | network-tools |
| description | Linux network tools and diagnostics |
| version | 1.0.0 |
| author | terminal-skills |
| tags | ["linux","network","diagnosis","netstat","ss","curl"] |
Network Tools and Diagnostics
Overview
Linux network diagnostics, port scanning, traffic analysis and other tool usage skills.
Network Configuration
View Configuration
ip addr
ip a
ifconfig
ip route
route -n
netstat -rn
cat /etc/resolv.conf
systemd-resolve --status
Configure Network
ip addr add 192.168.1.100/24 dev eth0
ip addr del 192.168.1.100/24 dev eth0
ip link set eth0 up
ip link set eth0 down
ip route add 10.0.0.0/8 via 192.168.1.1
ip route del 10.0.0.0/8
Connectivity Testing
ping
ping hostname
ping -c 4 hostname
ping -i 0.2 hostname
ping -s 1000 hostname
traceroute
traceroute hostname
traceroute -n hostname
traceroute -T hostname
mtr hostname
DNS Query
nslookup hostname
dig hostname
dig +short hostname
dig @8.8.8.8 hostname
host hostname
Ports and Connections
ss Command (Recommended)
ss -tlnp
ss -ulnp
ss -tlnp | grep :80
ss -tanp
ss -s
ss -t state established
ss -t dst 192.168.1.1
ss -t sport = :80
netstat Command
netstat -tlnp
netstat -ulnp
netstat -anp
netstat -s
lsof Network
lsof -i
lsof -i :80
lsof -i tcp
lsof -i @192.168.1.1
HTTP Tools
curl
curl http://example.com
curl -I http://example.com
curl -v http://example.com
curl -X POST -d "data=value" http://example.com
curl -X POST -H "Content-Type: application/json" -d '{"key":"value"}' http://example.com
curl -O http://example.com/file.zip
curl -o output.zip http://example.com/file.zip
curl -u user:pass http://example.com
curl -H "Authorization: Bearer token" http://example.com
wget
wget http://example.com/file.zip
wget -c http://example.com/file.zip
wget -r http://example.com
wget --mirror http://example.com
Packet Capture
tcpdump
tcpdump -i eth0
tcpdump -i any
tcpdump -i eth0 port 80
tcpdump -i eth0 host 192.168.1.1
tcpdump -i eth0 'tcp port 80 and host 192.168.1.1'
tcpdump -i eth0 -w capture.pcap
tcpdump -r capture.pcap
tcpdump -i eth0 -A port 80
tcpdump -i eth0 -X port 80
Traffic Monitoring
iftop
iftop -i eth0
nethogs
nethogs eth0
iperf3 -s
iperf3 -c server_ip
Common Scenarios
Scenario 1: Troubleshoot Port Usage
ss -tlnp | grep :8080
lsof -i :8080
kill -9 PID
fuser -k 8080/tcp
Scenario 2: Test Service Connectivity
nc -zv hostname 80
telnet hostname 80
curl -I http://hostname
curl -w "HTTP Code: %{http_code}\nTime: %{time_total}s\n" -o /dev/null -s http://hostname
Scenario 3: Network Performance Diagnosis
ping -c 100 hostname | tail -1
mtr --report hostname
iperf3 -c server -t 30
Troubleshooting
| Problem | Solution |
|---|
| Network unreachable | ping, traceroute, check routing |
| DNS resolution failed | dig, nslookup, check resolv.conf |
| Port unreachable | ss -tlnp, check firewall |
| Connection timeout | mtr, tcpdump packet capture |
| Insufficient bandwidth | iftop, iperf3 test |