Open In App

How To Use IPRoute2 Tools to Manage Network Configuration on a Linux

Last Updated : 10 Oct, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

In computer networking, the iproute2 command line utility tool is a versatile and powerful tool for users. it provides beginner-friendly functionality to manage and configure the network. In this article, we are going to discuss each and every part of the iproute2 tool and how to implement it in our system. By the end of this article, you’ll have solid knowledge about the iproute2 tool to fine-tune your network settings.

IPRoute2

In Linux distribution, iproute2 is a collection of command line utilities for controlling and monitoring the network configuration. It is the most powerful tool for system administrators, network engineers, and Linux users. It is a more flexible tool than ifconfig, route, and netstat commands. It can be used as multiple configurations of interfaces at the same time.

There are some common utilities of iproute2:

  • ip: It is used to configure and manage IP and routing tables.
  • tc: It is used to configure and manage traffic control rules.
  • bridge: It is used to manage bridge devices.
  • arpd: It is used to manage the ARP cache.
  • ss: It gives the information about TCP & UDP sockets and other network information.

Manage Network configuration on a Linux

Step 1: To show/view the details of all interface

The ip addr or IP address command is used to check IPv4 & IPv6 addresses, additionally it will also show the information of ether(MAC) address, loopback address(lo), interface UP/DOWN state, MTU (Maximum Transfer Unit)..

ip addr

ip-addr

To view the details of particular interface:

ip addr show eth0

ipaddrshow

To view the IPv4 or IPv6 address for the particular interface:

ip -4 addr show eth0


ipv4

ip -6 addr show eth0


ipv6

Step 2: Add/Delete the ip address to a particular interface

For adding or the deleting the ip address, we can use ip addr command along with option “add” or “delete” and “dev” for specifying the interface name.

ip addr 192.168.10.2/24 dev eth0


ip-addr-add

Step 3: To view the network interface details

To know the details of network interface, we can use the command “ip link”. link will display the network devices.

ip link show


iplink-(1)

To view the particular network interface:

ip link show lo


lo

Step 4: Set the network interface up and down

To set the loopback(lo) interface down:

ip link set lo down


lo-down

lo

To set the loopback(lo) interface up

ip link set lo up


lo-up

lo-show-(1)

Step 5: To view and manage the routing table

ip route 


iproute

Add/Delete the static route to the routing table

To add the static route, we can use add option with ip route command and specify destination address, default gateway, and interface name.

ip route add 10.0.5.1 via 10.0.2.2 dev eth0


ip-route-add

iproute2

To delete the static route, we can use del option with ip route command:

ip route del 10.0.5.1 via 10.0.2.2 dev eth0


ip-route-del

Step 6: To view and manipulate the ARP cache on a Linux system

To view the ARP cache on the system:

ip neighbor show


ip-neighbor

It will display the IP address, MAC address and network interface

To add the static ARP entry in cache:

sudo ip neighbor add 10.1.10.10 lladdr 08:00:27:cb:7e:f5 dev eth0 nud permanent



ip-neigh-add

Here, we need to specify “ip address”, “MAC address”, “network interface” and “nud permanent” means entry is permanent

Step 7: To manipulate routing policy database

To view routing rules on the system:

ip rule show



ip-rule-show

It will display the routing rules, matching criteria and action.

To add the routing rule in a routing policy

ip rule add from 10.0.2.15 lookup 20



ip-rule-add

ip-rule-show2

To delete the routing rule in a routing policy:

ip rule del from 10.0.2.15 lookup 20



ip-rule-del

To change the rule priority:

ip rule add from 10.0.2.12 lookup 20 priority 10



Here, the lower priority will be evaluated first

rule-pri

rule-show

Conclusion

In this article, we have discuss about iproute2 utility in a lot more details. we have came across through the usages of different types of iproute2 utilities and their implementations. This article highlights the feature like interface configuration, routing policy, ARP cache entry.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads