Linux ip Command with Examples

By 

Updated on

8 min read

Linux ip Command

The ip command is a powerful tool for configuring network interfaces that any Linux system administrator should know. It is used to bring interfaces up or down, assign and remove addresses and routes, manage ARP cache, and much more.

This article explains how to use the ip command through practical examples and detailed explanations of the most common options.

How to Use the ip Command

The ip utility is part of the iproute2 package, which is installed on all modern Linux distributions.

The syntax for the ip command is as follows:

txt
ip [OPTIONS] OBJECT { COMMAND | help }

OBJECT is the object type you want to manage. The most frequently used objects are:

  • link (l) — Display and modify network interfaces.
  • address (a) — Display and modify IP addresses.
  • route (r) — Display and alter the routing table.
  • neigh (n) — Display and manipulate neighbor objects (ARP table).

Each object can be written in full or abbreviated form. To display a list of commands and arguments for a given object, run ip OBJECT help.

When configuring network interfaces, you must run the commands as root or a user with sudo privileges. Otherwise, the command will print RTNETLINK answers: Operation not permitted.

The configurations set with the ip command are not persistent. After a system restart, all changes are lost. To make changes permanent, you need to edit the distribution-specific network configuration files or add the commands to a startup script.

Displaying and Modifying IP Addresses

When operating with the addr object, commands take the following form:

txt
ip addr [COMMAND] ADDRESS dev IFNAME

The most frequently used commands of the addr object are show, add, and del.

Display Information about All IP Addresses

To display a list of all network interfaces and their associated IP addresses:

Terminal
ip addr show
output
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
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 52:54:00:8c:62:44 brd ff:ff:ff:ff:ff:ff
    inet 192.168.121.241/24 brd 192.168.121.255 scope global dynamic eth0
       valid_lft 2900sec preferred_lft 2900sec
    inet6 fe80::5054:ff:fe8c:6244/64 scope link
       valid_lft forever preferred_lft forever

You will get the same output if you omit show and type ip addr. To display only IPv4 or IPv6 addresses, use ip -4 addr or ip -6 addr.

Display Information about a Single Interface

To get information about a specific network interface, use ip addr show dev followed by the device name:

Terminal
ip addr show dev eth0

Assign an IP Address to an Interface

To assign an IP address to an interface:

txt
ip addr add ADDRESS dev IFNAME

Where IFNAME is the interface name and ADDRESS is the IP address with its prefix length.

To add address 192.168.121.45/24 to device eth0:

Terminal
sudo ip address add 192.168.121.45/24 dev eth0

On success, the command produces no output. If the interface does not exist, you will get Cannot find device "eth0".

Assign Multiple IP Addresses to the Same Interface

With ip, you can assign multiple addresses to the same interface:

Terminal
sudo ip address add 192.168.121.241/24 dev eth0
sudo ip address add 192.168.121.45/24 dev eth0

To confirm the IPs are assigned:

Terminal
ip -4 addr show dev eth0
output
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    inet 192.168.121.241/24 brd 192.168.121.255 scope global dynamic eth0
       valid_lft 3515sec preferred_lft 3515sec
    inet 192.168.121.45/24 scope global secondary eth0
       valid_lft forever preferred_lft forever

Remove an IP Address from an Interface

To remove an IP address from an interface:

txt
ip addr del ADDRESS dev IFNAME

To remove address 192.168.121.45/24 from device eth0:

Terminal
sudo ip address del 192.168.121.45/24 dev eth0

Displaying and Modifying Network Interfaces

To manage and view the state of network interfaces, use the link object. The most commonly used commands are show, set, add, and del.

Display Information about Network Interfaces

To display a list of all network interfaces:

Terminal
ip link show
output
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 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 52:54:00:8c:62:44 brd ff:ff:ff:ff:ff:ff

Unlike ip addr show, ip link show does not print IP address information.

To query a specific interface:

Terminal
ip link show dev eth0
output
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 52:54:00:8c:62:44 brd ff:ff:ff:ff:ff:ff

Bring an Interface Up or Down

To bring interfaces up or down, use ip link set dev followed by the device name and state:

txt
ip link set dev DEVICE { up | down }

To bring eth0 online:

Terminal
sudo ip link set eth0 up

To bring it offline:

Terminal
sudo ip link set eth0 down

Display Interface Statistics

To view packet and error statistics for an interface, use the -s flag:

Terminal
ip -s link show dev eth0
output
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 52:54:00:8c:62:44 brd ff:ff:ff:ff:ff:ff
    RX:  bytes packets errors dropped  missed   mcast
    1923498    8438      0       0       0     204
    TX:  bytes packets errors dropped carrier collsns
     842103    5565      0       0       0       0

Displaying and Altering the Routing Table

To assign, remove, and display kernel routing table entries, use the route object.

Display the Routing Table

To list all kernel route entries:

Terminal
ip route list
output
default via 192.168.121.1 dev eth0 proto dhcp src 192.168.121.241 metric 100
192.168.121.0/24 dev eth0 proto kernel scope link src 192.168.121.241
192.168.121.1 dev eth0 proto dhcp scope link src 192.168.121.241 metric 100

To display routing for a specific network:

Terminal
ip route list 172.17.0.0/16
output
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown

Add a New Route

To add a route to 192.168.121.0/24 via the gateway at 192.168.121.1:

Terminal
sudo ip route add 192.168.121.0/24 via 192.168.121.1

To add a route reachable on device eth0:

Terminal
sudo ip route add 192.168.121.0/24 dev eth0

To add a default route via the gateway 192.168.121.1 on device eth0:

Terminal
sudo ip route add default via 192.168.121.1 dev eth0

Delete a Route

To delete an entry from the routing table, use the route del command with the same syntax as route add.

To delete the default route:

Terminal
sudo ip route del default

To delete a specific route:

Terminal
sudo ip route del 192.168.121.0/24 via 192.168.121.1

Displaying and Manipulating the ARP Table

The neigh object manages the neighbor (ARP) table, which maps IP addresses to MAC addresses on the local network.

To display the current ARP table:

Terminal
ip neigh show
output
192.168.121.1 dev eth0 lladdr 52:54:00:12:35:02 REACHABLE
192.168.121.10 dev eth0 lladdr 52:54:00:9a:41:af STALE

To add a static ARP entry:

Terminal
sudo ip neigh add 192.168.121.50 lladdr 00:11:22:33:44:55 dev eth0

To delete an ARP entry:

Terminal
sudo ip neigh del 192.168.121.50 dev eth0

To flush all ARP entries for an interface:

Terminal
sudo ip neigh flush dev eth0

Quick Reference

CommandDescription
ip addr showShow all IP addresses
ip addr show dev eth0Show addresses for one interface
ip addr add IP/PREFIX dev eth0Assign an IP address
ip addr del IP/PREFIX dev eth0Remove an IP address
ip link showShow all interfaces
ip link set eth0 upBring interface up
ip link set eth0 downBring interface down
ip -s link show dev eth0Show interface statistics
ip route listShow routing table
ip route add default via GW dev eth0Add default route
ip route del defaultDelete default route
ip neigh showShow ARP table
ip neigh flush dev eth0Flush ARP entries for interface

For a printable quick reference, see the IP command cheatsheet .

Troubleshooting

“RTNETLINK answers: Operation not permitted” The command requires root privileges. Prefix it with sudo: sudo ip link set eth0 up.

“Cannot find device” The interface name is wrong or the interface does not exist. List available interfaces with ip link show to find the correct name. Modern systems may use names like ens3, enp2s0, or wlan0 instead of eth0.

Changes lost after reboot The ip command applies changes only to the running kernel state. To make them persistent, add the configuration to your distribution’s network configuration files — systemd-networkd, NetworkManager, or /etc/network/interfaces depending on the distro.

ip route add fails with “RTNETLINK answers: File exists” A route for the same destination already exists. Delete the existing route first with ip route del DESTINATION, then re-add it.

FAQ

What is the difference between ip and ifconfig? ifconfig is part of the older net-tools package and is deprecated on most modern Linux distributions. ip from the iproute2 package is the replacement — it supports more features, has a consistent syntax across all network objects, and is actively maintained.

How do I make ip changes persistent across reboots? The ip command modifies the running kernel state only. To persist changes, configure your network manager — systemd-networkd (edit files in /etc/systemd/network/), NetworkManager (use nmcli or connection files), or the distro-specific interface configuration.

How do I find my server’s IP address? Run ip addr show and look for inet lines. The loopback address 127.0.0.1 is the local machine; any other inet address on an active interface is your network IP.

What does the /24 mean in an IP address like 192.168.1.1/24? The /24 is the prefix length (CIDR notation). It defines the subnet mask — /24 means the first 24 bits are the network portion, equivalent to a 255.255.255.0 netmask. This tells the system which addresses are on the local network.

Can I use ip to monitor network traffic? The ip -s link show command shows basic packet and error counters. For detailed traffic monitoring, use dedicated tools like ss, netstat, iftop, or tcpdump.

Conclusion

The ip command covers the full range of day-to-day network configuration tasks — from assigning addresses and managing routes to inspecting the ARP table. It replaces the older ifconfig and route commands on all modern Linux systems. For more details on available options, run man ip or ip OBJECT help.

Linuxize Weekly Newsletter

A quick weekly roundup of new tutorials, news, and tips.

About the authors

Dejan Panovski

Dejan Panovski

Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.

View author page