ip Command: Checking Linux IP and Managing Interfaces and Routing

Test environmentRHEL familyAlmaLinux 9.8root accountChecked 2026-10-29
Network commandsipLocation/usr/sbin/ip

The ip command is a key tool for managing the network on Linux and can carry out a wide range of network tasks. On an AlmaLinux 9 server, ip addr, ip link, ip route and ip neigh were run in turn, and four commands were enough to check the server's IP address, the interface status, the default gateway and even its MAC address.

It can check the status of network interfaces or enable and disable them, and it can also check IP addresses or add and delete them manually. It also provides a range of network features, including routing management that views the routing table and adds or removes routes, checking and modifying the ARP table, and tunnel setup.

FeaturesDescription
Checking network statusCheck interface status (UP/DOWN), link information, etc.
IP address managementCheck, add and delete IP addresses
Routing table managementCheck routing information, add and delete routes
ARP table managementCheck and modify the ARP cache
Interface controlEnable or disable interfaces
Tunnel setupCreate and manage tunnel interfaces

Commands that change the server network, such as adding and deleting IP addresses or turning off an interface, were not run on the test server. The IP addresses and MAC addresses in the output below are example values.

1️⃣ Basic Syntax of the ip Command

The ip command takes options (OPTIONS), followed by the object to work on (OBJECT) and the command to run (COMMAND), in that order. Typing just ip with nothing after it prints the usage.

ip
Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }
       ip [ -force ] -batch filename
where  OBJECT := { address | addrlabel | fou | help | ila | ioam | l2tp | link |
                   macsec | maddress | monitor | mptcp | mroute | mrule |
                   neighbor | neighbour | netconf | netns | nexthop | ntable |
                   ntbl | route | rule | sr | stats | tap | tcpmetrics |
                   token | tunnel | tuntap | vrf | xfrm }
       OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |
                    -h[uman-readable] | -iec | -j[son] | -p[retty] |
                    -f[amily] { inet | inet6 | mpls | bridge | link } |
                    -4 | -6 | -M | -B | -0 |
                    -l[oops] { maximum-addr-flush-attempts } | -echo | -br[ief] |
                    -o[neline] | -t[imestamp] | -ts[hort] | -b[atch] [filename] |
                    -rc[vbuf] [size] | -n[etns] name | -N[umeric] | -a[ll] |
                    -c[olor]}

The output of ip on its own was identical, character for character, to that of ip --help and ip help.

OBJECT can be written as the full name or a short name. According to man ip, address can be shortened to addr or a, and when tried, ip r, ip n and ip l also gave the same output as ip route show, ip neigh show and ip link show.

Splitting ip -4 addr show into options, object and command looks like this.

ip -4 addr show
[OPTIONS]
-4IPv4 output only
OBJECT
addrObject: IP address
showCommand: print information

show can be omitted, so ip -4 addr is the same command.

Adding help after an object prints only the commands and arguments that can be used with that object.

ip addr show help
Usage: ip address {add|change|replace} IFADDR dev IFNAME [ LIFETIME ]
                                                      [ CONFFLAG-LIST ]
       ip address del IFADDR dev IFNAME [mngtmpaddr]
       ip address {save|flush} [ dev IFNAME ] [ scope SCOPE-ID ] [ to PREFIX ]
                            [ FLAG-LIST ] [ label LABEL ] [ { up | down } ]
       ip address [ show [ dev IFNAME ] [ scope SCOPE-ID ] [ master DEVICE ]
                         [ nomaster ]
                         [ type TYPE ] [ to PREFIX ] [ FLAG-LIST ]
                         [ label LABEL ] [ { up | down } ] [ vrf NAME ]
                         [ proto ADDRPROTO ] ]
       ip address {showdump|restore}
IFADDR := PREFIX | ADDR peer PREFIX
          [ broadcast ADDR ] [ anycast ADDR ]
          [ label IFNAME ] [ scope SCOPE-ID ] [ metric METRIC ]
          [ proto ADDRPROTO ]
SCOPE-ID := [ host | link | global | NUMBER ]
FLAG-LIST := [ FLAG-LIST ] FLAG
FLAG  := [ permanent | dynamic | secondary | primary |
           [-]tentative | [-]deprecated | [-]dadfailed | temporary |
           CONFFLAG-LIST ]
CONFFLAG-LIST := [ CONFFLAG-LIST ] CONFFLAG
CONFFLAG  := [ home | nodad | mngtmpaddr | noprefixroute | autojoin ]
LIFETIME := [ valid_lft LFT ] [ preferred_lft LFT ]
LFT := forever | SECONDS
ADDRPROTO := [ NAME | NUMBER ]
TYPE := { amt | bareudp | bond | bond_slave | bridge | bridge_slave |
          dsa | dummy | erspan | geneve | gre | gretap | gtp | hsr |
          ifb | ip6erspan | ip6gre | ip6gretap | ip6tnl |
          ipip | ipoib | ipvlan | ipvtap |
          macsec | macvlan | macvtap | netdevsim |
          netkit | nlmon | pfcp | rmnet | sit | team | team_slave |
          vcan | veth | vlan | vrf | vti | vxcan | vxlan | wwan |
          xfrm | virt_wifi }

This usage shows that ip address takes commands such as add, del and show, and arguments such as dev and scope.

2️⃣ Commonly Used ip Commands

The ten commands below are the ones most often used in practice. The commands that check things (show) only read the settings, while add, del and set change the network settings the moment they run.

CommandDescription
ip a (ip addr)Print network interfaces and IP addresses
ip link showCheck network interface status
ip addr addAdd an IP address
ip addr delDelete an IP address
ip route showPrint the routing table
ip route addAdd a route
ip route delDelete a route
ip neigh showView the ARP table
ip link set up/downEnable/disable an interface
ip tunnel addCreate a tunnel

Tunnels are checked with ip tunnel show. On the test server, where no tunnel had been created, it printed nothing.

3️⃣ Linux Command to Check the IP: ip addr

To check a server's IP address on Linux, run ip a, the short form of ip addr.

ip a
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: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc mq state UP group default qlen 1000
    link/ether 02:00:00:00:00:10 brd ff:ff:ff:ff:ff:ff
    altname enp0s5
    altname ens5
    inet 192.0.2.10/24 brd 192.0.2.255 scope global dynamic noprefixroute eth0
       valid_lft 3536sec preferred_lft 3536sec
    inet6 2001:db8:0:1::10/128 scope global dynamic noprefixroute
       valid_lft 446sec preferred_lft 136sec
    inet6 fe80::ff:fe00:10/64 scope link noprefixroute
       valid_lft forever preferred_lft forever

The output starts each interface with a number and a name. 1: lo is the loopback interface used only inside the server, and 2: eth0 is the Ethernet interface that actually communicates. The meaning of each item is shown below.

ItemContents
1: loLoopback interface (for internal communication) · 127.0.0.1/8
2: eth0Ethernet interface
UP, LOWER_UPStatus — enabled
mtu 9001MTU — short for Maximum Transmission Unit, the largest data packet size that can be sent over the network at one time
link/etherMAC address
inet 192.0.2.10/24IPv4 address (subnet mask 255.255.255.0)
brd 192.0.2.255Broadcast address
scope globalRange (scope) — global (system-wide)
dynamicAddress with a limited lifetime (address obtained via DHCP)
noprefixrouteDoes not create a prefix route automatically
valid_lftAddress lifetime (forever = unlimited)
inet6 fe80::…/64IPv6 link-local address (scope link)

The MTU of eth0 was 9001, a value larger than the Ethernet default of 1500. valid_lft showed 3536sec, and when run again a few minutes later it had dropped to 2933sec. An address obtained via DHCP has a fixed lease time, so the remaining time keeps going down. 127.0.0.1 on lo showed forever.

To see only IPv4 addresses, add the -4 option.

ip -4 a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc mq state UP group default qlen 1000
    altname enp0s5
    altname ens5
    inet 192.0.2.10/24 brd 192.0.2.255 scope global dynamic noprefixroute eth0
       valid_lft 3536sec preferred_lft 3536sec

With -4, the link/ether and inet6 lines disappear and only the IPv4 addresses remain.

For a quick check of just the server IP, the output of the -br (brief) option is the shortest.

ip -br a
lo               UNKNOWN        127.0.0.1/8 ::1/128
eth0             UP             192.0.2.10/24 2001:db8:0:1::10/128 fe80::ff:fe00:10/64

Each interface gets one line with its name, status and addresses, but the MTU and lifetime are left out, so check those values with ip a when they are needed. To see a single interface, put its name after dev as in ip addr show dev eth0; giving a name that does not exist printed an error saying the device does not exist, with exit code 1.

Even if an IP address is assigned, packets do not go out while the interface is down, so check the interface status separately with ip link show.

ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether 02:00:00:00:00:10 brd ff:ff:ff:ff:ff:ff
    altname enp0s5
    altname ens5

ip link show prints only the interface names, status and MAC addresses, without IP addresses. UP, LOWER_UP and state UP on the eth0 line mean the interface is on and the link is connected. For lo, the loopback, state showed UNKNOWN.

For a quick look at just the MAC addresses, ip -br link prints one line per interface.

ip -br link
lo               UNKNOWN        00:00:00:00:00:00 <LOOPBACK,UP,LOWER_UP>
eth0             UP             02:00:00:00:00:10 <BROADCAST,MULTICAST,UP,LOWER_UP>

The second column is the status and the third column is the MAC address. The command that turns an interface off and on is ip link set.

ip link set dev eth0 down

down turns the interface off, and up turns it back on.

ip link set dev eth0 up

On a server reached over SSH, bringing down the interface used for the connection drops the connection at that moment, and the up command to turn it back on cannot be sent either. That is why this command is used only on servers that can be accessed directly through a console.

5️⃣ Adding and Deleting IP Addresses: ip addr add and del

The ip command applies network settings immediately, but these settings are temporary. The changes disappear after a reboot, so settings that should stay are better applied with nmtui or a similar command.

Below is the result of adding one more IP address to the enp0s3 interface of a test virtual machine. Put the subnet mask after the address, as in /24, and the interface name after dev.

ip addr add 192.0.2.201/24 dev enp0s3

A successful add prints nothing, so check the result with ip a.

ip a
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: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 02:00:00:00:00:20 brd ff:ff:ff:ff:ff:ff
    inet 192.0.2.200/24 brd 192.0.2.255 scope global noprefixroute enp0s3
       valid_lft forever preferred_lft forever
    inet 192.0.2.201/24 scope global secondary enp0s3
       valid_lft forever preferred_lft forever
    inet6 fe80::200/64 scope link noprefixroute
       valid_lft forever preferred_lft forever

In the output above, 192.0.2.201, added in the same range as the first address 192.0.2.200, is attached as secondary, with no brd address and a lifetime of forever.

To delete, use del in place of add, with the same address and subnet mask as when adding.

ip addr del 192.0.2.201/24 dev enp0s3

A successful delete also prints nothing, so check the remaining IPv4 addresses with ip -4 addr.

ip -4 addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    inet 192.0.2.200/24 brd 192.0.2.255 scope global noprefixroute enp0s3
       valid_lft forever preferred_lft forever

As in the output above, only the first address 192.0.2.200 remains after the deletion.

6️⃣ Checking the Routing Table and ARP with the ip Command

The path that packets leaving the server take is in the routing table, which is checked with ip route show.

ip route show
default via 192.0.2.1 dev eth0 proto dhcp src 192.0.2.10 metric 100
192.0.2.0/24 dev eth0 proto kernel scope link src 192.0.2.10 metric 100

show can be omitted, so ip route and ip r give the same output. 192.0.2.1 after default via is the default gateway, and 192.0.2.10 after src is the IP address this server uses when sending packets.

proto dhcp means this route was obtained via DHCP. The second line means that addresses in the same range (192.0.2.0/24) are sent straight out through eth0 without going through the gateway.

Which route is used to reach a specific destination is checked with ip route get.

ip route get 8.8.8.8
8.8.8.8 via 192.0.2.1 dev eth0 src 192.0.2.10 uid 0
    cache

In the output above, packets to 8.8.8.8 go out through eth0 via the default gateway 192.0.2.1, and the source address is 192.0.2.10.

To add or delete routes directly, use ip route add and ip route del.

ip route add 198.51.100.0/24 via 192.0.2.1 dev eth0

According to man ip-route, write the destination range after add, the gateway after via, and the interface after dev.

ip route del 198.51.100.0/24

After del, write the destination range to delete.

To hand packets to the gateway within the same network, the gateway's MAC address is needed, and that value is kept in the ARP table.

ip neigh show
192.0.2.2 dev eth0 lladdr 02:00:00:00:00:01 REACHABLE
192.0.2.1 dev eth0 lladdr 02:00:00:00:00:01 REACHABLE
fe80::ff:fe00:1 dev eth0 lladdr 02:00:00:00:00:01 router REACHABLE

What follows lladdr is the neighbor's MAC address, and the IPv6 gateway line has router attached. According to man ip-neighbour, REACHABLE at the end means the entry is valid until its confirmation time runs out.

Matching the values the four commands print to a single packet going to 8.8.8.8 gives the following.

🧭 Where the Output of the Four ip Commands Fits
Explainer diagram
🧭 Command
$ ip -4 a
inet 192.0.2.10/24 brd 192.0.2.255 scope global dynamic noprefixroute eth0
$ ip link show
2: eth0: … state UP … link/ether 02:00:00:00:00:10
$ ip route get 8.8.8.8
8.8.8.8 via 192.0.2.1 dev eth0 src 192.0.2.10 uid 0
$ ip neigh show
192.0.2.1 dev eth0 lladdr 02:00:00:00:00:01 REACHABLE
① This server's eth0192.0.2.10/24state UP02:00:00:00:00:10
→
② Default gateway192.0.2.102:00:00:00:00:01
→
③ Destination8.8.8.8
ip addr prints the IP address assigned to eth0. The server uses this value as the source address when sending packets.
ip link prints whether eth0 is up and the MAC address of eth0. If the interface is down, packets do not go out even if it has an IP address.
ip route prints the route to the destination. Packets to 8.8.8.8 go out through eth0 via the default gateway 192.0.2.1.
ip neigh prints the gateway's MAC address. Within the same network, packets are delivered to the gateway using this MAC address.

🔲 ip Command Simulator

On the virtual server in the simulator below, ip addr, ip link, ip route and ip neigh can be typed in directly. Adding an IP address makes a secondary address appear in the status panel, and turning off the interface changes eth0 to DOWN.

ip Command Simulatoriproute2 · example addresses
[root@server work]#
Use the ↑↓ keys to recall commands you typed earlier.

🔢 FAQ & Recommended Content

On the AlmaLinux 9 server, ifconfig was /usr/sbin/ifconfig from the net-tools package, and ip was /usr/sbin/ip from the iproute package. Both commands print interfaces and IP addresses, but with net-tools, routing and ARP are checked separately with the route and arp commands, while ip handles them within a single command as ip route and ip neigh.

With some cloud servers, the provider attaches the public IPv4 address from outside the server, so ip a may show only a private range address. The addresses in the article's output are example values. The actual eth0 IPv4 address on the test server was in a private range (10.x · 172.16~31.x · 192.168.x), and the public IPv4 address used to connect was not on the interface. The public IP is checked in the provider's control panel.

Running ip -c a with the -c option showed interface names, MAC addresses and IP addresses in different colors. According to man ip, -c=auto adds color only when the output is a terminal, and -c=never turns color off.

ℹ️ Affiliate Disclosure
This site's content contains affiliate links. When a visitor buys a product or service through one of them, the site receives a commission from the seller. The amount the buyer pays(it goes down during event discounts ↓)does not go up. Posted prices, discounts, and stock reflect the time of writing and may differ, so confirm with the seller before buying. Products are chosen and reviewed by our own standards, and commissions do not affect the order or content of reviews.

Leave a Reply

Your email address will not be published. Required fields are marked *

Prove your humanity: 8   +   2   =