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.
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 tohttp://blahfoo.dev.zfx/page?parameters=something
.There are a couple of caveats:
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.
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).
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.
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.
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.
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