Another way to get the IP address of your machine with the arp command.

Posted: April 9, 2015. At: 1:24 PM. This was 2 years ago. Post ID: 8108

This command will lookup the network adapter that you are using and return your network address.

[email protected]:~$ arp -n | grep : | awk '{print $1}'

This looks for the : character that is in the MAC address like this.

[email protected]:~$ arp -n
Address                  HWtype  HWaddress           Flags Mask            Iface                ether   c4:04:15:4d:44:24   C                     eth2

And then it returns the first entry which is the IP address. Yet another cool trick to return a IP address for your network hardware.

This command returns all IP addresses with accompanying broadcast addresses.

[email protected]:~$ ip a | grep "brd"
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    link/ether 6c:f0:49:b5:e6:2a brd ff:ff:ff:ff:ff:ff
    link/ether 00:13:46:3a:02:83 brd ff:ff:ff:ff:ff:ff
    link/ether f8:1a:67:10:b1:63 brd ff:ff:ff:ff:ff:ff
    inet brd scope global eth2

Or this one. This lists all interfaces that are connected with IP addresses.

[email protected]:~$ ifconfig | grep 'inet addr:'
          inet addr:  Bcast:  Mask:
          inet addr:  Mask:
          inet addr:  P-t-P:  Mask:

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

Leave a Reply