Currently, I simply have
www 10800 IN A xx.xxx.xxx.xxx
and with this, www.foo.com works, but not foo.com.
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.
Generally you should make your www
address a CNAME for your real server name in dns:
WWW IN CNAME server
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.
I typically do the following:
foo.com. A [IP]
and then www CNAME foo.com.
(so that you don't repeat the IP twice)