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

Currently, I simply have

www 10800 IN A xx.xxx.xxx.xxx

and with this, www.foo.com works, but not foo.com.

share|improve this question
Could we see the rest of the zone file? It's difficult to say how exactly to do this without seeing the structure of the zonefile. –  MadHatter Feb 13 '11 at 20:48

3 Answers 3

Your DNS servers sees www.foo and foo.com as 2 completely separate Domains. Due to this you also need to add an A record for just foo.com also like

Foo.com. IN A xxx.xx.x.x

Where xx.x.x.x is the same IP as www.

share|improve this answer
Hey! Thanks for the quick response. Is this as same as adding a CNAME? If not, what's the difference? –  randomguy Feb 13 '11 at 20:54
No, a cname would be for setting blah.example.com to forward to blah.othersite.net. You don't have An A record for foo.com only www.foo.com so thats why only 1 works. you need to add a A record for foo.com like foo.com IN A (IPhere). It should look like www.foo.com except there should be no www. on it. –  Jacob Feb 13 '11 at 21:01
Small clarification: You'll need a dot after foo.com, as "foo.com. IN A xxx.xx.x.x" Otherwise you are creating a record for "foo.com.foo.com." –  Cakemox Feb 13 '11 at 22:04
Forgot to add that thanks. –  Jacob Feb 13 '11 at 22:13

Generally you should make your www address a CNAME for your real server name in dns:


then when you do a dns lookup of example.com, server.example.com and www.example.com the result should be the same IP address in all cases.

Then (assuming you use apache) in the main section of your httpd.conf you should have:

ServerName server.example.com:80
UseCanonicalName off

so that requesting hosts can indicate the name they are trying to connect to and the server will always respond properly.

share|improve this answer
Hm Jacob you are right, my answer may be a bit outdated. Looking at the googles it seems like cnames are less efficient. –  Phil Hollenback Feb 13 '11 at 21:04
Jacob, please expand about why vhosts won't work. I took that config from a server that is running name-based vhosts. –  Phil Hollenback Feb 13 '11 at 22:13
Jacob, that doesn't make any sense whatsoever. The server hosting the websites sees an HTTP Host: header provided by the client. It doesn't care how the client found the IP address it's connecting to -- that's totally irrelevant information. –  jgoldschrafe Feb 13 '11 at 22:55
Sorry I typed the wrong thing, Vhosts will work but Cnames cause 2 lookups to be made to the server so thats why A records are better –  Jacob Feb 13 '11 at 23:00

I typically do the following:

foo.com. A [IP] and then www CNAME foo.com.

(so that you don't repeat the IP twice)

share|improve this answer
Cname causes 2 lookups at the server.not very efficant –  Jacob Feb 13 '11 at 22:57
I suppose so, in that case having two A records would work also. But it is a DNS server, using CNAMES I would assume is only marginally less efficient. –  farinspace Feb 14 '11 at 16:46

Your Answer


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.