1

Under my current understanding, I am able to use CNAME records to redirect users to another domain. For example, I own 'mydomain.com'. When a user goes to 'keep.mydomain.com', they should be redirected to 'keep.google.com'.

I currently have the following record in my DNS record set: Name: keep.mydomain.com Type: CNAME Value: https://keep.google.com/ TTL: 300ms

I don't have any other records under that subdomain, however I do have MX, A, NS, SOA, TXT, and other CNAME records under other domain/subdomains, which work properly. However, when I go to 'keep.mydomain.com', I get the error:

This site can’t be reached
keep.mydomain.ca’s server DNS address could not be found.
ERR_NAME_NOT_RESOLVED

Am I misunderstanding the use of CNAME, or is there something I have configured that is conflicting?

  • 1
    real names are helpful. – Jacob Evans Oct 25 '16 at 12:17
  • Sorry about that. Considering my name is visible, no harm in using my real domain. richardyang.ca, and keep.richardyang.ca. – Richard Yang Oct 25 '16 at 12:27
  • Use a DNAME record to redirect an entire tree elsewhere: serverfault.com/questions/722465/… – thrig Oct 25 '16 at 13:52
7

CNAMES are not redirections, they are aliases. CNAME also includes all other resource records such as A,MX,TXT.

so if you query for an A record, the cname will send you to the A record of it's alias.

Many registrars include additional options such as redirect services, godaddy and Google for example.

also, be careful entering values for CNAMES, some systems assume terminating periods, others do not.

assuming domain example.com

test IN CNAME example.org

results in test resolves to the IP of host example.org.example.com which does not exist.

test IN CNAME example.org.

results in test resolves to the IP of host example.org which does exist.

CNAME values can only be HOSTS, not a URL.

dig A keep.richardyang.ca @8.8.8.8
keep.richardyang.ca.    299     IN      CNAME   https://keep.google.com/.

Change it to

keep.richardyang.ca.    299     IN      CNAME   keep.google.com.

Maybe check out https://stackoverflow.com/questions/10115799/set-up-dns-based-url-forwarding-in-amazon-route53

Example on how to use Synthetic records with Google.com Domains.

Keep Record

;; ANSWER SECTION:
keep.jacobdevans.com.   3600    IN      CNAME   ghs.googlehosted.com.
ghs.googlehosted.com.   163     IN      A       173.194.207.121

This sends my request to google's servers, google then sends a 302 code to the new url, I've chosen 302, you would want 301 if you want SEO to know this is a permanent change, I may want to switch my destinations at a later time as I use this for my signature links to ensure my contact info stays current.

OR, since you already have a website, point the domain there and redirect the site.

Script:

<script type="text/javascript">
if (window.location.href== "http://keep.richardyang.ca") {
   window.location.href = 'http://keep.google.com'; 
}
</script>

DNS:

keep.richardyang.ca.    299     IN      CNAME   richardyang.ca.
  • I think the latter part of my answer is your issue – Jacob Evans Oct 25 '16 at 12:23
  • I was not aware of the terminating periods, thank you for bringing that up. I've changed my cname setting to what you listed, however I still get the not found message. – Richard Yang Oct 25 '16 at 12:39
  • see updated answer, your cname destination must be a host record not a http link – Jacob Evans Oct 25 '16 at 12:40
  • Also, I understand the method used in that link you provided. Whats the difference between the method you listed and the method they used? Yours seemed way more simple. – Richard Yang Oct 25 '16 at 12:40
  • Yes I made that change right after you recommended it. See below: keep.richardyang.ca. 299 IN CNAME keep.google.com. keep.google.com. 299 IN A 172.217.6.14 – Richard Yang Oct 25 '16 at 12:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.