Getting the hostname from a Linux computer on a LAN
Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Getting the hostname from a Linux computer on a LAN
Background: If I go into my router's setup, I can see which computers are currently using the LAN, and it also gives their hostnames.
So if I am a computer on the LAN, how can I get the hostnames of other computers on the LAN? For Windows machines, I know that I can usually use a NetBIOS query to their computer to get the hostname, unless they have taken specific measures to disable it. For a Linux machine, is there a similar way to ask it for its hostname from another computer on the LAN? And if so, how would I disable it?
And in case someone knows, for the specific case of using the WLAN with my router, when my computer first connects to the router and gives the router my computer's hostname, would someone who is sniffing packets "promiscuously" be able to get that information even if I'm using WPA/WPA2? In other words, does my computer give that information to the router before or after the encryption begins?
There are no native broadcast discovery services in traditional *nix networking. Names are discovered by doing IP->hostname lookups, either in /etc/hosts, or via DNS.
With Samba, one can emulate Windows networking, and thereby gain its discovery services.
I do not believe sensitive information is sent into the ether before the encrypted handshake is complete. A host name is hardly sensitive in any case.
There are no native broadcast discovery services in traditional *nix networking. Names are discovered by doing IP->hostname lookups, either in /etc/hosts, or via DNS.
With Samba, one can emulate Windows networking, and thereby gain its discovery services.
I do not believe sensitive information is sent into the ether before the encrypted handshake is complete. A host name is hardly sensitive in any case.
Yes, I totally agree that "a host name is hardly sensitive in any case", I mainly wanted to know this for my own information. Often people name their computers in ways that obviously identify them, so it's a step in the right direction if you can keep that information hidden from would-be hackers on a LAN; that way they have a harder time figuring out which LAN IP actually corresponds to which computer. Thanks for the info!
It's not usually easy to enumerate all of the hosts and hostnames on a network unless they are registered in DNS. Your router has this information because, most likely, it is acting as a DHCP server, and systems send their hostname in their DHCP requests.
To answer the second part of your question: WPA/WEP encryption is applied to each packet that is sent. Only a hardware handshake is performed before the encryption. Hostname information is in the DHCP request, which is in a standard data packet.
Matir, thanks for the info about the host name being given with a DHCP request; I tested it with my router--I connected to my router with a static IP and sure enough, no longer was my host name listed in the router config (whereas the router lists my computer's name when I use DHCP). I'm starting to understand it all better now, thanks for the help.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.