The ip command (from the iproute2 package) is the modern tool for network configuration on Linux. It replaced ifconfig, route and arp, which are no longer installed by default on many distributions.
Changes made with ip are temporary — they vanish at reboot. Permanent configuration belongs in Netplan, NetworkManager or /etc/network/interfaces (see the end of this guide).
Show addresses
ip addr # or: ip a
ip -br addr # brief: one line per interface
ip -4 addr # IPv4 only
ip -6 addr # IPv6 only
ip addr show eth0
ip -br addr is the quickest overview:
lo UNKNOWN 127.0.0.1/8 ::1/128
eth0 UP 203.0.113.10/24 2001:db8::10/64 fe80::5054:ff:fe12:3456/64
The /24 is the prefix length (subnet mask 255.255.255.0). Addresses starting with fe80:: are IPv6 link-local addresses, always present on IPv6-enabled interfaces.
Show interfaces (links)
ip link
ip -br link
ip -s link show eth0 # with RX/TX statistics: bytes, packets, errors, drops
Rising errors or dropped counters can indicate network problems or an overloaded interface.
Add and remove addresses
sudo ip addr add 203.0.113.11/24 dev eth0 # add a secondary IP
sudo ip addr del 203.0.113.11/24 dev eth0
sudo ip addr flush dev eth1 # remove all addresses from eth1
Additional IPs from your provider sometimes use /32 or a different subnet — follow their instructions. See adding a secondary IP.
Bring interfaces up and down
sudo ip link set eth1 up
sudo ip link set eth1 down
sudo ip link set eth0 mtu 1450
Never take down the interface you’re connected through over SSH — use the VPS console for that.
Routes
ip route # or: ip r
ip -6 route
ip route get 1.1.1.1 # which route/interface/source IP would be used
Typical output:
default via 203.0.113.1 dev eth0 proto static
203.0.113.0/24 dev eth0 proto kernel scope link src 203.0.113.10
10.8.0.0/24 dev wg0 proto kernel scope link src 10.8.0.1
Add and remove routes:
sudo ip route add 10.20.0.0/16 via 10.0.0.1 dev eth1
sudo ip route del 10.20.0.0/16
sudo ip route replace default via 203.0.113.1 dev eth0
ip route get is invaluable with multiple interfaces or VPNs: it tells you exactly how the kernel would send a packet.
Neighbours (ARP / NDP)
ip neigh
ip neigh flush dev eth0
Shows MAC addresses of hosts on the local network — useful when debugging a gateway that doesn’t respond.
Policy routing (multiple uplinks)
ip rule
ip route show table all
Policy rules choose routing tables based on source address or marks — needed when a server has IPs from different networks that must answer through their own gateways.
Network namespaces
ip netns list
sudo ip netns exec NAME ip addr
Containers use namespaces; this lets you inspect their networking from the host. See Linux network namespaces.
Colour and JSON
ip -c a # coloured output
ip -j -p addr # pretty JSON — handy with jq
ifconfig → ip cheat sheet
| Old command | ip equivalent |
|---|---|
ifconfig |
ip addr / ip -br a |
ifconfig eth0 up |
ip link set eth0 up |
ifconfig eth0 10.0.0.5/24 |
ip addr add 10.0.0.5/24 dev eth0 |
route -n |
ip route |
route add default gw 10.0.0.1 |
ip route add default via 10.0.0.1 |
arp -a |
ip neigh |
netstat -i |
ip -s link |
Making changes permanent
| System | Where |
|---|---|
| Ubuntu (server) | Netplan: /etc/netplan/*.yaml → Netplan guide |
| Debian (ifupdown) | /etc/network/interfaces → Debian networking |
| AlmaLinux/Rocky/Fedora | NetworkManager: nmcli → nmcli guide |
Quick reference
| Task | Command |
|---|---|
| Addresses | ip -br a |
| Interfaces + stats | ip -s link |
| Add IP | ip addr add IP/PREFIX dev IF |
| Routes | ip r |
| Route lookup | ip route get DEST |
| Default gateway | ip route add default via GW |
| Neighbours | ip neigh |
Related: ss command and network troubleshooting.