How to A-record DNS redirections work?
February 19, 2011 8:21 AM   Subscribe

Some DNS registrars offer a service where they redirect anybody landing at to What do they do to the DNS record to make this happen, particularly if the www is a CNAME record (that is, not an IP address)?
posted by deeper red to Computers & Internet (12 answers total) 1 user marked this as a favorite
Can you give an example of a service that does this through DNS?
I don't think it's the DNS registrars doing this, since the DNS protocol has no idea what port you are trying to connect to or what protocol you are trying to use.

More likely, it's the web hosting service doing this, which doesn't even require a redirect; it's just another Server Alias (or Virtual Host).
posted by jozxyqk at 8:27 AM on February 19, 2011

My DNS settings through Nearly Free Speech (my web host) do this. Article of interest.
posted by jmd82 at 8:34 AM on February 19, 2011

I believe they just give the root an A record which points to their web server, which is configured to do the redirect.
posted by makeitso at 8:38 AM on February 19, 2011

If you want the person's browser to actually show the url when they put in just, that is not possible just with DNS. A redirect is needed on the web server answering for So if a DNS provider is to have this server, they actually have a web server answering for and sending an HTTP 301 redirect to

On preview, what makeitso said.
posted by zsazsa at 8:38 AM on February 19, 2011

so for my domains I have an A record that points to the non www domain. I can then have a CNAME record for www which points to This takes care of the DNS records.

I don't "redirect" to I use a ServerAlias
posted by bitdamaged at 9:06 AM on February 19, 2011

Bitdamaged, it's the other way around that I'm interested in.
posted by deeper red at 9:35 AM on February 19, 2011

What do you mean the other way around?
posted by bitdamaged at 9:49 AM on February 19, 2011

A records create a mapping between an IP address and a name. That's all they do. There is nothing happening in DNS that's redirecting web browsers to the "www." version of a URL.

Here's how that happens (leaving out a few steps about authoritative nameservers and root nameservers and such):

1: You type "" into the browser's address bar and hit enter.
2: Your machine asks a nameserver to resolve ""
3: The nameserver determines from your domain registrar what the authoritative nameserver for is -- this won't necessarily be a nameserver controlled by your domain registrar, though it often is.
4: The nameserver you contacted contacts the authoritative nameserver for and asks to resolve "". The authoritative nameserver, which has either a CNAME or an A record for "" returns the result, which is passed along to your machine.
6: Your browser opens a connection to the HTTP server running at the IP returned by the DNS query and makes a request for
7: The HTTP server redirects the browser to
8: Steps 2 through 6 are repeated.
9: Your browser opens up a connection to the HTTP server running at the IP returned for "" and makes a request. The URL bar now says "".

The important thing here is that the redirection happens on the HTTP server, not the DNS server. What everyone else has been telling you is true. If your domain registrar is also your DNS and HTTP host, then they can sell you this as a package and hide the details from you. I have at least one domain that I have to do this manually for -- I registered it through Dotster, DNS is hosted by Dreamhost, and the HTTP server is on Linode. Neither Dotster nor Dreamhost can do anything to make redirect to I have to do that myself, on the HTTP server I run at Linode.
posted by hades at 9:55 AM on February 19, 2011 [2 favorites]

Forgot to mention: the HTTP server answering to "" and the HTTP server answering to "" may or may not be the same server. It doesn't really make a difference. The HTTP server could be something your DNS host provides for the express purpose of redirecting their customers' top-level domains to "www", or it could just be an extra line in the configuration of the HTTP server your web host for runs.

The type of record is a red herring. Both and could have A records or CNAME records and the behavior would be the same. The redirection doesn't take place in DNS.
posted by hades at 10:03 AM on February 19, 2011

deeper red: Are the registrars who are doing this also hosting the website in question?
posted by rhizome at 11:38 AM on February 19, 2011 [1 favorite]

Echoing what makeitso and others have said, I assume the registrar is running the webserver pointed to by, but the only thing that webserver does is issue a redirect to, which can be hosted anywhere. (I tried reading jmd82's link but it seems to be for logged-in users only.)
posted by hattifattener at 2:58 PM on February 19, 2011 [1 favorite]

If you want the url in the browser to change (that is, you typed 'A', resulting page reads 'B') then you must have something more than DNS in the mix, in particular you need a HTTP server that responds with a 30x code and 'Location' header. If the DNS provider is not hosting the site, then they must have the name resolve to a different IP address of a server under their control that sends the redirect. If they are hosting the site they can have both domains resolve to the same IP address and then do the redirect.
posted by Rhomboid at 4:52 PM on February 19, 2011

« Older Boston North End Apt Search   |   I want to buy a really boring car. Newer »
This thread is closed to new comments.