The Wayback Machine - https://web.archive.org/web/20230512155753/https://www.geeksforgeeks.org/ip-command-in-linux-with-examples/
Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

ip command in Linux with examples

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Ip command in Linux is present in the net-tools which are used for performing several network administration tasks. IP stands for Internet Protocol. This command is used to show or manipulate routing, devices, and tunnels. It is similar to the ifconfig command, but it is much more powerful with more functions and facilities attached to it. ifconfig is one of the deprecated commands in the net-tools of Linux that has not been maintained for many years. The ip command is used to perform several tasks like assigning an address to a network interface or configuring network interface parameters. It can perform several other tasks like configuring and modifying the default and static routing, setting up a tunnel over IP, listing IP addresses and property information, modifying the status of the interface, and assigning, deleting, and setting up IP addresses and routes. 

Syntax of the `ip` command in Linux

ip [ OPTIONS ] OBJECT { COMMAND | help }

Options available in the `ip` command in Linux

1) address

 This option is used to show all IP addresses associated with all network devices.

ip address
ip address

ip address

This will show the information related to all interfaces available on our system, but if we want to view the information of any particular interface, add the options shown followed by the name of the particular network interface.

ip address show (interface)

For Example:

ip address show enp3s0
ip address show enp3s0

ip address show enp3s0

2) link

It is used to display link layer information; it will fetch characteristics of the link layer devices currently available. Any networking device which has a driver loaded can be classified as an available device.

ip link
ip link

ip link

 This link option when used with -s option is used to show the statistics of the various network interfaces.

ip -s link
ip -s link

ip -s link

 And, to get information about a particular network interface, add an option show followed by the name of the particular network interface.

ip -s link show (interface)

For Example:

ip -s link show enp3s0
ip -s link show enp3s0

ip -s link show enp3s0

3) route

 This command helps you to see the route packets your network will take as set in your routing table. The first entry is the default route.

ip route
ip route

ip route

4) add: 

This is used to assign an IP address to an interface.

ip a add (ip_address) dev (interface)

For Example:

ip a add 192.168.1.50/24 dev enp3s0

5) del:

 This is used to delete an assigned IP address to an interface.

ip a del (ip_address) dev (interface)

For Example:

ip a del 192.168.1.50/24 dev enp3s0

6) up:

 This option enables a network interface.

ip link set (interface) up

For Example:

ip link set enp3s0 up

7) down: 

This option disables a network interface.

ip link set (interface) down

For Example:

ip link set enp3s0 down

8) monitor: 

This command can monitor and display the state of devices, addresses and routes continuously.

ip monitor
ip monitor

ip monitor

9) help 

This command is used to help to know more about ip command.

ip help
ip help

ip help

10) neighbour

This command is used to view the MAC address of the devices connected to your system.

ip neighbour
ip neighbour

ip neighbour

  • STABLE: This means that the neighbor is valid, but is probably already unreachable, so the kernel will try to check it at the first transmission.
  • REACHABLE: This means that the neighbor is valid and reachable.
  • DELAY: This means that a packet has been sent to the stable neighbor and the kernel is waiting for confirmation.
  • Delete an ARP entry:
ip neighbour del (ip_address) dev interface

For Example:

ip neighbour del 192.168.0.200 dev enp3s0

Add an ARP entry:

ip neighbour add (ip_address) dev interface

For Example:

ip neighbour add 192.168.0.200 dev enp3s0

Conclusion

The `ip` command in Linux is a powerful tool that is used for performing administrative tasks. We can say that this command is the improved version of the deprecated `ifconfig` command. As we discussed, this command can be used to manipulate devices, routing and tunnels. This `ip` command can also monitor the state of devices, routes and addresses. Overall, we can say that this command is a versatile tool that can be helpful network administrators manage their networks more efficiently.


My Personal Notes arrow_drop_up
Last Updated : 05 May, 2023
Like Article
Save Article
Similar Reads
Related Tutorials