0

I have a synthetic record set up pointing example.com to www.example.com and this works. I also have a CNAME pointing a.example.com to a website that hosts my images, and this works.

I want www.example.com to redirect to a.example.com, while I build a website to deploy on www.example.com.

I used CNAME from www.example.com to a.example.com and this did not work. Everything I read says that CNAME is the correct tool for this, so what is going on?

update: To clarify, I am setting these records on Namecheap (but this should apply to all other Domain managers like Google Domains), not Windows Server or Apache or NGINX.

Ryan
  • 109
  • 1
  • 1
    Have you used an DNS resolution tools to see what is going on and what is being returned? dig can be very informative when troubleshooting DNS resolution issues. CNAME is typically the way to go for these types of things. Also obfuscating the domain in this circumstance actually hurts troubleshooting the issue. What DNS server are you using? What are your forward zone configs? – Dion Pezzimenti Apr 05 '19 at 05:28
  • So proper config would be something as such, A Record www.domain.com points to IP. CNAME a.domain.com points to www.domain.com – Dion Pezzimenti Apr 05 '19 at 05:31
  • 1
    In general saying "it does not work" is not very helpful as it lacks details about what you tried exactly, what error messages or undesired behavior you got and what results you expected. Also (badly) obfuscating DNS data is kind of silly as it both hinders help (no one can redo your troubleshooting steps to double check) and is pointless since the DNS is public anyway. – Patrick Mevzek Apr 07 '19 at 03:07
  • @ryan when asking others for help, “this did not work” isn’t useful. What did it do instead of working? Did it give an error? Post that. Did it show certain behaviours when troubleshooting? describe them. Did it catch fire? Safely put the fire out first, then say that’s what happened. – Rob Moir Apr 07 '19 at 05:13
  • Even just re-reading my question I have developed a headache. Can we all agree that these network engineer people are clueless at naming things and make what should be simple technology entirely unusable as a result of poor documentation, lack of sensible up-to-date names, and no standards of definition? – Ryan Jul 24 '19 at 08:21

3 Answers3

2

So you can check my comments for a little bit of insight on how to troubleshoot your issue. But I suppose a definitive answer to how DNS records work and how to achieve the redirection you are looking for would be more appropriate. RFCs probably are the proper way to site sources, but I like to explain with my own examples. So I will provide screen shots from my Windows 2016 Active Directory server that runs DNS locally on the server as well. Now if you use something like bind on Linux/Windows then the concepts should hold true, but obviously a different approach to configuration.

So your DNS server is going to have a Forward Lookup zone configured for your domain. Mine for this instance is digiecho.xyz as you can see in the screenshot below:

DNS Forward Zone Example

In the lookup zone you can see that I have an assortment of A records that point to IP addresses. These are the most common types of records created in my experience. So you should have one A record where your www.domain.com points to some IP. For my example I'm going to use my A record for VC01.

A CNAME or Canonical Name allows you to alias one name to another. I'm going to create a CNAME record vcenter.digiecho.xyz and point it to my A record VC01 (see screen shot below for record creation example, and info on CNAMEs):

https://support.dnsimple.com/articles/cname-record/

CNAME Record Creation

You then can use DNS tools like dig or nslookup to troubleshoot what is going on. Since this is all on my internal network I just used nslookup from another server on my virtual host to show some relevant outputs to help you in your troubleshooting:

nslookup Example

As you can see it not only tells me the true canonical domain the alias points to. However it should report back the server that is reporting back the record. So if you have like a master-slave configuration in your DNS environment you will want to make sure the zone transfers have occurred from the master to all the slaves to ensure that they all have the correct. If you are using Linux just man dig for the command parameters. But really those basic DNS checks and troubleshooting should be sufficient to solve a CNAME issue.

Dion Pezzimenti
  • 177
  • 1
  • 1
  • 10
2
name                optional_TTL   CLASS   RR      canonical name
www.example.net.    3600           IN      CNAME   a.example.com. 

Simplified a DNS CNAME record does nothing more than pointing a DNS record to the canonical name of another host by using that hosts DNS name rather than by creating an A entering that hosts IP-address.

After that DNS change you will usually need to reconfigure a.example.com and make the services running there aware of the fact they can be accessed by an additional hostname www.example.net. rather than only via a.example.com.

If you don't do that, things may work out, for instance a web server running plain http and only one website will display that website regardless of the hostname used to access the web server, but for a web server running multiple virtual hosts on HTTPS you will need to both request a new TLS certificate with the www.example.net. domain name AND you need to either create a new virtual host entry, or add www.example.net. to a specific existing virtual host.

HBruijn
  • 72,524
  • 21
  • 127
  • 192
2

A CNAME record should not point to another CNAME record.

Find out where your a.example.com CNAME actually points to, and then set your www.example.com CNAME to also point directly to that.

Patrick Mevzek
  • 9,273
  • 7
  • 29
  • 42
telcoM
  • 4,153
  • 12
  • 23
  • 1
    A `CNAME` record can absolutely point to another `CNAME` there is nothing wrong about that, you just need to be careful as it may have consequences on resolution time. It fact it happens often nowadays with the use of CDNs, just try to resolve `www.microsoft.com` you will see a chain of 3 CNAME records! – Patrick Mevzek Apr 07 '19 at 03:11