Linux Commands - Display IP address info using the ip command
by
Jeremy Canfield |
Updated: October 23 2023
| Linux Commands articles
On some systems, the ip command is not installed. apt-get or yum install can be used to install the ip command.
yum install iproute
The ip address (or `ip addr` or `ip a`) command without any options will display information about all of the active interfaces being used.
~]# ip a
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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eno16777984: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:64:f5:94 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.5/24 brd 192.168.0.255 scope global noprefixroute eno16777984
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe64:f594/64 scope link
valid_lft forever preferred_lft forever
The list or show option can be used to display information on a specific interface.
~]# ip address show eno16777984
2: eno16777984: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:64:f5:94 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.5/24 brd 192.168.0.255 scope global noprefixroute eno16777984
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe64:f594/64 scope link
valid_lft forever preferred_lft forever
Or, sometimes you may want to go with the hostname command and the -i or --ip-address flag. It is important to recognize that if there are 2 or more IP addresses bound to an interface, this command will return the primary IP address, not the additional (e.g. secondary) IP addresses.
~]# hostname --ip-address
192.168.0.5
Did you find this article helpful?
If so, consider buying me a coffee over at