Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a strange problem with domain name resolution on my VPS. The problem is that when I do a ping, or telnet to a non-existing domain name, then the ".com" top level domain name gets automatically appended to the original domain name.

1) nslookup test

[root@myhost etc]# nslookup www.dhjfdghfgdhafgdh.com
Server:         168.144.1.130
Address:        168.144.1.130#53

** server can't find www.dhjfdghfgdhafgdh.com: NXDOMAIN

OK - expected result

2) ping test

[root@myhost etc]# ping -v www.dhjfdghfgdhafgdh.com
PING www.dhjfdghfgdhafgdh.com.com (208.73.211.69) 56(84) bytes of data.
64 bytes from 208.73.211.69: icmp_seq=1 ttl=238 time=78.2 ms
64 bytes from 208.73.211.69: icmp_seq=2 ttl=238 time=74.5 ms
64 bytes from 208.73.211.69: icmp_seq=3 ttl=238 time=76.4 ms
^C
--- www.dhjfdghfgdhafgdh.com.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2427ms
rtt min/avg/max/mdev = 74.594/76.431/78.264/1.498 ms

NOK – non-existing domain gets resolved as “.com” somehow miraculously gets appended to the original domain. com.com is a registered domain name so I can ping it, but I am pinging a different domain then I intended to.

3) telnet test

[root@myhost etc]# telnet www.dhjfdghfgdhafgdh.com 80
Trying 208.73.211.69...
Connected to www.dhjfdghfgdhafgdh.com.
Escape character is '^]'.

NOK – same as ping. This time however, telnet does not tell me I am actually connected to the com.com host. I can only tell from the IP address.

This is my /etc/resolv.conf:

nameserver 168.144.1.130
nameserver 108.59.242.6

Thanks for any hints.

share|improve this question

migrated from stackoverflow.com Aug 12 '13 at 13:27

This question came from our site for professional and enthusiast programmers.

    
This is not a programming question. –  James Polley Aug 12 '13 at 9:19
add comment

2 Answers

This is a feature, not a bug.

Say that your local domain is example.com, and you have a machine called server. It's nice to be able to ping server and have everything Just Know(TM) that you meant server.example.com.

To accomplish this, there are a couple of settings that can be configured. These settings could be on your local machine (possibly set by your dhcp server, if you have one); or they could be on some upstream name server, so that when your system asks upstream "What's the address for server?" the answer it gets back is "silly, you mean server.example.com, and btw it's 1.2.3.4".

The two things that control this lookup are a setting called "ndots"; if the hostname has "ndots" dots, it will not have this helpful extra lookup applied. Usually ndots is set to 1 - so that server would get extra help, but server.local wouldn't. In your case it sounds like ndots is set to at least 2 - it looks like www.blah.com is still having extra lookups done.

The other feature is the search list - a list of domains that get appended to the hostname to try to find a match. In the usual case, this would be "example.com". In your case, it sounds as though "com" has ended up in the list - I'm guessing so that people can enter "yahoo" and have "yahoo.com" returned.

Again, this is probably being set by your DHCP server when it hands out a lease. If it was configured on your local machine it would probably be listed in /etc/resolv.conf.

share|improve this answer
add comment

Adding to James Polley's answer, you can usually override the search behavior by explicitly specifying that name resolution should begin at the DNS root zone. That is done by appending one . to the fully qualified host name.

So, instead of abc.server.example.com, you'd use abc.server.example.com.. The extra . instructs the resolver to try only this name and not use any configured search domains.

share|improve this answer
    
very good point! (no pun intended ;) –  James Polley Aug 13 '13 at 12:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.