Our Knowledge Base provides step-by-step guides, troubleshooting tips, and expert insights to help you manage VPS, dedicated servers, domains, DDoS protection, and more — all designed to make your experience with us fast, secure, and stress-free.
This article explains how to use the ip command through practical examples and detailed explanations of the most common options.
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.
The ip utility is a part of the iproute2 package that is installed on all modern Linux distributions.
The syntax for the ip command is as follows:
ip [ OPTIONS ] OBJECT { COMMAND | help }
OBJECT is the object type that you want to manage. The most frequently used objects (or subcommands) 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).
The object can be written in full or abbreviated (short) form. To display a list of commands and arguments for each object, enter, ip OBJECT help.
When configuring network interfaces, you must execute the commands as root or 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 the changes permanent, you need to edit the distro-specific configuration files or add the commands to a startup script.
When operating with the addr object the commands take the following form:
ip addr [ COMMAND ] ADDRESS dev IFNAME
The most frequently used COMMANDS of the addr object are: show, add, and del.
To display a list of all network interfaces and the associated ip address type the following command:
ip addr show
The output will look something like this:
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 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:16:3e:39:e7:1f brd ff:ff:ff:ff:ff:ff inet 5.254.113.196/26 brd 5.254.113.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::216:3eff:fe39:e71f/64 scope link valid_lft forever preferred_lft forever
You will get the same output if you type omit the show command and type: ip addr.
If you want to display only IPv4 or IPv6 ip addresses, use ip -4 addr or ip -6 addr.
To get information about a specific network interface, use ip addr show dev followed by the device name. For example, to query eth0, you would type:
ip addr show dev eth0
To assign an IP address to an interface, use the following syntax:
ip addr add ADDRESS dev IFNAME
Where IFNAME is the interface name and ADDRESS is the IP address you want to assign to the interface.
To add address 192.168.121.45 with netmask 24 to device eth0, you would type:
sudo ip address add 5.254.113.196/26 dev eth0
On success, the command will not show any output. If the interface doesn’t exist, you will get C
annot find device “eth0”.
With ip, you can assign multiple addresses to the same interface. For example:
sudo ip address add 169.254.0.0/16 dev eth0sudo ip address add 5.254.113.196/26 dev eth0
To confirm the IPs are assigned type ip -4 addr show dev eth0 or ip -4 a show dev eth0:
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 inet 169.254.0.0/16 brd 192.168.121.255 scope global dynamic eth0 valid_lft 3515sec preferred_lft 3515sec inet 5.254.113.196/26 scope global secondary eth0 valid_lft forever preferred_lft forever
The syntax to remove an IP address from an interface is as below:
ip addr dev ADDRESS dev IFNAME
IFNAME is the interface name, and ADDRESS is the IP address you want to remove from the interface.
To remove address 5.254.113.196/26 from device eth0 type:
sudo ip address del 5.254.113.196/26 dev eth0
To manage and view the state of the network interfaces, use the link object.
When working with the link objects, the most commonly used commands are: show, set, add, and del.
To display a list of all network interfaces, type the following command:
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 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000 link/ether 00:16:3e:39:e7:1f brd ff:ff:ff:ff:ff:ff
Unlike ip addr show, ip link show will not print information about the IP addresses associated with the device.
To get information about a specific network interface, use ip link show dev followed by the device name. For example, to query eth0 you would type:
ip link show dev eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000 link/ether 00:16:3e:39:e7:1f brd ff:ff:ff:ff:ff:ff
To bring interfaces up or down, use the ip link set dev followed by the device name and the desired state:
ip link set dev {DEVICE} {up|down}
For example, to bring the interface eth0 online, you would type:
ip link set eth0 up
And to bring if offline
ip link set eth0 down
To assign, remove, and display the kernel routing table use the route object. The most commonly used commands when working with the routes objects are: list, add, and del.
To get a list of the kernel route entries, use one of the following commands:
ip route ip route list ip route list SELECTOR
When used without a SELECTOR the command will list all of the route entries in the kernel:
ip route list
5.254.113.192/26 dev eth0 proto kernel scope link src 5.254.113.196 169.254.0.0/16 dev eth0 scope link metric 1002
To add a new entry to the routing table, use the route add command followed by network or device name.
Add a route to 192.168.121.0/24 via the gateway at 192.168.121.1
ip route add 192.168.121.0/24 via 192.168.121.1
Add a route to 192.168.121.0/24 that can be reached on device eth0.
ip route add 192.168.121.0/24 dev eth0
To add a default route, use the keyword default. The following command will add a default route via the local gateway 192.168.121.1 that can be reached on device eth0.
ip route add default via 192.168.121.1 dev eth0
To delete an entry from the routing table, use the route add command. The syntax for deleting a route is the same as when adding.
The following command will delete the default route:
ip route del default
Delete a route for 192.168.121.0/24 via the gateway at 192.168.121.1
ip route add 192.168.121.0/24 via 192.168.121.1
By now, you should have a good understanding of how to use the Linux ip command. For more information about the other ip options, visit the ip command man page or type man ip in your terminal.