Operating System - HP-UX
1755258 Members
5116 Online
108831 Solutions
New Discussion юеВ

Find hostname with IP address

 
Ullrich Rieger
Occasional Contributor

Find hostname with IP address

Hi,

Is there a way to tell the hostname of a host from a given IP address? A solution that works within the LAN would be sufficient.

TIA
Ully
6 REPLIES 6
Mark van Hassel
Respected Contributor

Re: Find hostname with IP address

Ullrich,

This is possible when you have a IP-hostname database such as the /etc/hosts file or an DNS server. The command you can use is:
nslookup [IP or hostname]
The surest sign that life exists elsewhere in the universe is that none of it has tried to contact us
Michael Duthie
Trusted Contributor

Re: Find hostname with IP address

Try using "nslookup"

eg #nslookup 192.1.1.1

This will check the default ip resolution table usually /etc/hosts, DNS or NIS.
Rainer von Bongartz
Honored Contributor

Re: Find hostname with IP address

You will have to set up a DNS server (bind services) on your HP box for example.
point your clients (UNIX file /etc/resolv.conf, NT Network settings) to use this DNS server.
the command to ask DNS for an ip-address of a box in your network then will be nslookup (UNIX and NT)

look at the DNS cook-book at
http://www.troubleshooters.com/tpromag/9811/dns.htm
He's a real UNIX Man, sitting in his UNIX LAN making all his UNIX plans for nobody ...
Magdi KAMAL
Respected Contributor

Re: Find hostname with IP address

Hi Ullrich,

nslookup command allow you by giving it either a hostname or an IP address to give you :

hostname, ip address and aliases.

You need to set the file /etc/nsswitch.conf with the following entry :
hosts: files[NOTFOUND=continue UNAVAIL=continue] dns [NOTFOUND=return UNAVAIL=continue TRYAGAIN=return]

this scanes first /etc/hosts file and then DNS.
You may do the inverse ( dns then /etc/hosts ) by putting dns first and then hosts in the file /etc/nsswitch.conf.

Magdi
Ravi_8
Honored Contributor

Re: Find hostname with IP address

Hi,
using 'nslookup' it's possible, but you need to have nis server and DNS entry for all system in your LAN. otherwise it wouldn't.
never give up
Harinath N
Frequent Advisor

Re: Find hostname with IP address

Hi Ullrich,

First of all you should have some data resource for resolving things, ie., either /etc/hosts file on your system or an DNS database in your network. The entry in /etc/hosts file should be like,

IP Hostname (Alias Name-if needed)

Then you have to edit the /etc/nsswitch.conf file and make required entry. If you want to resolve IP to Hostname and vice-versa you can use nslookup.

Regards,
N.Harinath.