ip Command Cheat Sheet
Read-only commands that answer most "what is my network doing" questions:
ip -br a # every interface, state and address, one line each
ip -br link # interfaces and MAC addresses
ip r # routing table, including the default gateway
ip route get 1.1.1.1 # which interface and source IP reach this address
ip neigh # ARP / neighbour cache
ip -s link show enp3s0 # packet and error counters
Syntax: ip [options] OBJECT COMMAND. Objects can be abbreviated: ip a = ip address, ip l = ip link, ip r = ip route, ip n = ip neigh. With no command, show is assumed. Anything that changes state needs sudo and is temporary: it is lost on reboot and can be overwritten by NetworkManager at any time. For permanent settings use the nmcli cheat sheet or the static IP guide.
Addresses (ip addr)
| Command | What it does |
|---|---|
ip a | All interfaces with all addresses |
ip -br a | Brief: name, state, addresses |
ip -4 a / ip -6 a | IPv4 or IPv6 only |
ip a show dev wlp2s0 | One interface |
ip a show up | Only interfaces that are up |
sudo ip a add 192.168.1.50/24 dev enp3s0 | Add an address (an interface can have several) |
sudo ip a del 192.168.1.50/24 dev enp3s0 | Remove an address |
sudo ip a flush dev enp3s0 | Remove all addresses from an interface (drops your SSH session if remote) |
ip -j a | jq | JSON output for scripts |
Example output of ip -br a:
lo UNKNOWN 127.0.0.1/8 ::1/128
enp3s0 UP 192.168.1.23/24 fe80::3a2c:4aff:fe10:9b1e/64
wlp2s0 DOWN
The /24 is the prefix length. Use the subnet calculator to turn it into a netmask, network address and host range.
Links and interfaces (ip link)
| Command | What it does |
|---|---|
ip link | All interfaces, state, MTU and MAC address |
ip -s link show enp3s0 | RX/TX packets, errors and drops (-s -s for more detail) |
sudo ip link set enp3s0 up | Bring an interface up |
sudo ip link set enp3s0 down | Take it down |
sudo ip link set enp3s0 mtu 9000 | Change the MTU (jumbo frames) |
sudo ip link set enp3s0 address 02:11:22:33:44:55 | Change the MAC address (bring the link down first on some drivers) |
sudo ip link add br0 type bridge | Create a bridge |
sudo ip link set enp3s0 master br0 | Attach an interface to the bridge |
sudo ip link add link enp3s0 name enp3s0.10 type vlan id 10 | Create a VLAN subinterface |
sudo ip link add veth0 type veth peer name veth1 | Create a virtual Ethernet pair |
sudo ip link del br0 | Delete a virtual interface |
ip -d link show enp3s0 | Details: driver-level type, bridge/VLAN info |
state DOWN with NO-CARRIER means no cable or no Wi-Fi association; that is a physical or driver problem, not an IP one. The Wi-Fi troubleshooting guide covers the wireless side.
Routes (ip route)
| Command | What it does |
|---|---|
ip r | Main IPv4 routing table |
ip -6 r | IPv6 routes |
ip r show default | Only the default route (gateway) |
ip route get 8.8.8.8 | The route, interface and source IP the kernel would pick |
sudo ip r add default via 192.168.1.1 dev enp3s0 | Add a default gateway |
sudo ip r replace default via 192.168.1.254 | Change the default gateway (add or replace) |
sudo ip r add 10.20.0.0/16 via 192.168.1.5 | Route a network through another router |
sudo ip r add 10.30.0.0/24 dev wg0 | Route a network out of an interface directly |
sudo ip r del 10.20.0.0/16 | Delete a route |
ip r show table all | Every routing table (VPNs and policy routing use extra tables) |
ip rule | Policy routing rules (which table is used when) |
Example output of ip r:
default via 192.168.1.1 dev enp3s0 proto dhcp src 192.168.1.23 metric 100
192.168.1.0/24 dev enp3s0 proto kernel scope link src 192.168.1.23 metric 100
No default line means the machine cannot reach anything outside its own subnet, which produces Network is unreachable.
Neighbours, namespaces and monitoring
| Command | What it does |
|---|---|
ip n | Neighbour (ARP/NDP) table: IP to MAC mappings and their state |
sudo ip n flush dev enp3s0 | Clear the neighbour cache for an interface |
sudo ip n add 192.168.1.9 lladdr aa:bb:cc:dd:ee:ff dev enp3s0 | Static ARP entry |
ip monitor | Print address, link and route changes as they happen |
ip netns list | List named network namespaces |
sudo ip netns add test | Create a namespace |
sudo ip netns exec test ip a | Run a command inside a namespace |
ip -c a | Colour output (many distros alias this already) |
ip -o a | One line per address, easy to grep |
Old net-tools equivalents
| Old command | ip equivalent |
|---|---|
ifconfig | ip a |
ifconfig eth0 up | ip link set eth0 up |
ifconfig eth0 192.168.1.5 netmask 255.255.255.0 | ip a add 192.168.1.5/24 dev eth0 |
route -n | ip r |
route add default gw 192.168.1.1 | ip r add default via 192.168.1.1 |
arp -n | ip n |
netstat -tulpn | ss -tulpn |
netstat -i | ip -s link |
Common recipes
Print just your IPv4 address on the default-route interface:
ip route get 1.1.1.1 | awk '{for(i=1;i<NF;i++) if($i=="src") print $(i+1)}'
Give a server a temporary extra address for a migration, then remove it:
sudo ip a add 203.0.113.20/24 dev eth0
sudo ip a del 203.0.113.20/24 dev eth0
Diagnose "no internet" step by step:
ip -br link # is the interface UP with a carrier?
ip -br a # does it have an address (not only fe80::)?
ip r show default # is there a gateway?
ping -c3 "$(ip r show default | awk '{print $3; exit}')" # can you reach it?
resolvectl status # DNS servers (if ping 1.1.1.1 works but names fail)
Watch for interface errors while reproducing a problem:
watch -n1 'ip -s link show enp3s0'
A fuller walkthrough, including DNS and firewalls, is in the Linux networking basics guide.
Gotchas
- Nothing is persistent. NetworkManager, systemd-networkd or netplan own the configuration and will undo your
ipchanges on reconnect or reboot. - Remote lockout.
ip link set ... down,ip a flushor replacing the default route over SSH can cut you off. Schedule a rollback first, for example withsudo systemd-run --on-active=2min ip r replace default via OLD_GW. - Interface names. Modern systems use predictable names like
enp3s0,eno1orwlp2s0, noteth0. Check withip -br link. - Missing netmask = /32.
ip a add 192.168.1.5 dev eth0without a prefix adds a /32 with no subnet route. Always give the prefix. - Two default routes. With wired and Wi-Fi both up, the lowest
metricwins. Compare the metrics inip r.
Full reference: ip(8) and the per-object pages such as ip-route(8).
Frequently asked questions
How do I show my IP address on Linux?
Run ip a (short for ip addr show). For a compact view use ip -br a. Your public IP, as seen from the internet, is different; that needs an external service.
What replaced ifconfig on Linux?
The ip command from iproute2. ifconfig, route and arp come from the old net-tools package, which most distros no longer install by default.
Are changes made with ip permanent?
No. Addresses and routes set with ip disappear on reboot or when NetworkManager reconfigures the interface. Make them permanent with nmcli, netplan or systemd-networkd.
How do I see the default gateway?
Run ip route show default (or just ip r). The address after via is the gateway and the name after dev is the interface used.
How do I find which interface is used to reach an address?
ip route get 1.1.1.1 prints the route, the outgoing interface and the source address the kernel would use for that destination.
Spotted a mistake or a command that no longer works? Send a correction — pages are re-checked when reports come in.