# get hostname from a given IP



## houssam_ballout

Hello,
on my lan, how can I get the hostname of a remote computer if I know the IP of that machine?
Thanks


----------



## Shady

open cmd and write this command

ping -a 192.168.1.66

replace the IP address with the one you want to get it's host name


----------



## tlarkin

are you trying to figure out the DNS host name?  That can be done by doing a reverse DNS look up by IP.  Using the nslookup command.


----------



## houssam_ballout

I'd tried ping -a 192.168.1.66 but it won't , its the same as the normal ping, I got 3 replies.

tlarkin:
I am trying to get the hostname of an computer on LAN knowing its internal IP.


----------



## cohen

houssam_ballout said:


> tlarkin:
> I am trying to get the hostname of an computer on LAN knowing its internal IP.



You mean, the name of the PC on your LAN.... your trying to get the name of that..... by using it's IP.

Try PC Wizard, under network, it tells you what PCs are on the network, the name and their IP.


----------



## houssam_ballout

You mean, the name of the PC on your LAN.... your trying to get the name of that..... by using it's IP. yeah that what I want, 
but is there some command on DOS that allow me to do that.


----------



## Shady

The command I posted works. Look closer.


----------



## G25r8cer

Shady said:


> open cmd and write this command
> 
> ping -a 192.168.1.66
> 
> replace the IP address with the one you want to get it's host name



This works very well


----------



## tyttebøvs

"ping -a" *might* work. It doens't in OP's network. A firewall for example can make it not work.


----------



## Shady

tyttebøvs said:


> "ping -a" *might* work. It doens't in OP's network. A firewall for example can make it not work.



Any ping won't pass a firewall. I assumed everybody knows that. Thanks for pointing that out, it could be the reason why it's not working for him


----------



## Ambushed

Shady said:


> Any ping won't pass a firewall. I assumed everybody knows that. Thanks for pointing that out, it could be the reason why it's not working for him



Yeah but the first post he did point out a "remote" computer.


----------



## jeehtoven

you can use nslookup to get the hostname from a given IP


----------



## tlarkin

jeehtoven said:


> you can use nslookup to get the hostname from a given IP



That is only if DNS is in order.  nslookup is reverse DNS look up and if the DNS is not in order you won't get proper results.


----------



## bilbus

tyttebøvs said:


> "ping -a" *might* work. It doens't in OP's network. A firewall for example can make it not work.



ping works just fine though a firewall, if you open access for ICMP ....

ping -a "ip"

works fine, but unless you have a PTR record on your local dns server you wont get much.

Here is an example

ping -a 74.125.91.103

Pinging qy-in-f103.google.com [74.125.91.103] with 32 bytes of data:

Reply from 74.125.91.103: bytes=32 time=36ms TTL=241
Reply from 74.125.91.103: bytes=32 time=36ms TTL=241


----------



## blondie

Hi all,

The command stated is the correct one, as pointed out firewalls can cause netbios name resolution to fail. But you are also dependent on windows services, I am unsure of which ones.

Regards,


----------



## tlarkin

the host command works too, if you are running a *nix OS:



		Code:
	

$ host www.google.com
www.google.com is an alias for www.l.google.com.
www.l.google.com has address 74.125.95.104
www.l.google.com has address 74.125.95.147
www.l.google.com has address 74.125.95.99
www.l.google.com has address 74.125.95.103


----------

