Unable to resolve hostname to ip

On my Debian server, the hostname is set to "debian." When I tried to ping debian from another Linux machine, it says "ping: cannot resolve debian: Unknown host." When trying to ping to any other servers, it's able to resolve for ip and ping successfully. What's wrong?


Solution 1:

Windows networking has kind of spoiled people on how networks are supposed to work.

Windows machines all run (by default, anyway) a name resolution service as part of SMB. This starts to be a confusion when non-windows components are added to the network, and they "don't act predictably".

Additionally some components, being designed with the knowledge that some things won't act windowsy (for lack of a better word) include "features" to "encourage things to just work". These features just make more ambiguous how the network is actually working.

There are a couple solutions:

  1. Install/activate the Samba service on the Debian box. This will enable the name resolution service, so the box can be seen by-name from windows machines. Be aware any other Linux machines on the network will probably still not see the machine by-name, since Linux machines generally don't use SMB level name resolution for network lookups.
  2. Use custom host files so all the known machines on the network can reference each other by name without having to use a resolution service. This is my preferred method, but can get complicated with networks that grow larger than 10 machines or so.
  3. Some routers that can handle DNS locally will reverse-include machines that get their IP by DHCP from them. But, this relies on all the machines on the network using the router as the primary DNS provider, and not an ISP or other external DNS provider (like OpenDNS). For routers I've used that had this feature, success was kind of a hit or miss kind of thing, but also had the problem of any machine with a static IP (not getting IP by DHCP), was not in the DNS table on the router, so had to be manually dealt with anyway.

Basically, it all comes down to knowing and mastering your local network. Windows made a little too much of network administration too easy for too long, and it has unfortunately led to a lot of incorrect assumptions about how networks work.