Layer 1: Physical
ip link show
ethtool eth0 | grep "Link detected"
ethtool --cable-test eth0
ip -s link show eth0
Layer 2: Data Link
ip link show eth0 | grep link/ether
ip neigh show
arp -a
sudo ip neigh flush all
Layer 3: Network
ip addr show
ifconfig
ip route show
route -n
ping -c 4 $(ip route | grep default | awk '{print $3}')
ping -c 4 8.8.8.8
Layer 4: Transport
ss -tuln
netstat -tuln
ss -tup
netstat -tup
ss -tuln | grep :80
Layer 7: Application
curl -I https://example.com
dig example.com
nslookup example.com
telnet example.com 80
nc -zv example.com 80
Systematic troubleshooting
Step 1: Verify physical connection
ip link show eth0
sudo ip link set eth0 up
ip -s link show eth0 | grep -i error
Step 2: Check IP configuration
ip addr show eth0
sudo dhclient -r eth0
sudo dhclient eth0
sudo ip addr add 192.168.1.100/24 dev eth0
sudo ip route add default via 192.168.1.1
Step 3: Test gateway connection
ip route | grep default
ping -c 4 192.168.1.1
traceroute -m 1 192.168.1.1
Step 4: Test DNS
cat /etc/resolv.conf
dig google.com @8.8.8.8
dig google.com @8.8.8.8
dig google.com @1.1.1.1
sudo systemd-resolve --flush-caches
Step 5: Test external connectivity
ping -c 4 8.8.8.8
ping -c 4 google.com
traceroute google.com
mtr google.com
Common issues and fixes
No network interface
ip link show
lsmod | grep -i network
sudo systemctl restart NetworkManager
Can't ping gateway
ethtool eth0 | grep "Link detected"
ip route show
sudo ip route add default via 192.168.1.1 dev eth0
sudo iptables -L
sudo ufw status
DNS not resolving
cat /etc/resolv.conf
dig google.com @8.8.8.8
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf
sudo systemctl restart systemd-resolved
Slow network
iperf3 -c server-ip
ping -M do -s 1472 google.com
ping -c 100 google.com | grep loss
ping -c 10 google.com | tail -1
Network diagnostic commands
ip addr
ip route
ip neigh
ss -tuln
ss -tup
ping 8.8.8.8
dig google.com
Capture traffic
sudo tcpdump -i eth0
sudo tcpdump -i eth0 port 80
sudo tcpdump -i eth0 -w capture.pcap
tcpdump -r capture.pcap
Monitor bandwidth
sudo iftop -i eth0
sudo nethogs eth0
vnstat -l -i eth0
Firewall issues
sudo iptables -L -v -n
sudo ufw status verbose
sudo firewall-cmd --list-all
sudo ufw disable
sudo systemctl stop firewalld
WiFi specific
sudo iwlist wlan0 scan
sudo iwconfig wlan0 essid "NetworkName"
iwconfig wlan0 | grep Signal
nmcli dev wifi list
Complete troubleshooting script
#!/bin/bash
echo "=== Network Troubleshooting ==="
echo ""
echo "1. Interface Status:"
ip link show | grep "state UP"
echo ""
echo "2. IP Addresses:"
ip addr show | grep "inet "
echo ""
echo "3. Default Gateway:"
ip route | grep default
echo ""
echo "4. DNS Servers:"
cat /etc/resolv.conf | grep nameserver
echo ""
echo "5. Ping Gateway:"
GATEWAY=$(ip route | grep default | awk '{print $3}')
ping -c 2 $GATEWAY
echo ""
echo "6. Ping External:"
ping -c 2 8.8.8.8
echo ""
echo "7. DNS Resolution:"
dig google.com +short
echo ""
echo "8. Open Ports:"
ss -tuln | head -5
Performance testing
wget -O /dev/null http://speedtest.tele2.net/100MB.zip
iperf3 -c iperf.example.com
ping -c 100 8.8.8.8 | grep rtt
Check MTU path
ping -M do -s 1472 google.com
ping -M do -s 1400 google.com
sudo ip link set dev eth0 mtu 1400
Routing troubleshooting
ip route show
route -n
traceroute -n google.com
mtr --report google.com
sudo ip route add 10.0.0.0/24 via 192.168.1.1
Reset network
sudo systemctl restart NetworkManager
sudo systemctl restart networking
sudo ip addr flush dev eth0
sudo systemctl restart networking