19

I have used arp-scan in terminal to get the ipaddress as well as mac address, is there anyway i can get to know the hostname of the ipaddress that are there in the terminal? for example there are A-pc and B-pc and C-pc connected to the same router. I need to get the hostname the same way i got the result in arp-scan. Is there any command? please reply to this. Thank you.

PS: I dont want to use wireshark or any other s/w. It would be helpful if there was a terminal command.

thanmai
  • 367

4 Answers4

14

Assuming you have a local DNS server set up, dig should do

dig +short -x 123.456.789.12

(Yes, that's not a valid IP, it's a Hollywood IP)

geirha
  • 47,279
12

try nslookup

Note: All tools require a DNS that have a reverse lookup zone. (the default is forward lookup zone only). This is why it will work on most external domains (internet) because they are registered in DNS all over the internet. for internal network you need an internal DNS reverse lookup server. check the following link

3

To get the hostname from the IP address. The simplest way is to use the “host” utility . Just run…

# host 64.233.187.99
output is: #99.187.233.64.in-addr.arpa domain name pointer jc-in-f99.google.com.

This will query the name server and provide you with the hostname of the IP address.By default it will query the nameserver listed in the /etc/resolv.conf file.

2

I'm assuming you want the netbios name?

sudo apt-get install nbtscan
echo will scan: $(hostname -I | cut -d ' ' -f 1)/24
nbtscan $(hostname -I | cut -d ' ' -f 1)/24