▶Prefer to watch? This video runs the guide's main commands on a real Ubuntu 24.04 machine, with on-screen captions and no voiceover. Click to play, or watch it on YouTube. It is part of the Networking and Firewalls playlist.
ip [OPTIONS] OBJECT COMMAND
ip addr show
ip is the modern tool for viewing and changing network settings on Linux. It replaces the
old ifconfig, route, arp and netstat commands (part of the iproute2 package). Objects can be
shortened as long as they are unique: ip a = ip addr, ip r = ip route, ip l = ip link.
Changes made with ip last until reboot. Make them permanent in your distribution's
network config (netplan, NetworkManager, systemd-networkd or /etc/network/interfaces).
Old command to ip command
ifconfig ip addr (or ip -s link for statistics)
ifconfig eth0 up ip link set eth0 up
route -n ip route
route add / del ip route add / del
arp -a ip neigh
netstat -i ip -s link
netstat -g ip maddr
iptunnel ip tunnel
Useful global options
-br Brief, one line per item ip -br addr
-c Color output ip -c addr
-4 / -6 Only IPv4 / only IPv6 ip -4 addr
-s Statistics (add another -s for more errors detail)
-j / -p JSON output / pretty-print it ip -j -p addr
-d Show details
-o One record per line (good for scripts)
Show addresses and interfaces
ip addr # all interfaces and their addresses (ip a)
ip -br addr # short summary: name, state, addresses
ip -4 -br addr # IPv4 only
ip addr show eth0 # one interface
ip addr show dev eth0 scope global
ip link # link-layer info: state, MAC address, MTU (ip l)
ip -br link
ip -s link show eth0 # packet, error and drop counters
ip link show up # only interfaces that are up
Look for state UP, LOWER_UP (cable/link present), and the inet line for the IPv4 address.
Add and remove addresses
sudo ip addr add 192.168.1.50/24 dev eth0 # add an address
sudo ip addr add 192.168.1.51/24 dev eth0 # a second address on the same NIC
sudo ip addr del 192.168.1.50/24 dev eth0 # remove one
sudo ip addr flush dev eth0 # remove ALL addresses from the interface
sudo ip addr add 10.0.0.5/24 brd + dev eth0 # brd + sets the broadcast address
sudo ip -6 addr add 2001:db8::5/64 dev eth0
Use CIDR notation: /24 = 255.255.255.0, /16 = 255.255.0.0, /32 = a single host.
Bring interfaces up and down
sudo ip link set eth0 up
sudo ip link set eth0 down
sudo ip link set eth0 mtu 9000 # change MTU
sudo ip link set eth0 address 02:11:22:33:44:55 # change the MAC address
sudo ip link set eth0 name lan0 # rename (interface must be down)
sudo ip link set eth0 promisc on # promiscuous mode
sudo ip link set dev eth0 txqueuelen 2000
Do not bring down the interface you are connected to over SSH.
Routing
ip route # routing table (ip r)
ip route show table all
ip -6 route
ip route get 8.8.8.8 # which route and source IP would be used?
ip route get 8.8.8.8 from 192.168.1.50
sudo ip route add default via 192.168.1.1 # default gateway
sudo ip route add default via 192.168.1.1 dev eth0
sudo ip route add 10.10.0.0/16 via 192.168.1.254 # route to a network
sudo ip route add 10.20.0.0/16 dev eth1 # directly connected network
sudo ip route add 10.30.0.0/16 via 192.168.1.254 metric 200 # lower metric wins
sudo ip route replace default via 192.168.1.2 # add or change
sudo ip route del 10.10.0.0/16
sudo ip route del default
sudo ip route flush cache
sudo ip route add blackhole 203.0.113.0/24 # silently drop traffic
sudo ip route add unreachable 203.0.113.0/24 # reject with an error
Fast check: ip route get <address> tells you exactly what the kernel will do with a packet.
Neighbors (ARP and IPv6 neighbor discovery)
ip neigh # ARP/NDP table (ip n)
ip neigh show dev eth0
ip neigh show nud reachable
sudo ip neigh add 192.168.1.20 lladdr 00:11:22:33:44:55 dev eth0 nud permanent
sudo ip neigh del 192.168.1.20 dev eth0
sudo ip neigh flush dev eth0 # clear the cache
States: REACHABLE (fresh), STALE (needs re-checking), DELAY/PROBE (checking),
FAILED (no answer), PERMANENT (static entry).
Policy routing (route by source or mark)
ip rule # list rules
sudo ip route add default via 10.0.0.1 table 100 # a custom table
sudo ip rule add from 192.168.2.0/24 table 100 # use it for that source
sudo ip rule add fwmark 1 table 100
sudo ip rule del from 192.168.2.0/24 table 100
ip route show table 100
Custom table names can be defined in /etc/iproute2/rt_tables.
Virtual interfaces
sudo ip link add link eth0 name eth0.10 type vlan id 10 # VLAN
sudo ip link add br0 type bridge # bridge
sudo ip link set eth1 master br0 # add a port to the bridge
sudo ip link set eth1 nomaster
sudo ip link add bond0 type bond mode active-backup # bond
sudo ip link add veth0 type veth peer name veth1 # virtual cable pair
sudo ip link add dummy0 type dummy # dummy interface for testing
sudo ip link add wg0 type wireguard # WireGuard interface
sudo ip tuntap add dev tap0 mode tap # tun/tap device
sudo ip link del eth0.10 # remove a virtual interface
bridge link # (separate tool) show bridge ports
Network namespaces (isolated network stacks, used by containers)
sudo ip netns add lab # create one
ip netns list
sudo ip netns exec lab ip addr # run a command inside it
sudo ip netns exec lab bash # a shell inside it
sudo ip link set veth1 netns lab # move an interface into it
sudo ip netns del lab
Try it: connect two namespaces with a veth pair to build a small lab without any hardware.
Multicast, tunnels and more
ip maddr # multicast addresses
sudo ip tunnel add gre1 mode gre remote 203.0.113.1 local 198.51.100.1 ttl 255
sudo ip link add gre2 type gre remote 203.0.113.1 local 198.51.100.1
ip monitor # watch address, link and route changes live
ip monitor route
ip -s -s link # detailed error counters
ip mroute # multicast routing cache
ip tcp_metrics # cached TCP metrics
Practical one-liners
# My IPv4 address on the default route
ip -4 route get 1.1.1.1 | awk '{for(i=1;i<=NF;i++) if($i=="src") print $(i+1)}'
# Just the IPv4 addresses of every interface
ip -4 -o addr show | awk '{print $2, $4}'
# The default gateway
ip route | awk '/default/ {print $3}'
# The interface used for the default route
ip route show default | awk '{print $5}'
# Which interface has this IP?
ip -o addr | grep 192.168.1.50
# MAC address of an interface
ip -br link show eth0
cat /sys/class/net/eth0/address
# Is the link up? (script friendly)
ip -j link show eth0 | jq -r '.[0].operstate'
# Watch traffic counters change
watch -n1 'ip -s link show eth0'
# Add a temporary address, test, remove it
sudo ip addr add 192.168.1.99/24 dev eth0 && ping -c2 192.168.1.1; sudo ip addr del 192.168.1.99/24 dev eth0
# List every route with its metric
ip route show | sort -k1
# Simple check that a host is reachable on the LAN (ARP)
ping -c1 192.168.1.20 >/dev/null; ip neigh show 192.168.1.20
Related tools
ss -tulpn Listening sockets (replaces netstat)
ping -c4 host Reachability traceroute / tracepath host Path to a host
dig / resolvectl query DNS lookups nmcli / networkctl NetworkManager / systemd-networkd
tcpdump -i eth0 Packet capture ethtool eth0 NIC speed, duplex, driver
bridge Bridge and VLAN info tc Traffic control (shaping)
Common problems
Address shows but no connectivity No default route: ip route, then add one with ip route add default via <gateway>
Interface is DOWN ip link set eth0 up, and check the cable or virtual switch
NO-CARRIER No link: cable, switch port or virtual NIC is disconnected
Set an IP, gone after reboot ip changes are temporary: put it in netplan or NetworkManager
"RTNETLINK answers: File exists" The address or route is already there: use ip route replace
"Cannot find device" Wrong interface name: check ip -br link (names like enp3s0)
"Network is unreachable" No route to that network from the chosen interface
Cannot reach other subnets Missing route or gateway; check ip route get <address>
Tips
Start with ip -br addr and ip route: together they answer most "why is the network broken" questions.
ip route get <address> shows exactly which interface, gateway and source IP will be used.
Changes with ip are not permanent. Make them permanent in netplan, NetworkManager or systemd-networkd.
Be careful over SSH: removing the address, route or link you are connected on drops your session. Use a console or a scheduled undo.
Use -br for readable summaries, -c for color and -j with jq in scripts.
Interfaces on modern systems have predictable names like enp3s0 and wlp2s0, not eth0. Check yours first.
Use ip -s link to look for errors and drops before blaming the network.
Old ifconfig, route and arp commands are deprecated. Learn the ip equivalents.
Test risky routing changes on a lab using network namespaces (ip netns) first.