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
To view the details of particular interface:
ip addr show eth0
To view the IPv4 or IPv6 address for the particular interface:
ip -4 addr show eth0
ip -6 addr show eth0
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
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
To view the particular network interface:
ip link show lo
Step 4: Set the network interface up and down
To set the loopback(lo) interface down:
ip link set lo down
To set the loopback(lo) interface up
ip link set lo up
Step 5: To view and manage the routing table
ip route
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
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
Step 6: To view and manipulate the ARP cache on a Linux system
To view the ARP cache on the system:
ip neighbor show
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
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
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
To delete the routing rule in a routing policy:
ip rule del from 10.0.2.15 lookup 20
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
How To Use IPRoute2 Tools to Manage Network Configuration on a Linux
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.