ip Command Cheat Sheet

Most used

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)

CommandWhat it does
ip aAll interfaces with all addresses
ip -br aBrief: name, state, addresses
ip -4 a / ip -6 aIPv4 or IPv6 only
ip a show dev wlp2s0One interface
ip a show upOnly interfaces that are up
sudo ip a add 192.168.1.50/24 dev enp3s0Add an address (an interface can have several)
sudo ip a del 192.168.1.50/24 dev enp3s0Remove an address
sudo ip a flush dev enp3s0Remove all addresses from an interface (drops your SSH session if remote)
ip -j a | jqJSON 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.

CommandWhat it does
ip linkAll interfaces, state, MTU and MAC address
ip -s link show enp3s0RX/TX packets, errors and drops (-s -s for more detail)
sudo ip link set enp3s0 upBring an interface up
sudo ip link set enp3s0 downTake it down
sudo ip link set enp3s0 mtu 9000Change the MTU (jumbo frames)
sudo ip link set enp3s0 address 02:11:22:33:44:55Change the MAC address (bring the link down first on some drivers)
sudo ip link add br0 type bridgeCreate a bridge
sudo ip link set enp3s0 master br0Attach an interface to the bridge
sudo ip link add link enp3s0 name enp3s0.10 type vlan id 10Create a VLAN subinterface
sudo ip link add veth0 type veth peer name veth1Create a virtual Ethernet pair
sudo ip link del br0Delete a virtual interface
ip -d link show enp3s0Details: 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)

CommandWhat it does
ip rMain IPv4 routing table
ip -6 rIPv6 routes
ip r show defaultOnly the default route (gateway)
ip route get 8.8.8.8The route, interface and source IP the kernel would pick
sudo ip r add default via 192.168.1.1 dev enp3s0Add a default gateway
sudo ip r replace default via 192.168.1.254Change the default gateway (add or replace)
sudo ip r add 10.20.0.0/16 via 192.168.1.5Route a network through another router
sudo ip r add 10.30.0.0/24 dev wg0Route a network out of an interface directly
sudo ip r del 10.20.0.0/16Delete a route
ip r show table allEvery routing table (VPNs and policy routing use extra tables)
ip rulePolicy 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

CommandWhat it does
ip nNeighbour (ARP/NDP) table: IP to MAC mappings and their state
sudo ip n flush dev enp3s0Clear the neighbour cache for an interface
sudo ip n add 192.168.1.9 lladdr aa:bb:cc:dd:ee:ff dev enp3s0Static ARP entry
ip monitorPrint address, link and route changes as they happen
ip netns listList named network namespaces
sudo ip netns add testCreate a namespace
sudo ip netns exec test ip aRun a command inside a namespace
ip -c aColour output (many distros alias this already)
ip -o aOne line per address, easy to grep

Old net-tools equivalents

Old commandip equivalent
ifconfigip a
ifconfig eth0 upip link set eth0 up
ifconfig eth0 192.168.1.5 netmask 255.255.255.0ip a add 192.168.1.5/24 dev eth0
route -nip r
route add default gw 192.168.1.1ip r add default via 192.168.1.1
arp -nip n
netstat -tulpnss -tulpn
netstat -iip -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 ip changes on reconnect or reboot.
  • Remote lockout. ip link set ... down, ip a flush or replacing the default route over SSH can cut you off. Schedule a rollback first, for example with sudo systemd-run --on-active=2min ip r replace default via OLD_GW.
  • Interface names. Modern systems use predictable names like enp3s0, eno1 or wlp2s0, not eth0. Check with ip -br link.
  • Missing netmask = /32. ip a add 192.168.1.5 dev eth0 without 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 metric wins. Compare the metrics in ip 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.