As a Linux user, you may have used the ip addr command at some point. But do you know what this command does and how it can be useful?
In this blog post, we’ll take a closer look at the ip addr command and what it can do for you.
ip addr command is used to check the IP address of a network interface
The ip addr command is a basic networking utility used to view, add, and delete IP addresses on network interfaces.
By default, the ip addr command displays information about all network interfaces on a Linux system.
This includes information such as the name of each interface, its IP addresses, the netmask, broadcast address, and the status of the interface (up or down).
With this command, I can easily view information about my system’s current networking configuration and make adjustments as needed.
This makes ip addr an invaluable tool for efficiently resolving any network-related issues.
Here’s an example of the ip addr command and its output:
$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether fa:16:3e:18:3a:76 brd ff:ff:ff:ff:ff:ff
inet 10.254.222.37/23 brd 10.254.223.255 scope global dynamic eth0
valid_lft 74268sec preferred_lft 74268sec
This output shows information about two network interfaces on the system: lo (the loopback interface) and eth0 (a network interface card).
For each interface, the output shows:
- The name of the interface (e.g. lo, eth0)
- The status of the interface (e.g. UP)
- The MAC address (e.g. 00:11:22:33:44:55)
- The IP addresses assigned to the interface (e.g. 127.0.0.1, 192.168.0.100)
- The netmask (e.g. /8, /24)
- The broadcast address (e.g. brd 192.168.0.255)
This information can be useful when troubleshooting network connectivity issues, or when configuring network interfaces on a Linux system.
If you want to view information about a specific interface, you can specify the interface name as an argument to the ip addr command.
For example, to view information about the eth0 interface, you can use the following command:
ip addr show eth0
This will display information about the eth0 interface, including its IP addresses, netmask, broadcast address, and status.
The ip addr add command is used to assign an IP address to a network interface and make it available on the network.
To use this command, you must first specify the IP address that you want to assign, followed by the name of the interface you are working with. For example, to assign the IP address 192.168.1.20, you would type: ip addr add 192.168.1.20/32 dev eth0.
If you need to delete an IP address from a network interface, you can use ip addr del command. This command can be useful for removing old or unused IP addresses and for reorganizing your network configuration.
To use this command, you must first specify the IP address that you want to delete, followed by the name of the interface you are working with. For example, to delete the IP address 192.168.1.20, you would type: ip addr del 192.168.1.20 dev eth0.
case study to troubleshoot a network issue with ip addr command
One of our customers John had been having trouble with his home network for weeks and was starting to get frustrated.
He tried a few basic troubleshooting steps of restarting the router, but the issue persisted. Desperate to get back online, he decided to try something else.
After the consulting with us, he entered “ip addr show” to list his current network configuration.
To his surprise, he identified an old address that should have been deleted but hadn’t been.
With this knowledge in hand, John was able to make the necessary changes using the ip addr del command. This allowed him to quickly delete the outdated IP address from his system and get back online.
If you’re having issues with network connectivity, you can use the ip addr command to verify that your system has the correct IP address and that the interface is in the “UP” state.
If the IP address is incorrect, or if the interface is in the “DOWN” state, you can use the information provided by the ip addr command to diagnose and resolve the issue.
ip addr command displays information about all the network interfaces on a Linux system. This includes the IP address, netmask, broadcast address, and more. The ip addr command is useful for troubleshooting networking issues