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 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?

share|improve this question
    
You have hosts in zone, not subdomains!!! Shit, when i'll be happy to see again correct usage of terms by hostmasters?! –  Lazy Badger Nov 3 '11 at 4:24
add comment

2 Answers

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)

share|improve this answer
add comment

I guess what I'm asking is, how do I begin diagnosing the problem? How can I rule a DNS problem out?

  1. In case of multiply virthosts in Apache, fist virthost serves as fallback for all hosts-requests, which aren't found in visthosts lists, but reach server due to DNS configuration (or other methods), it's clearly OK for your non-existing virthost
  2. Never, never mask domain in case of domain-related issues - this way you guaranteed to compel all interested in the answer to guess, instead of testing and debugging.
  3. For me "dev.domain.com" is perfectly valid according to you quote, but I prefer to test it real life
  4. Wild guessing - dev.domain.com can somehow resolve to wrong IP, without http-server on it. How to test
    • nslookup dev.domain.com, verify IP-of-dev.domain.com
    • traceroute IP-of-dev.domain.com OR traceroute dev.domain.com
    • telnet dev.domain.com 80 and perform shortest http-session, if connected or use wget dev.domain.com/index.file for monitoring actons of http-client with site dev
share|improve this answer
add comment

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.