7

Is that possible to get the IP address of my machine from the hostname or the machine's own mac address?

If yes, how? If not, could you suggest an alternative way?

Seth
  • 59,332

2 Answers2

6

Of all the suggestions in the comments this one seems easiest.

sudo apt-get install arp-scan

sudo arp-scan --interface=wlan0 --localnet where wlan0 is your interface if your on a wire you'll likely change wlan0 to eth0. You can find out your interface with ifconfig you'll get output similar to this that provides The IP and MAC Address of each machine on your local subnet.

$ sudo arp-scan --interface=eth0 --localnet
Interface: eth0, datalink type: EN10MB (Ethernet)
Starting arp-scan 1.8.1 with 256 hosts (http://www.nta-monitor.com/tools/arp-scan/)
192.168.15.2    XX:XX:XX:XX:XX:XX   NETGEAR
192.168.15.24   XX:XX:XX:XX:XX:XX   BROTHER INDUSTRIES, LTD.
192.168.15.103  XX:XX:XX:XX:XX:XX   GIGA-BYTE TECHNOLOGY CO.,LTD.

Sources:

1) http://www.binarytides.com/scan-the-local-network-with-arp-scan-on-ubuntu/

2) https://superuser.com/questions/261818/how-can-i-list-all-ips-in-the-connected-network-through-terminal-preferably

3)Experience

Elder Geek
  • 36,752
0

Technically it is possibly but Logically not. We can get IP by pinging hostname only if it is bind to that certain IP. In local host its hosts file do that work on business network it's DNS which do that work & on internet as well it's DNS but A records/cname which do that work. We can also get IPs assigned ot hostname set for particular MAC id, but that programatically possible not sure if you can do that with simple commands

To know what is your public IP address : www.ipconfig.in

Edit:

getent hosts <hostname> | awk

This works locally aswell.

An0n
  • 2,225
Bella
  • 21