Skip to content
Advertisement

How to get hostname from IP (Linux)?

I’d like to get remote machine/hostname through IP Address. I found lots of answer such as nslookup, host, resloveip, etc.. but I still can’t get hostname from my target machine(cent OS, ubuntu etc…) It seems need to register to DNS server?

I have a machine named test and using IP 10.1.27.97

but I used the method above still can’t not get “test

Does anyone can help me to get the hostname form IP Address?

Advertisement

Answer

In order to use nslookup, host or gethostbyname() then the target’s name will need to be registered with DNS or statically defined in the hosts file on the machine running your program. Yes, you could connect to the target with SSH or some other application and query it directly, but for a generic solution you’ll need some sort of DNS entry for it.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement