Network Debugging Commands
ip Command
ip replaces the legacy ifconfig command.
| Command | Description |
|---|---|
ip link show | Show all network interfaces |
ip addr show | Show IP addresses |
ip -4 addr show | Show IPv4 addresses only |
ip -6 addr show | Show IPv6 addresses only |
ip route show | Show routing table |
ip route get 8.8.8.8 | Show route to a specific IP |
sudo ip link set enp0s3 up | Enable a network interface |
sudo ip link set enp0s3 down | Disable a network interface |
sudo ip addr add 192.168.1.100/24 dev enp0s3 | Temporarily add an IP |
sudo ip route add 10.0.0.0/8 via 192.168.1.1 | Temporarily add a route |
ip neigh show | Show neighbor table (ARP) |
ss Command
ss replaces the legacy netstat command. Flags: -t TCP, -u UDP, -l listening, -n no name resolution, -p show process.
| Command | Description |
|---|---|
ss -tlnp | Show all listening ports |
ss -tnp | Show all TCP connections |
ss -ulnp | Show all UDP ports |
ss -tlnp | grep :80 | Check a specific port |
ss -tlnp sport = :443 | Filter by port number |
ss -s | Show connection statistics |
ss -tnp | grep process-name | Show network connections for a process |
ping
| Command | Description |
|---|---|
ping -c 4 8.8.8.8 | Test connectivity |
ping -c 10 -i 0.5 -s 1400 target-IP | Specify count, interval, and packet size |
ping6 ::1 | IPv6 ping |
ping -c 1 -W 1 192.168.1.1 && echo "online" || echo "offline" | Quick host online check |
traceroute / tracepath
| Command | Description |
|---|---|
traceroute www.example.com | Trace route path |
sudo traceroute -I www.example.com | Trace using ICMP |
sudo traceroute -T -p 80 www.example.com | Trace using TCP (firewall penetration) |
tracepath www.example.com | Trace route (no root required) |
mtr www.example.com | Combined ping + traceroute (install mtr-tiny) |
dig / nslookup
| Command | Description |
|---|---|
dig www.example.com | DNS lookup |
dig +short www.example.com | Short output |
dig MX example.com | Query MX records |
dig AAAA www.example.com | Query IPv6 records |
dig NS example.com | Query name servers |
dig TXT example.com | Query TXT records |
dig @8.8.8.8 www.example.com | Query using a specific DNS server |
dig -x 8.8.8.8 | Reverse lookup |
nslookup www.example.com | Simple DNS lookup |
nslookup www.example.com 8.8.8.8 | Specify DNS server |
curl
| Command | Description |
|---|---|
curl https://www.example.com | GET request |
curl -I https://www.example.com | Show response headers |
curl -v https://www.example.com | Show verbose information |
curl -o /dev/null -s -w "%{http_code}\n" https://www.example.com | Show HTTP status code only |
curl -X POST -d "key=value" https://api.example.com | POST request |
curl -X POST -H "Content-Type: application/json" -d '{"key":"value"}' https://api.example.com | JSON POST |
curl -O https://example.com/file.zip | Download file (keep original name) |
curl -o newname.zip https://example.com/file.zip | Download file (custom name) |
curl -o /dev/null -s -w "DNS: %{time_namelookup}s\nConnect: %{time_connect}s\nTTFB: %{time_starttransfer}s\nTotal: %{time_total}s\n" https://www.example.com | Test connection timing |
curl -x http://proxy:8080 https://www.example.com | Request through proxy |
wget
| Command | Description |
|---|---|
wget https://example.com/file.zip | Download file |
wget -c https://example.com/large-file.iso | Resume interrupted download |
wget -b https://example.com/large-file.iso | Background download |
wget --limit-rate=1M https://example.com/file.zip | Rate-limited download |
NetworkManager Commands
| Command | Description |
|---|---|
nmcli general status | Check connection status |
nmcli connection show | Show all connections |
nmcli device wifi list | List Wi-Fi networks |
nmcli device status | Show device status |
sudo systemctl restart NetworkManager | Restart networking |
Firewall Debugging
| Command | Description |
|---|---|
sudo ufw status verbose | UFW status |
sudo iptables -L -n -v | iptables rules |
sudo nft list ruleset | nftables rules |
Comprehensive Troubleshooting Flow
| Step | Command | Description |
|---|---|---|
| 1 | ip link show | Check if interface is up |
| 2 | ip addr show | Check IP address |
| 3 | ip route show | Check gateway |
| 4 | ping -c 2 gateway-IP | Test gateway connectivity |
| 5 | ping -c 2 8.8.8.8 | Test internet connectivity |
| 6 | dig www.example.com | Test DNS |
| 7 | curl -I https://www.example.com | Test HTTP |
Last updated on