Are you tired of constantly struggling with network connectivity issues and not being able to identify the root cause?
Look no further than the ‘ip addr’ command!
This powerful command allows you to view and manipulate your network interfaces, providing crucial information such as IP addresses, netmasks, and broadcast addresses.
If you’re unfamiliar with this powerful tool, don’t worry, because in this post we’ll be diving into what the “ip addr” command is, what it does, and how you can use it to gain greater control over your network settings.
Get Your Free Linux training!
Join our free Linux training and discover the power of open-source technology. Enhance your skills and boost your career! Learn Linux for Free!Table of Contents
Manage the IP address of a network interface with ip addr command
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, we can easily view information about our system’s current networking configuration and make adjustments as needed.
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, 10.254.222.37)
- The netmask (e.g. /8, /23)
- The broadcast address (e.g. brd 10.254.223.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.
For example, to delete the IP address 192.168.1.20, you would type:
ip addr del 192.168.1.20 dev eth0
How to install ip command in Linux
In most modern Linux distributions, the “ip” command is included in the default installation, so you should be able to use it right away. However, if you’re working with a more minimal installation or an older version of Linux, you may need to install the “iproute2” package manually, which provides the “ip” command and other networking utilities.
Here are the general steps to install the “iproute2” package and the “ip” command on a Linux system:
- Open a terminal window on your Linux system.
- Check if the “ip” command is already installed by running the following command: ip addr. If the command outputs information about your network interfaces, the “ip” command is already installed on your system.
- If the “ip” command is not installed, run the following command to install the “iproute2” package: sudo apt-get install iproute2. Note that the package manager and command may differ depending on your Linux distribution.
- Once the installation is complete, run the “ip” command again to verify that it is now installed on your system.
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.
Conclusion
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
Chris D
Sunday 29th of October 2023
cool. Thanks for the detailed info.