ip
Overview
ip (from iproute2) configures and displays interfaces, addresses, routes, neighbors, rules, and tunnels. It replaces legacy ifconfig/route/arp for modern Linux networking.
Syntax
ip [OPTIONS] OBJECT COMMAND
ip -h # help
ip OBJECT help # object-specific helpCommon objects: link, address (addr), route, neigh, rule, netns, xfrm.
Common Options
| Option | Description |
|---|---|
-4 / -6 |
IPv4 / IPv6 only |
-s |
Statistics (can repeat for more detail) |
-d |
Extra detail |
-br |
Brief columnar output |
-c |
Color |
-o |
One-line output |
-j / -p |
JSON / pretty JSON (newer iproute2) |
Key Use Cases
- Inspect and set addresses
- Bring links up/down, set MTU/MAC
- Manage default and static routes
- Debug neighbor (ARP/ND) tables
- Work with network namespaces
Safety
Address and route changes can drop your SSH session. Prefer a console/IPMI session or a scripted rollback when changing the only default route. On Ubuntu servers, prefer netplan or NetworkManager for persistent config; use ip for live debug.
Examples with Explanations
Brief overview
ip -br link
ip -br addr
ip routeFast “what interfaces, what IPs, what default route?”.
Full address list
ip addr show
ip -4 addr show dev eth0Bring link up/down
sudo ip link set dev eth0 up
sudo ip link set dev eth0 downAdd/remove an address
sudo ip addr add 192.168.1.50/24 dev eth0
sudo ip addr del 192.168.1.50/24 dev eth0Prefix length is required. Secondary addresses are normal on multi-homed hosts.
Default route
sudo ip route add default via 192.168.1.1 dev eth0
sudo ip route replace default via 192.168.1.1 dev eth0
ip route get 1.1.1.1route get shows which path the kernel would use.
Static route
sudo ip route add 10.0.0.0/8 via 192.168.1.254
sudo ip route del 10.0.0.0/8Neighbor table (ARP)
ip neigh show
sudo ip neigh flush dev eth0Statistics
ip -s link show eth0
ip -s -s link show eth0 # more error detailNetwork namespace (quick)
sudo ip netns add lab
sudo ip netns exec lab ip link
sudo ip netns delete labUnderstanding Output
UP/LOWER_UPon links: admin up vs carrier present
inet/inet6lines: addresses and scopes (global,link)
proto kernelvsproto static/dhcpon routes: origin of the route
Common Usage Patterns
Live IP on a server you did not configure
ip -br a; ip r; resolvectl status 2>/dev/null || cat /etc/resolv.confFlush all IPv4 addresses on a NIC (careful)
sudo ip -4 addr flush dev eth0Notes & Pitfalls
- Changes with
ipare not durable across reboot unless persisted by netplan/NM/scripts.
- Interface names may be predictable (
enp3s0) noteth0.
- Policy routing uses
ip rule+ multiple tables — advanced; seeman ip-rule.
Additional Resources
man ip,man ip-link,man ip-route
- iproute2 documentation