Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

When I go to me.com in chrome it tells me that domain can't be found. When I go to me.com with ssh, it connects to that server. When I try to ping me.com it pings localhost. I want me.com to resolve to localhost in all 3 situations. How can I accomplish this?

Here are my relevant files:

/etc/hosts

127.0.0.1       localhost.localdomain   localhost me.com
::1     laptop  localhost6.localdomain6 localhost6
127.0.1.1       laptop

/etc/resolv.conf:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.0.1
nameserver 127.0.0.1

/etc/resolvconf/resolv.conf.d/head

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.0.1
share|improve this question
add comment

4 Answers 4

up vote 2 down vote accepted

Unless you're actually running a DNS server such as BIND or dnsmasq on the localhost, you don't want your nameserver stanzas to point to the localhost. If you are running a DNS server or caching service, you'll need to refer to its documentation for details on how to configure it so me.com resolves to the localhost. Once the DNS service is configured, you can test resolution of specific domain names with nslookup.

Chrome may be automatically appending 'www' to the front of your URL, you can make sure this is behavior is disabled by specifying the protocol portion of the URL explicitly, like so: "http://me.com"

We'd need to see your /etc/nsswitch.conf file to help with the ssh connection. ssh -v may also produce some useful output.

Finally, if you want to connect to the localhost, it may be much less of a headache to simply specify 'localhost' as your hostname, instead of 'me.com' :)

share|improve this answer
add comment

Try to clear your DNS cache and then remove all history in Chrome (should be somewhere easy-accessible under settings, this is good to do since I'm not entirely sure if Chrome is DNS-caching)

See http://www.ubuntugeek.com/howto-clearflush-dns-cache-in-ubuntu.html for clearing cache (I'm not entirely sure that is needed or is possible, but try it ;D)

Also try to dig me.com since that could give some helpful information. You could also try by starting up Firefox and see if me.com goes to localhost.

Also - I don't think you have to (or should, unless you've got a DNS-server set up to replicate other DNS-servers) point your nameservers to 127.0.0.1 since /etc/hosts has higher priority than that of the nameservers per default (see the hosts-line in /etc/nsswitch.conf for your settings)

share|improve this answer
add comment

To address the original question.

First, why do you get three different results from Chrome, ssh and ping?

It looks to me as if these three programs use different resolver logic, perhaps using different libraries or different flanking code. It is known that ping uses the glibc resolver which obeys /etc/nsswitch.conf and /etc/resolv.conf. Hence ping first tries /etc/hosts and then DNS. So ping me.com pings 127.0.0.1. Perhaps Chrome skips /etc/hosts and can't find www.me.com in DNS. As for ssh, what host does it end up connecting to?

share|improve this answer
add comment

You know if in your network has some proxy server? If has maybe is a restriction in this server. If you has control OK, but if other SysAdmin manage, you need talk with him.

share|improve this answer
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.