How to Use IP Command in Linux

How to Use IP Command in Linux

IP command is a command with more features that ifconfig. The command helps to do various tasks related to network administration. Today, ifconfig command is the least used command

Setting and Deleting an IP Address

$ sudo ip addr add IPaddress/24 dev eth0

In this the IP address includes a prefix. This is used to show the subnet mask used.

(Replace IP address with exact IP address)

To verify the changes, show command can be useful.

$ ip addr show wlan0

The same steps can lead you to delete the IP address by replacing the add with del.


Show Routing Table Entry

The entries made first in this table are default and can be altered later. IP commands are mainly used for viewing the route packets which leads to the network as per mentioned in the routing table. 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

To view the route packet of a specified IP address

$ ip route get IP address

(Replace IP address with exact IP address)


Changing The Default Route

The default route can be modified using the IP commands as follows.

$ sudo ip route add default via IP address

(Replace IP address with exact IP address)


Show Network Statistics

The various interfaces statistics can be viewed by specifying the option ls followed by the name of the network interface.

$ ip -s link

The option -s is used to view more information related to the particular interface. These are mostly used at the time of troubleshooting errors in network connectivity.

$ ip  -s  -s link ls eth0


ARP Entries

The translation physical address to its MAC address can be done with the help of Address Resolution Protocol (ARP). The IP command and option neigh or neighbor are used to display the MAC address of the LAN connected devices.

$ ip neighbour


Monitor Netlink Messages

To view the netlink messages, the use of IP command with monitor option will suitably produce the output about state of your network devices. To determine the category on which the computer connected in a LAN is a REACHABLE or STALE can be decided depending in on its status.

The command can be used as follows:

$ ip monitor all


Activate and Deactivate Network Interface

Specific interface can be activated or deactivated using the IP command by using options up and down. This is 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 eth0 down

$ sudo ip link set ppp0 up


Getting Help

The help option provides a great assistance in case if you have any doubts with the working of the options. Although the main page of the IP command provides less information, the help will compensate it with required information. For example, to know more about the link option:

$ ip link help


If you need any further assistance please contact our support department.


  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to Block Bots using Robots.txt File?

How to Block Bots using Robots.txt File? The robots.txt file is a simple text file placed on...

PageSpeed on cPanel Server

PageSpeed on cPanel Server PageSpeed on cPanel Server PageSpeed (mod_pagespeed) is a module for...

How to change cPanel logout URL

How to change cPanel logout URL Do you know that it is possible to change cPanel logout URL any...

How to Change cPanel Style

How to Change cPanel Style How to Change cPanel Style cPanel is the most popular control panel...