Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm testing a new server and have been playing with /etc/hosts.

I have been able to get it working on just domain.com, but if I try www.domain.com it points to where the actual domain is currently delegated, not the testing server.

ie

xxx.xx.xx.xx domain.com

If I load domain.com, I get the ip address I enter. With this though I enter www.domain.com I get where the domain is currently hosted.

if I try:

xxx.xx.xx.xx www.domain.com

I still end up with where the domain is currently hosted and not the test server.

What am I missing here?

share|improve this question
    
What is your OS? –  Khaled Jul 14 '12 at 9:16
    
I am on osx 10.7 –  willdanceforfun Jul 14 '12 at 9:16

2 Answers 2

xxx.xx.xx.xx www.domain.com should have worked, assuming that you have configured your resolver to first use the hosts file. (Trying DNS next and the host file as a backup is also allowed and might be the default on some distributions).

I checked FreeBSD and Fedora and both have default lines like this:

>cat /etc/host.conf
# Auto-generated from nsswitch.conf
hosts
dns

Fedora

order host, bind

Edit: I just saw your comment that you use OS X. That makes this post relevant

share|improve this answer

Your setup of /etc/hosts file is good.

Look in the file /etc/nsswitch.conf, and check if the first parameter of line beginning with "host: " is "files". If not it's a priority probleme between /etc/hosts file and DNS recursion (dns parameter).

share|improve this answer

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.