Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

My network includes machines running Linux and others running Windows. And my machine is running Linux.

share|improve this question
    
The question is a bit unclear, which resulted in the varying - and good - answers below. Do you want to find the DNS name of a host? Do you want to find the WINS name? Do you want to search the network for all hosts found? All of these questions are answered - but the specific answer desired is unknown. –  Mei Sep 29 at 19:08

6 Answers 6

Type in terminal

arp -a

It will show all host name in LAN whether it is Linux or windows.

share|improve this answer
    
This shows nothing on my local network that has 30+ Linux machines... –  Cerin Apr 28 at 16:41
    
@Cerin Are you on Linux machine yourself? –  Shashank Sawant Jul 23 at 3:50

Type in terminal

sudo aptitude install nmap
nmap -sP xxx.xxx.xxx.xxx

This will give you:

Starting Nmap 5.21 ( http://nmap.org ) at 2012-11-03 19:08 CET
Nmap scan report for HOST.DOMAIN (xxx.xxx.xxx.xxx)
Host is up (0.00052s latency).
MAC Address: YY:YY:YY:YY:YY:YY (Manufactor)
Nmap done: 1 IP address (1 host up) scanned in 0.11 seconds

Where HOST.DOMAIN is the DNS-name of the machine.

share|improve this answer
    
This shows all active IPs, but it only shows domains for machines which explicitly have custom domain configured in my local Bind server. It doesn't show any local hostnames, which I think is what the OP is trying to accomplish. –  Cerin Apr 28 at 17:11

What if you try this:

You can run it in windows

nbtstat -A xxx.xxx.xxx.xxx (where x is the ip address)

on ubuntu you can install nbtscan. You can find more information here : http://www.unixwiz.net/tools/nbtscan.html

Hope it helps

share|improve this answer
    
Thanks very much, but it seems that nbtscan detects machines running Windows only. I've 2 machines running Windows and another 2 running Linux. It detects the two running Windows only. –  Islam Hassan Apr 27 '12 at 20:55
    
can you try nmblookup? it should be installed already on Ubuntu –  Brett Apr 27 '12 at 20:57
    
Sorry, I've read the tutorial but couldn't figure out how to write the command that solves my problem. I can't see options taking IP as input. Can you write the command for me please? –  Islam Hassan Apr 27 '12 at 21:04
1  
try nmblookup -A xxx.xxx.x.x where x is the ip address of the machine. So I would do nmblookup -A 192.168.1.6 and it would return the name of my machine. You will need to do that for each machine. –  Brett Apr 27 '12 at 21:19
    
It also detects Windows machines only, but for Linux machines it gives me this error Unable to create directory /var/run/samba for file unexpected.tdb. Error was No such file or directory –  Islam Hassan Apr 27 '12 at 21:37

To the best of my knowledge, there is no utility available to resolve an IP address into a NetBIOS name. I'd imagine that some sort of a network scoping program or a penetration testing program might be able to give you that sore of information though. However, all of the computers would have to be on the same domain and subnet.

share|improve this answer
    
Could you name a program please? –  Islam Hassan Apr 27 '12 at 20:45
    
The OP wants the opposite. e.g. IP->hostname –  Cerin Apr 28 at 16:48
    
I know this is old...and OP is using Linux, not Windows...but on Windows you can run nbtstat -A <IP Address> to get the NetBIOS name from just the IP. This works across subnets and there's no need to be in the same domain. Also, running nbtstat -a <NetBIOS Name> will do the reverse. Hope this helps... –  John Homer Sep 10 at 13:44

If your network is running a DHCP server, usually on the modem/router, chances are it will have a way for you to see the DHCP assigned addresses - often by a web page, and that often lists the computer names beside the allocated ip addresses.

share|improve this answer

I'd just use

nslookup xxx.xxx.xxx.xxx

it will show me the host name (usually the computer name)

share|improve this answer
    
This just gets me ** server can't find xxx.xxx.xxx.xxx.in-addr.arpa.: NXDOMAIN –  Cerin Apr 28 at 16:50

protected by jokerdino Oct 4 '13 at 16:05

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.