The ip command will list all of your ip addresses when combined with the grep command to look for all inet words. This is a very useful one-liner.
ubuntu ~/Documents $ ip a | grep "inet " inet 127.0.0.1/8 scope host lo inet 172.31.20.16/20 brd 172.31.31.255 scope global eth0 inet 10.8.0.1 peer 10.8.0.2/32 scope global tun1194
This is another example. Using the ifconfig command instead.
ubuntu ~/Documents $ ifconfig | grep "inet addr:" inet addr:172.31.20.16 Bcast:172.31.31.255 Mask:255.255.240.0 inet addr:127.0.0.1 Mask:255.0.0.0 inet addr:10.8.0.1 P-t-P:10.8.0.2 Mask:255.255.255.255
This command, ipmaddr will list all MAC addresses on your network hardware. Another very useful Linux command.
ubuntu ~/Documents $ ipmaddr 1: lo inet 188.8.131.52 inet6 ff02::1 inet6 ff01::1 2: eth0 link 01:00:5e:00:00:01 link 33:33:00:00:00:01 link 33:33:ff:a8:82:13 inet 184.108.40.206 inet6 ff02::1:ffa8:8213 inet6 ff02::1 inet6 ff01::1 7: tun1194 inet 220.127.116.11 inet6 ff02::1 inet6 ff01::1
As you can see, these commands are very useful for the Linux user that needs information about their network hardware.
To get the MAC address of the eth0 interface, you may also use this command.
ubuntu ~/Documents $ cat /sys/class/net/eth0/address 06:d6:3a:a8:82:13
Finally, this command will return your IP address for the eth0 interface.
ubuntu ~/Documents $ /sbin/ifconfig eth0 | sed -e's/^.*inet addr:\([^ ]*\) .*$/\1/;t;d' 172.31.20.16