How to retrieve the IP address with ip under Linux ?
In this story, you will learn how to retrieve the IP address with the ip command.
Ensure that ifconfig is installed :
sudo yum install net-tools
To show the interfaces of the system :
ip address show
lo is the loopback address. In general, it’s 127.0.0.1/8.
To filter a device :
ip address show dev eth1
The IPv4 address is listed in the line starting with inet.
Retrieve the IP address can be done like that :
ip address show dev eth1 | grep “inet “ | awk ‘{ print $2 }’
You can see that in video (in french …) on my Youtube channel DevOpsTestLab.
Bruno Delb, founder of the blog http://www.DevOpsTestLab.com.