ip command in Linux: addresses and interfaces (ip addr)

Updated November 1, 2026

The ip command shows and configures networking: interfaces, addresses and routes.

Syntax

ip OBJECT COMMAND

Common cases

ip addr            # interfaces and their addresses
ip -o addr         # one address per line
ip link            # interfaces and their state (up/down)
ip route           # the routing table and default gateway

Sample output

$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0@if1422: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 56:77:c0:8d:be:4b brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 192.168.215.6/24 brd 192.168.215.255 scope global eth0
       valid_lft forever preferred_lft forever

How it works: ip replaced ifconfig

ip from the iproute2 package is the modern replacement for the old ifconfig, route and netstat. One interface is always present: the loopback lo at 127.0.0.1, the host talking to itself. With ip you name the object first (addr, link, route), then the action. The -o flag is handy when you parse the output with grep, awk or wc.

Common mistakes

Anyone may read the network, only root may change it. ip addr add 10.0.0.5/24 dev eth0 as a normal user answers RTNETLINK answers: Operation not permitted and exits with code 2. Under root it works, but the address goes into the running kernel only, and a reboot wipes it. The permanent setting on Ubuntu lives in /etc/netplan/.

ip link and ip addr show different layers, and that is where people trip. ip link show lo prints the MAC and state UNKNOWN but not a single IP: addresses live only in ip addr output. state UNKNOWN on the loopback is normal, not a fault: there is no carrier for the kernel to poll. The interface name is checked strictly too: ip addr show eth1 with no such device answers Device "eth1" does not exist. and exit code 1.

ip -o addr does not drop the extra fields, it folds them onto one line with a backslash: 1: lo inet 127.0.0.1/8 scope host lo\ valid_lft forever preferred_lft forever. That is fine for awk '{print $4}' and awkward to read. When you want an even table, use ip -br addr, which prints eth0@if1784 UP 192.168.215.5/24.

Used in

You need this in the lesson Networking: inspection. The theory is the chapter Networking basics.

See also

Sockets: ss.

Try it

Open the sandbox: a real throwaway Linux terminal in your browser. Run the commands above by hand - the container is deleted when you leave.