I have Ubuntu 11.10 running on VirtualBox and I've set up a virtual named server.
I'm able to access this site from Windows 7, but I'm not able to access the site from Ubuntu.
My HOSTS file is located in /etc/
folder and looks like this:
127.0.0.1 localhost
127.0.1.1 ubuntu-VirtualBox
192.168.0.97 mysite.com
But whenever I try to access mysite.com from the server, I get redirected to a site saying that this domain is for sale.
What could be the cause of the hosts file not working?
Update
This is my /etc/nsswitch.conf
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.
passwd: compat
group: compat
shadow: compat
#hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
hosts: files dns
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: nis
Best Answer
First, check that nsswitch.conf is correct:
Make sure that it says "files dns", otherwise it will not look in your hosts file before asking DNS.
If it is correct in nsswitch I have before seen that an invisible character somehow got into my hosts file, causing it to look perfectly normal but the invisible character made it not work.
So try deleting the line and then create it again - by hand, don't paste.
Next thing you can try is to test what it looks it up for by pinging:
If you see the correct IP address there, it does resolve correctly and your browser is the one causing trouble. Do not use host, dig or nslookup, they ignore /etc/hosts! Use ping to have the IP address resolved as most applications would see it.