Mastering Network Configuration with iproute2: The Modern Networking Toolkit

Introduction to iproute2

iproute2 is the modern networking toolkit for Linux, replacing traditional tools like ifconfig and route with more powerful and flexible alternatives.

Basic Network Configuration

Interface Management

  1. Show interfaces:
ip addr show
  1. Add IP address:
sudo ip addr add 192.168.1.100/24 dev eth0
  1. Bring interface up:
sudo ip link set eth0 up

Advanced Routing

Routing Tables

  1. Add route:
sudo ip route add 10.0.0.0/8 via 192.168.1.1
  1. Policy routing:
sudo ip rule add from 192.168.1.100 lookup 100
sudo ip route add default via 192.168.1.1 table 100

Traffic Control

Quality of Service (QoS)

  1. Create HTB queue:
sudo tc qdisc add dev eth0 root handle 1: htb
  1. Add class:
sudo tc class add dev eth0 parent 1: classid 1:1 htb rate 100mbit

Troubleshooting

  1. Network statistics:
nstat -a
  1. Socket information:
ss -tulpn
  1. Routing diagnostics:
ip route get 8.8.8.8

Performance Optimization

  1. TCP tuning:
sudo sysctl -w net.core.rmem_max=16777216
sudo sysctl -w net.core.wmem_max=16777216
  1. Interface buffering:
sudo ethtool -G eth0 rx 4096 tx 4096

Conclusion

iproute2 provides powerful tools for network configuration and troubleshooting, making it an essential skill for Linux system administrators.