Identifying Network Interfaces on Linux
This article briefly describes a method of identifying which network interfaces on a Linux server are associated with which IP addresses.
You can get a simple list of the network interfaces and IPv4 addresses on your server by running the following command:
/sbin/ip -4 -o a | cut -d ' ' -f 2,7 | cut -d '/' -f 1
The output will list the interface names on the left and the associated IP addresses on the right.
lo 127.0.0.1 eth0 126.96.36.199 eth1 10.173.3.121
For IPv6 you can run a similar command, but with "-6" in place of "-4":
/sbin/ip −6 -o a | cut -d ' ' -f 2,7 | cut -d '/' -f 1
Here too the interface names will be on the left and the IP addresses on the right.
lo ::1/128 eth0 2001:4801:7817:72:bc18:4779:ff10:1653 eth0 fe80::be76:4eff:fe10:1633 eth1 fe80::be76:4eff:fe10:12ab
To get all the information about your network interfaces in one place, just run:
The detailed output lists each interface, any associated IP addresses, their network prefix length, their scope, and plenty of other data besides. For more information, check the man page for the "ip address" command:
© 2011-2013 Rackspace US, Inc.
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License
See license specifics and DISCLAIMER