LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   get netbios name from ip address? (https://www.linuxquestions.org/questions/linux-networking-3/get-netbios-name-from-ip-address-792311/)

Hailey's_Comet 03-01-2010 05:51 AM

get netbios name from ip address?
 
At the CLI, I want to know how to get a netbios name from an IP address. It seems that every solution that I have found is windows based, or requires me to install something beyond samba. Please tell me that there is a simple "prog-x -somearg 192.168.1.100" or similar to get the netbios name - and that it doesn't require a reconfiguration of my server?

For instance, I would like this to be usable on a desktop system in an ad hoc without having to be run from root.

acid_kewpie 03-01-2010 06:52 AM

Not sure what "beyond Samba" means, but samba should contain the answer. Is this not visible from "smbclient -L a.b.c.d"?

And if you aren't using Samba, why would you possibly care about netbios names?

Hailey's_Comet 03-01-2010 08:03 AM

Absolutely! That gave me all the info I need! Now why was that so hard for me to find?!?

By beyond I meant in addition to. This will help me diagnose quite a bit in my network, I think.

ilikejam 03-01-2010 08:08 AM

nmap might be worth looking into as well.

e.g.
nmap --script smb-os-discovery.nse -p445 hostname

Dave

acid_kewpie 03-01-2010 08:08 AM

NetBIOS. *shudder*

Hailey's_Comet 03-01-2010 08:20 AM

@acid_kewpie: yeah, my roomies like their PC's like they like their, um, NM.

@ilikejam: Yours seems to work better, and is parsable by shell script. Thank you as well. I am still a noob at nmap...

acid_kewpie 03-01-2010 02:50 PM

yeah, nmap FTW. it is so useful it's unreal.

jschiwal 03-01-2010 02:56 PM

If your system runs the avahi daemon, then "getent hosts <ip_address>" may return both the hostname and IP address using zeroconf (mdns). It depends on how your nsswitch.conf and host.conf are configured.

You can also run "getent hosts <hostname>". This will also return IP addresses for hosts on the internet. For avahi, add .local to the hostname. E.G.
getent hosts elite.local
192.168.1.106 elite.local

I configure my router to map MAC numbers to IP addresses, which allows me to maintain an /etc/hosts file. Entering "getent hosts elite.local" allows me to conveniently look up another hosts IP address before entering it in /etc/hosts.

jefro 03-01-2010 04:27 PM

It can depend on your lan.

Try this nmblookup -A ip_address


All times are GMT -5. The time now is 08:16 PM.