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.

We have two external servers, Dev and Prod. We are a software house and in the code we have a subdomain metrics.company.com that points to Prod.

Development is continuous and our internal and external developers and testers will need to switch from Dev to Prod and back again. It is not an option to have a different sub domain in the code during development and change this for production.

The way we wish to switch between Dev and Prod is to use DNS. We need a public DNS server that behaves normally apart from routing metrics.company.com to Dev. The users will be able to swap their DNS back and forward to hit the different servers.

What is the easiest way to do this? Is there a company that hosts this service or am I going to have to rent a server and set it up myself?

Any help would be much appreciated.

share|improve this question
add comment

6 Answers 6

up vote 2 down vote accepted

We have a little more complicated setup, with a DEV, TEST, BETA, and PROD environment. I claim some extra crafty points for coming up with our solution, which allows the developers to initially build their code on their workstations, deploy up, and have it work without changing the code.

We do this by running several different internal DNS zones, specifically dev.zfx, test.zfx, beta.zfx, and then multiple PROD zones, one for each datacenter. Then, depending on the environment that their code is currently residing, the DNS search list is configured to reference that zone first. So, for example, they'll write their code to reference http://blahfoo/page?paramaters=something. On a DEV machine (or on their workstations), that will resolve to http://blahfoo.dev.zfx/page?parameters=something.

There are a couple of caveats:

  1. never, ever, under any circumstances allow a name to exist in one of these zones that exists in one of your static, internal zones. These zones should only include these developmental level type entries.
  2. you must work with your server admins to make sure the search list is configured as part of the build process. you will not enjoy life when they release some chunk of code into their development environment that goes totally wonky and kills prod because the system wasn't setup correctly.

At first glance, it's kinda kludgy looking, but it's worked really well for the past five years. If you have any other questions, just lmk.

share|improve this answer
    
Hi Greeblesnort. Do you have multiple DNS servers to achieve this? Do you allow external access to it? –  Relentim Aug 10 '10 at 9:27
    
I do run multiple DNS servers, actually multiple clustered DNS servers behind a hardware load balancer, and a hidden master. But, this would work just as well, if with less reliable uptime, with a single server. I would be more than happy to either post the files here or bundle them up and email if it would be useful. –  Greeblesnort Aug 10 '10 at 22:34
    
Upvote for username hilarity –  Tom O'Connor Jun 26 '12 at 14:51
    
What happens if the first DNS server in the search list is down? In your setup where you have the same level of redundancy for all DNS zones you are fine because 1) DNS is highly available and 2) no DNS zone is more available than others... so if dev is down it won't try to resolve in prod, because both DNS zones are down. But in a situation where the DNS isn't available "all or nothing" then you might have some problems, correct? –  Jeremy Jun 26 '12 at 14:58
add comment

Why not change your hosts file? Make sure your browser understands the change, I need to restart firefox for this (which is qiute logic because then the resolver in FF (or IE) is restarted).

share|improve this answer
    
Sorry, I should have specified. We are not using a PC and have a UI that gives easy access to the DNS settings. –  Relentim Aug 2 '10 at 12:52
add comment

It is not an option to have a different sub domain in the code

Why isn't it an option? I go through this kind of thing constantly while developing and solve the "problem" with a single #define (in C, or equivalent in whatever language is being used), which sets the development environment and is simply commented out for the production version. Stuffing around with DNS for this kind of thing is not only introducing an undesirable, error prone level of complexity, it should be unnecessary.

However, if you really want to pursue this weird idea why not just set up an additional DNS server, with the zone information you want for he dev version and tell your OS to use whichever DNS server is required at any particular time.

share|improve this answer
    
External users are testing compiled code, they need to switch between Prod and Dev. I would love to set up an addition DNS server if this is the easiest solution. Is there a company that hosts this service or am I going to have to rent a server and set it up myself? –  Relentim Aug 2 '10 at 13:27
    
@Relentim, why not install a DNS server on one of your existing servers, such as one of those the testers are accessing? –  John Gardeniers Aug 2 '10 at 21:42
add comment

You will probably run into trouble doing this with a DNS server. All DNS records have a TTL (time-to-live) attached, and clients (and intermediate DNS servers) will cache name records for that time, so they don't have to query the DNS server all the time. During that time the old records will be re-used, unless you a) force the client to throw away its cache and b) make sure you query to authoritative server for that domain directly (as otherwise your default DNS server will serve a cached record and you have no control over that).

A much easier situation is probably to add specific records for these domains/subdomains to your local hosts file (under Windows this is usually in C:\Windows\system32\drivers\etc\, under linux it is in /etc/). Users can then simply (un)comment the lines they need to switch from one server to the other.

Having said this, it would seem a rather strange thing that the sub domain could not be implemented as a run-time option.

share|improve this answer
    
Sorry, I should have specified. We are not using a PC and have a UI that gives easy access to the DNS settings. –  Relentim Aug 2 '10 at 12:53
add comment

I would change DNS servers, not code or DNS records.

Depending on how you've got things setup, you can either change the resolv.conf on the hosts, change the DHCP lease information, or change the forwarder for the DNS server you're using.

Set up two DNS servers to be authoritative for the records you're looking up; one DNS server that has the dev IPs and another DNS server that's got the prod IPs.

Just keep the TTLs short for both servers.

share|improve this answer
add comment

If you can have your DNS offsite, you can use CloudFlare for DNS. You can defined very short TTL and if you route the site through their CDN, DNS changes are instant, because it's basically just a configuration to their proxy.

/ Michael

share|improve this answer
    
This isn't a very good solution to separate dev and prod systems. Also DNS caching adds a lot of issues too. –  Jacob Jun 26 '12 at 15:09
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.