1

I wish to know the computer name associated with a known ip-address. The DNS is managed by my router (WIND3 webcube) and I can see the resolved name using the browser (http://192.168.1.1) Nevertheless, I wish to read the LAN computer names by command line from the console. I've tried <ping -r 192.168.1.255> then <arp -a> as suggested by Bodo; this has shown all IPs & relevant MACs on the LAN except my own; the only hostname shown has been the router name corresponding to 192.168.1.1 - half question has been answered, now I have a way to discover remote IPs on the LAN by console. In addition, using <nmap -sn 192.168.1.0/24>, I can see the full list of IPs on the LAN but still no hostnmes.

At the moment the best solution is running this script:
for x in {101..110}
do nslookup 192.168.1.$x | grep name
done

that shows all active names and relevant IPs (reversed)

2 Answers2

2

workarounds(using ping, arp table and scans) that should work in most networks but might not report all devices(reports only those devices that echo/respond to the ping).

With ping and arp

ping(for a short while) the broadcast IP address(i.e. the highest, last and unusable IP address in your sub-net e.g. 192.168.1.255) which will in turn result in ping packets being sent to every possible IP address on your network like so:

ping -b 192.168.1.255

Then, run an arp(Address Resolution Protocol) request like so:

arp -a

With nmap

From man nmap:

-sn (No port scan)
  This option tells Nmap not to do a port scan after host discovery,
  and only print out the available hosts that responded to the host
  discovery probes. This is often known as a “ping scan”.

So, you can use it on your network like so:

nmap -sn 192.168.1.0/24

Where 192.168.1.0(the first unusable IP address i.e. 0) is your network address and 24 is your sub-net mask.

Raffa
  • 34,963
1

To get the name for a single known IP address from the router you can use

dig @router -x ipaddress +short

for example

dig @192.168.1.1 -x 192.168.1.100 +short

see man dig

I was not able to use dig's query type axfr or nslookup's ls command to get a full listing from my router. This might be a permissions issue.

Of course you can use shell programming to run dig in a loop for a range of IP addresses.

Bodo
  • 591