List all of your IP addresses using the ip command.

Posted: May 4, 2015. At: 9:50 AM. This was 3 years ago. Post ID: 8178
Page permalink.
WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters. These cookies expire two weeks after they are set.

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 scope host lo
    inet brd scope global eth0
    inet peer scope global tun1194

This is another example. Using the ifconfig command instead.

ubuntu ~/Documents $ ifconfig | grep "inet addr:"
          inet addr:  Bcast:  Mask:
          inet addr:  Mask:
          inet addr:  P-t-P:  Mask:

This command, ipmaddr will list all MAC addresses on your network hardware. Another very useful Linux command.

ubuntu ~/Documents $ ipmaddr
1:      lo
        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
        inet6 ff02::1:ffa8:8213
        inet6 ff02::1
        inet6 ff01::1
7:      tun1194
        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

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'

No comments have been made. Use this form to start the conversation :)

Leave a Reply