Diagnosing subdomain “server not found”: Where to start

domain-name-systemsubdomainvirtualhost

I'm having a strange problem. I'll be quick about the setup:

DNS

Following are A-records pointing to the same IP:

  • www.domain.com
  • domain.com
  • login.domain.com
  • dev.domain.com

I have tried using CNAME for the sub-domains, but that did not change anything.

Apache 2 setup

I have two virtual-hosts:

<VirtualHost *:80>
  ServerName domain.com
  ServerAlias www.domain.com
  DocumentRoot /var/www/a
  [...log setup]
</VirtualHost>

and

<VirtualHost *:80>
  ServerName dev.domain.com
  DocumentRoot /var/www/b
  [...log setup]
</VirtualHost>

Take notice that there is no host set up for login.domain.com.

Problem

Now to the problem. When I enter dev.domain.com it says server not found instantly. Have tried clearing cache and all that, and on several computers. www.domain.com and domain.com serve from the right directory. login.domain.com redirects to domain.com for some reason.

The config above is the only one under sites-enabled, but it also loads a config from phpmyadmin.

I guess what I'm asking is, how do I begin diagnosing the problem? How can I rule a DNS problem out? I have tried adding dev.domain.com as a serveralias to the current config – nothing changes. And I have no idea why login.domain.com redirects – there's not wildcard anywhere as far as I can see.

Where do I start?

Best Answer

When someone queries a non-existent domain name, the reply that it does not exists (NXDOMAIN), cached in the intermediate DNS servers.

Possibly for dev.domain.com, negative reply was cached somewhere.

To test, try

1. nslookup dev.domain.com (or dig dev.domain.com)
2. nslookup dev.domain.com ns1.domain.com (or dig @ns1.domain.com dev.domain.com)

If that is the case, you'll get negative answer in 1. and your IP in 2.

There's no solution other to wait the time specified in the last field of your SOA record (nslookup -type=SOA domain.com or dig domain.com SOA). To prevent it in the future, put there some lower value.

As for login.domain.com - it falls back to the first VirtualHost defined. It is normal behavior.

(I'd agree that if you would post the real domain name, it would make our life better)

Related Topic