Using nmap to resolve host (computer) name.

asked 2017-01-18 03:01:44 -0500

dokterw gravatar image

I am trying to find a simple way to resolve the host name of computers on my local network.

After some searches it seems that (as root) nmap -sn 192.168.0.0/24 should do that, but it doesn't.

I have even tried the following (as root): nmap -sL nmap -sP nmap -sn -R nmap -sn --system-dns (this only shows the host name of the computer I execute nmap on)

My intention is to use this in a bash script, to list all computers on the local network, with their hostname, and either push it to a text file or print to screen.

edit retag flag offensive close merge delete

Comments

nmap does actually work here. Are hostnames configured on all your machines? are them all linux machines (nmblookup)? What about arp -a? Or dig -x ip-address?

fcomida gravatar imagefcomida ( 2017-01-19 08:35:54 -0500 )edit

Yeah, Linux and Mac. And I've tried arp, dig, etc. Even done a broadcast ping and then using arp. I have a hunch it might be the "lovely" router I got from our broadband provider.

I don't remember which one of the tools I used, but where the host name should've been it just just displayed a questionmark.

What is odd though is that the router itself lists the hostnames fine.

dokterw gravatar imagedokterw ( 2017-01-20 00:44:35 -0500 )edit