How to use IP Command in Linux with Examples

The linux ip command is similar to ifconfig, but more powerful and is intended to be a replacement for it. With ip you have the advantage of performing several network administration tasks with only one command. ifconfig is one of the deprecated command within net-tools that has not been maintained for many years. The functionalities of many commands is retained with more features under iproute2 suite.

Net tools vs Iproute2

To install ip download the iproute2 suite utility here, however most Linux distributions will come with the iproute2 tools pre-installed.

You can also use use git to download the source code:

$ git clone

iproute2 git clone

1) Setting and Deleting an Ip Address

To set an IP address for your computer, the command ip can be used as follows:

$ sudo ip addr add dev wlan0

Note that the IP address has a prefix, for example /24. This is used in classless inter-domain routing (CIDR) to show the subnet mask used. In this case the subnet mask is

After you have set the IP address confirm with show, whether the the changes have taken effect.

$ ip addr show wlan0

set ip address

You can also use the same procedure to delete an IP address by just replacing add with del.

$ sudo ip addr del dev wlan0

delete ip address

2) Show Routing Table Entry

The route object of ip command also helps you to see the route packets will take in your network as set in your routing table. The first entry is the default route which you can change as you prefer.

In this example there are several routes. These are a result of having a several devices connected through different network interface. These include WIFI, Ethernet and a point to point link.

$ ip route show

ip route show

Suppose now that you have an IP address which you need to know the route packets will take. You can use route option as follows:

$ ip route get

ip route get

3) Changing The Default Route

To change the default route, the ip command can be used as follows:

$ sudo ip route add default via

default route

4) Show Network Statistics

The ip command can also be used to show the statistics of the various network interfaces. To do this you can use the ip command with the option -s and then specify the network device.

$ ip -s link

ip statistics all interfaces

When you need to get information about a particular network interface, add the option ls followed by the name of the network interface. The option -s when used more than once gives you more information about that particular interface. This can be very useful especially when trouble shooting errors in network connectivity.

$ ip -s -s link ls p2p1

ip link statistics

5) ARP Entries

Address Resolution Protocol (ARP) is used to translate an IP address to its corresponding physical address, commonly known as MAC address. With ip command you can view the MAC address of the devices connected in your LAN by using the option neigh or neighbour.

$ ip neighbour

ip neighbour

6) Monitor Netlink Messages

It is also possible to view netlink messages with ip command. The monitor option allows you to see the state of your network devices. For instance a computer on your LAN could be categorized as REACHABLE or STALE depending on its status. The command can be used as follows:

$ ip monitor all

ip monitor all

7) Activate and Deactivate Network Interface

To activate a particular interface you can use the ip command with options up and down, almost similar to how ifconfig is used.

In this example you can see the routing table entry when the ppp0 interface is activated and after it is deactivated and activated once again. The interface can be wlan0 or eth0. Change ppp0 to whatever interface is available in your case.

$ sudo ip link set ppp0 down

$ sudo ip link set ppp0 up

ip link set up and down

8) Getting Help

In case you get stuck and do not know how a particular option works you can use the help option. The man page does not give a lot of information on how to use the ip options and this is where help comes to the rescue.

For example, to know more about the route option:

$ ip route help

ip route help

9) TCP Delayed ACK

From RHEL 7.1 iproute package added support for TCP Delayed ACK. Use below command to enable it

ip route quickack


The command ip is a must have tool for network administrators and all Linux users alike. It is time to move from ifconfig, especially when you are writing scripts.

Bobbin Zachariah 3:00 am


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

All comments are subject to moderation.


  1. I often use ifconfig to create alias interface (when I have to configure new router with factory setting, etc). I miss similar example using ip command. Syntax with ipconfig is simple:

    ifconfig eth0:0

    I found that I can do that with ip command too, but it not simple command: :-(

    ip addr add brd dev eth0 label eth0:0

  2. Has it occurred to you that when you write an article like this one (that isn't full of content-free fluff) your readers might want to save the information it presents for later reference? As one such reader I typically keep a crib sheet with useful examples that I've cut'n'pasted from various sources. But here you are, perversely using PNG images to present (some of the) info in an article about inherently textual command line tools, thereby making it difficult for us to preserve the info in question. >-/

    Good work, nevertheless...

  3. Thanks for the info, this is a good walkthrough of iproute, but I'm not sure(or convinced) of why ifconfig is now considered harmful.

    I mean, okay, woohoo progress, but as your table shows, you need two different commands to do what netstat does by itself. You also still need to use command like iw(1) to configure the underlying properties of WLAN devices, the BlueZ suite for bluetooth devices, etc.

    Removing net-tools as a package is certainly one way to force users to use iproute, but I remain unconvinced that it's actually materially *better*.

    1. iproute2 is actively maintained. net-tools has not been maintained since 2001.

      I haven't used ifconfig in years. I use ip; it can do far more than I typically need it to do.