Linux Networking Commands ও Troubleshooting

লেসন ১১ / ৩৮

🌐 IP Configuration

ip addr show               # all interfaces
ip a                       # short
ip route show              # routing table
ip route get 8.8.8.8       # which route
hostname; hostname -I
hostnamectl set-hostname myserver

# /etc/hosts (manual override)
127.0.0.1     localhost
192.168.1.10  myapp.local

🔍 DNS Tools

dig example.com
dig example.com +short
dig @8.8.8.8 example.com   # specific resolver
dig example.com MX
dig -x 8.8.8.8             # reverse DNS

# Propagation check
for ns in 8.8.8.8 1.1.1.1 9.9.9.9; do
  dig @$ns example.com +short
done

📡 Connection Test

ping -c 4 example.com
traceroute example.com
mtr example.com            # live trace 🔥

curl -v https://x.com      # full debug
curl -I url                # headers only
curl -L url                # follow redirect
curl -X POST -d "data" url
curl -H "Authorization: Bearer X" url
curl -o file.zip url
curl -w "%{http_code} %{time_total}\n" -o /dev/null -s url

wget -c url                # resume download

🔌 Port & Connection

ss -tulnp                  # listening 🔥
ss -tunap                  # all
lsof -i :80
netstat -an | grep :80 | wc -l   # active connections

nc -zv example.com 443     # test open
nc -l 8080                 # listen for testing
python3 -m http.server 8000  # quick web server

🔬 Packet Capture

sudo tcpdump -i any port 80
sudo tcpdump -i eth0 host example.com -w cap.pcap
sudo tcpdump -r cap.pcap

📊 Bandwidth

sudo iftop                 # per-connection live
nload eth0                 # interface bandwidth
speedtest                  # speedtest CLI

🔧 Troubleshooting Flow

# Site not loading?
1. ping site.com           → reachability
2. dig site.com            → DNS
3. curl -v https://site    → full request
4. ss -tulnp | grep 443    → listening?
5. tail -f nginx logs      → server logs
6. ufw status              → firewall block?
7. systemctl status nginx  → service running?

🎓 মূল কথা ⭐

5 command = 90% network debug — ping, dig, curl, ss, traceroute। Server unreachable → ping। Site error → curl -v। Port → ss/lsof।