ip Command Cheat Sheet
The ip command is the powerhouse of Linux networking. It replaces ifconfig, route, arp, and netstat. It allows configuration of network interfaces, routing tables, ARP tables, and tunnels.
Synopsis
ip [ OPTIONS ] OBJECT { COMMAND | help }
address, link, route, neigh, rule, tunnel, maddr
Managing Addresses (ip addr)
Replaces ifconfig.
Show IP Addresses
ip addr show
ip a
Show Only IPv4 or IPv6
ip -4 a # IPv4 only
ip -6 a # IPv6 only
Add an IP Address
sudo ip addr add 192.168.1.100/24 dev eth0
Delete an IP Address
sudo ip addr del 192.168.1.100/24 dev eth0
Flush All IPs from an Interface
sudo ip addr flush dev eth0
Managing Links (ip link)
Replaces ifconfig up/down.
Show Interface Status
ip link show
ip l
Bring Interface Up/Down
sudo ip link set eth0 up
sudo ip link set eth0 down
Change MTU
sudo ip link set eth0 mtu 1400
Change MAC Address
sudo ip link set dev eth0 address 00:11:22:33:44:55
Rename Interface
sudo ip link set dev eth0 down
sudo ip link set dev eth0 name wan0
sudo ip link set dev wan0 up
Managing Routes (ip route)
Replaces route.
Show Routing Table
ip route show
ip r
Add Default Gateway
sudo ip route add default via 192.168.1.1
Add Static Route
Route traffic for 10.0.0.0/8 network through 192.168.1.5 gateway.
sudo ip route add 10.0.0.0/8 via 192.168.1.5 dev eth0
Delete Route
sudo ip route del 10.0.0.0/8
Managing Neighbors (ip neigh)
Replaces arp.
Show ARP Table
ip neigh show
ip n
Add Static ARP Entry
sudo ip neigh add 192.168.1.5 lladdr 00:11:22:33:44:55 dev eth0
Delete ARP Entry
sudo ip neigh del 192.168.1.5 dev eth0
Output Formatting
Color Output (-c)
Highlights IP addresses and status.
ip -c a
JSON Output (-j)
Critical for scripting (Python/jq content).
ip -j a | jq
Brief Output (-br)
Shows a clean, one-line summary per interface. Highly recommended.
ip -br a
# Output:
# lo UNKNOWN 127.0.0.1/8 ::1/128
# eth0 UP 192.168.1.100/24
Advanced: Validation
Show Detailed Statistics
ip -s link
Monitor Network Events
Watch network changes (cable plug, IP update) in real-time.
ip monitor
Notes
- Persistence: Like
ifconfig,ipcommands do not survive a reboot. Use Netplan (/etc/netplan), NetworkManager (nmcli), or/etc/network/interfaces. - Secondary IPs:
ip addr add 10.0.0.1/24 dev eth0adds a second IP (aliasing).ifconfigrequired:0aliases;ipdoes not.