Unable to resolve hostname to ip

2

2

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?

superuser

Posted 2012-06-09T00:56:38.727

Reputation: 3 297

How is it supposed to work? By what method are you expecting the other servers to resolve the IP? (If you don't have any idea why it should work, then you shouldn't expect it to work and probably it shouldn't work. If you can an idea why it should work, that will be the first big clue that tells you what to investigate.) – David Schwartz – 2012-06-09T01:27:08.487

All of my servers are joined together by a router. This should make it work. When I ping server1, it should ask the router for an ip address (192.168.0.63) and forwards it to the client. But it's not working in this case. – superuser – 2012-06-09T01:34:33.127

Are you saying your router is supposed to provide a name to IP address mapping service of some kind? Is this dynamic DNS? Or is the mDNS or Bonjour? Is the router the DNS server? (You won't be able to figure out why it's not working without first fully understanding how it is supposed to work.) – David Schwartz – 2012-06-09T01:59:32.657

Right, my router is acting as a DNS server inside my work network. Please correct me if I'm wrong... When a computer registers on my router's network, it tells the router what its hostname is and assigns the computer an IP address, right? So, if I go on another PC on the same network and try to ping that computer using its hostname instead of its IP, the router should know what IP to point the request to. However, this doesn't seem to be working on this computer only, other in the same network works! I'm thinking it might be a fqdn issue, but I'm not 100% sure how to fix it. – superuser – 2012-06-09T02:15:28.677

If that's true on your LAN, that would be unusual and you would have to have specifically configured it. If that's the case, I'd check your configuration. If it's based on the client registering in the DNS, make sure the client is set to do that. If it's based on the router/server registering in the DNS, check the router/server's configuration. I should stress that this is an unusual setup, and if you have it, it's because you (or someone else) specifically configured this. – David Schwartz – 2012-06-09T02:17:09.780

what does "cat /etc/resolv.conf" show you on the other linux machine? – Keith – 2012-06-10T09:49:01.907

Keith, all of the other machines have "nameserver 192.168.0.1" in resolv.conf. 192.168.0.1 is the address of the router. – superuser – 2012-06-10T18:37:18.083

Answers

5

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.

killermist

Posted 2012-06-09T00:56:38.727

Reputation: 1 886

Your solution #3 gave me an idea to manually add the host to a list of "static leases" on the router since the Debian server didn't obtain its IP from DHCP. After a reboot, it worked like a charm. Thanks everyone for your helpful inputs! – superuser – 2012-06-10T19:03:17.677