Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a single server (single ip) running apache, bind and a mailserver. This serves a single domain ( and I would like to associate and with my website, with the mailserver (both incoming and outgoing) and with the DNS.

Everything works fine, but I don't like that pointing a browser at (or at takes me to my website (i.e. the same as As far as I understand, this cannot be fixed in the DNS, correct? I could create virtual hosts in apache for and either show a blank page or an error message? Which is preferable, and is there a common/recommended error message to show?

Are there any other places where those names overlap: e.g. affecting the mail system?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

The problem seems to be that your webserver is configured to listen on the (numerical) IP address. (Otherwise you would already get an error on arbitrary subdomains.) So stop it from listening on the IP address. A vhost just and only for and to serve the webpage should be your way to go.

Now, if browser-requesting the IP address results in the browsers' well known "cannot connect to server" error, it will be there on ns. and mail. too while not affecting regular mail or DNS service.

share|improve this answer
You could also probably set up appropriate .htaccess rules to control access that way - might be useful if there's going to be webmail, etc. running on a separate vhost entry so that goes to the webmail interface. – fencepost Jan 25 '13 at 21:21
@KarmaFusebox: I only have "Listen 80", so I guess it is not listening on the (numerical) IP address. I do get errors on arbitrary subdomains, just not on ns. and mail. On the other hand ns. and mail. point to the same ip address via my DNS settings, so would end up at the webserver, no? – user1583209 Jan 25 '13 at 22:30
Listening for anything on port 80 does not even respect different subdomain requests. Because, as you said, all your subdomains resolve to the same IP address, where you are listening generally. So you have to define vhosts here to distinguish the subdomains. I'm sorry that I can't give you any more hints about how to configure the webserver exactly, but generally I still suppose that this is outlining the problem. – Karma Fusebox Jan 26 '13 at 19:08
Thanks. I created a default vhost for ns. and mail. and made it create a 403 error by denying access. – user1583209 Jan 27 '13 at 22:41

this is called the_default_vhost in apache and it is actually well documented. If there is no hostname then it serves the_default_host that is the first one that your apache has on the list, in your case it happens to be and so on. I figured it out earlier myself by testing it around and creating a hostname (document root) for every single A record I had. It helped. Then a little later I found out that it was called the_default_host.

share|improve this answer

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.