Domain A records: Why is my wildcard working?

A couple of weeks ago, I set up a new live site for a client on a fresh domain. This is a routine task I do on a regular basis, and is one of those things you do on autopilot.

As usual, I pushed the site to the live server, tested the www. and non-www. using my host file, and checked everything was working correctly. I changed the IPs in the domain www and wildcard * A records to point to the server the site was hosted on, expecting them to resolve within a few hours. When I checked the www. version shortly after, everything was working as expected. When I checked the non-www. version, the domain was not resolving. I doubled checked the IP I specified for the * record, but everything looked fine. I put this down to propagation and forgot about it.

When I went back to the site a couple of days later, I typed in the domain without www. and the domain was still not resolving. At this point, I realised something wasn’t right. The domain was brand new. There were only two records on the domain; the www A record, with the IP of the server, and the wildcard * A record, again with the  same IP address. The IP was correct, and the nameservers were working – this was proved by the www record resolving as expected.  What was wrong?

Being more of a front-end person, I’ve never really delved much into the technology behind domains or what the records mean. All I knew was that you need a www A record, and a * A record. I only found out recently there’s such a thing as a TTL, or ‘time to live’, which I believe controls hows long the DNS is cached for (please tell me if this is wrong!).

After much Googling and head-scratching, I couldn’t find an answer as to why this wasn’t working. I decided to double check another domain that was definitely resolving to see if there was anything I was missing. There I saw an additional A record, with an @ in place of the *, pointing at the same IP address. I figured this must be the issue, and added it to my broken domain. The problem resolved almost straight away.

But why? What does the @ symbol mean?

[Pro tip: Google does not search for the term “@”. Searching for “DNS @ A record” or words to this effect will only return you lots of results about DNS records in general.]

After learning that the hard way, I searched for “at symbol” instead, and found this ServerFault article that says the @ record refers to the root of the domain. It also says it is a shortcut for the origin. Then it all gets a bit technical and I don’t understand it anymore.

In my research, I’m yet to find an answer to why the @ record caused my wildcard to work. I know it isn’t required for domain to work as a whole, as the www. worked. My theory is that * is an alias for the origin, but if that is the case, then why does it need an IP address? Why does a domain require a * for the non-www. to work?

So, to anyone who may stumble upon this article while trying to find an answer to the same issue, hopefully this will help. Sorry I can’t provide a reason why. To anyone who knows the answer, please share in the comments!

Leave a Reply

Your email address will not be published. Required fields are marked *