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

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

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

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

[email protected]:~$ arp -n
Address                  HWtype  HWaddress           Flags Mask            Iface
10.10.0.1                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 10.10.0.2/24 brd 10.10.0.255 scope global eth2

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

[email protected]:~$ ifconfig | grep 'inet addr:'
          inet addr:10.10.0.2  Bcast:10.10.0.255  Mask:255.255.255.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

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

Leave a Reply