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 have a dev environment and a production environment.

The production environment lives at example.com on one server (77.123.45.67).

On a totally separate server (different host, everything), I have dev.example.com (77.765.43.21).

I'm trying to create a subdomain on the development server: dev2.dev.example.com. I tried to add an entry to the dev DNS zone file:

dev2.dev.example.com CNAME dev.example.com

But, it is still not working. Do I have to do anything else, or is what I've done wrong?

share|improve this question

migrated from stackoverflow.com Jul 14 '11 at 22:48

This question came from our site for professional and enthusiast programmers.

    
Show your existing DNS configuration. –  Ignacio Vazquez-Abrams Jul 14 '11 at 22:51
    

3 Answers 3

your whole approach seems kind of odd but if you insist on creating a sub-domain named dev2.dev.example.com go ahead and edit the DNS with an A record for it.

dev2.dev 77.765.43.21

Next you need to edit the Apache.conf file and add dev2.dev.example.com as either a "ServerName" or "ServerAlias".

share|improve this answer

You don't add an entry to the dev zone. In fact you shouldn't even have a dev zone. Everything should be done in example zone.

share|improve this answer

There are two approaches you can take here:

  1. keep everything in the example.com zone file, or
  2. delegate dev.example.com to a separate name server.

Option 1 is simple: you keep everything in the same file, and there's no need to set up a second server. The disadvantage is that your production and development DNS settings are in the same file, which may not be what you want -- especially if you're as prone to typo'ing config files as I am!

If you go this route, your zone file should look something like this: # example.com # SOA, NS, etc.

@        IN A       77.123.45.67
dev      IN A       77.765.43.21
dev2.dev IN CNAME   dev

If you don't terminate a label with a dot character, the zone name is automatically appended.

Option 2 is a bit more complicated: you need to set up a second DNS server to host the dev.example.com domain. If you're trying to replicate a production environment, this could be what you want. It would look like this, assuming that your second nameserver lives on 1.2.3.4:

# example.com
# SOA, NS, etc. 

@        IN A       77.123.45.67
dev      IN NS      1.2.3.4

and for the other zone:

# dev.example.com
# SOA, NS, etc.
@        IN A       77.765.43.21
dev2     IN A       77.765.43.21

This delegates authority over the entire dev.example.com domain to nameserver 1.2.3.4, in the same manner that .com delegates example.com to your current nameserver.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.