This command will lookup the network adapter that you are using and return the gateway IP address.
jason@eyjafjallajkull:~$ arp -n | grep : | awk '{print $1}' 10.10.0.1 |
This looks for the : character that is in the MAC address like this.
jason@Yog-Sothoth:~$ arp -n Address HWtype HWaddress Flags Mask Iface 192.168.1.1 ether c8:14:51:5f:a9:47 C enp0s25 |
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.
jason@Yog-Sothoth:~$ ip a | grep "brd" link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 link/ether 00:13:46:3a:02:83 brd ff:ff:ff:ff:ff:ff link/ether d0:50:99:0d:ab:0f brd ff:ff:ff:ff:ff:ff inet 192.168.1.2/24 brd 192.168.1.255 scope global dynamic enp0s25 link/ether 52:54:00:5b:ba:d8 brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 link/ether 52:54:00:5b:ba:d8 brd ff:ff:ff:ff:ff:ff |
Or this one. This lists all interfaces that are connected with IP addresses. This does include the loopback interface, as it does have an IP.
jason@Yog-Sothoth:~$ ifconfig | grep 'inet ' inet 192.168.1.2 netmask 255.255.255.0 broadcast 192.168.1.255 inet 127.0.0.1 netmask 255.0.0.0 inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255 |