Understanding networking is essential for system administration and troubleshooting connectivity issues.
Network Configuration
IP Configuration
ip addr show # Show IP addresses
ip link show # Show network interfaces
ip route show # Show routing table
Traditional Commands
ifconfig # Interface configuration (deprecated)
route -n # Routing table
netstat -rn # Network statistics
Network Interfaces
# Enable/disable interface
ip link set eth0 up
ip link set eth0 down
# Configure IP
ip addr add 192.168.1.10/24 dev eth0
ip addr del 192.168.1.10/24 dev eth0
DNS Configuration
cat /etc/resolv.conf # DNS servers
host example.com # DNS lookup
dig example.com # Detailed DNS query
nslookup example.com # Name server lookup
Network Testing
ping host # Test connectivity
traceroute host # Trace route
mtr host # My traceroute (continuous)
curl -I url # HTTP request
wget url # Download file
Firewall Basics
iptables
iptables -L # List rules
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -j DROP
firewalld (Red Hat)
firewall-cmd --list-all
firewall-cmd --add-port=80/tcp --permanent
firewall-cmd --reload
ufw (Ubuntu)
ufw status
ufw allow 22/tcp
ufw enable
SSH
ssh user@host # Connect
ssh -p 2222 user@host # Custom port
ssh-keygen # Generate key pair
ssh-copy-id user@host # Copy public key
Network Troubleshooting
# Check connectivity
ping -c 4 8.8.8.8
# Check DNS
dig @8.8.8.8 google.com
# Check listening ports
ss -tulpn
# Monitor traffic
tcpdump -i eth0
Understanding networking helps you configure, secure, and troubleshoot Linux systems.