Windows uses a different system for hostname resolution to Linux.
Linux uses the /etc/hosts
file and/or DNS for name resolution
The /etc/hosts
file is simply a list of IP address and names and was once the only way to map names to IP addresses before it was realised that it was getting to big to manage. The solution was DNS (Domain Name System), which is a distributed database which now underpins the whole Internet.
The host
command that you used only queries DNS - not /etc/hosts
, therefore it cannot find your local computer unless it has a DNS entry.
To access all your Linux machines by name, either create a /etc/hosts
file:
127.0.0.1 localhost.localdomain localhost
192.168.0.5 laptop.mydomain.net laptop
192.168.0.6 server.mydomain.net server
192.168.0.7 printer.mydomain.net printer
and distribute it to all your Linux computer, or install DNS. dnsmasq
is a lightweight DNS/DHCP server which is perfect for a small network.
Windows uses it's own NetBIOS Name Resolution where each computer broadcasts a special message on the local area network in order to find out the IP address of a computer with a specific name. This is why Windows machines tend to find each other automatically when they are on the same network. They cache this for future use so that there isn't too much chatter on the network.
An alternative to this broadcast name resolution (for larger deployments) is WINS (Windows Internet Naming Service) which is a central database of computer and/or service names to IP address. Modern versions of Windows now use DNS as it's the de-facto standard for name resolution and is more scalable than WINS.