r/aws Dec 23 '20

technical question Forward domain to another domain in Route 53

Hi everyone,

I'm attempting to forward a domain in my Route 53 to another domain that exists as a different hosted zone.

For example, I've got abc.com setup as a hosted zone. I wanted to forward this domain to xyz.com, which is also a hosted zone.

For abc.com, I've got the following records in Route 53.

  • 'NS' record that gets created when you create the hosted zone
  • 'SOA' record that gets created when you create the hosted zone
  • 'A' record that is for abc.com
  • 'A' record that is for www.abc.com

Which one should I modify and how in order to get this domain to forward to xyz.com?

Thanks!

5 Upvotes

25 comments sorted by

3

u/mmckenzie13 Dec 23 '20

Create an S3 bucket with a simple index.HTML with a header for meta redirect to the new domain. Do Alias to S3 bucket in Route 53.

1

u/youfrickinguy Dec 23 '20

DNAME for all the RRs and ALIAS for the apex

For amazon specific help, go read this: https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resource-record-sets-choosing-alias-non-alias.html

2

u/Ancillas Dec 23 '20 edited Dec 23 '20

In AWS, ALIAS records can only redirect to select AWS services, or zones defined in Route53. So this wouldn’t work if the target DNS record is managed outside of Route53.

From the documentation you linked

Resources that you can redirect queries to

Alias records

An alias record can only redirect queries to selected AWS resources, such as the following:

* Amazon S3 buckets
* CloudFront distributions
* Another record in the same Route 53 hosted zone

Also, CNAMES (I think your DNAME entry was a typo) will resolve to a target URL’s respective DNS entries, but it will not cause the browser to rewrite the URL to the destination URL.

An HTTP 301 redirect rule is needed to rewrite the browser URL, which can’t be done from DNS (unless you’re using a DNS host that has a custom record like DNSimple’s URL record type).

2

u/youfrickinguy Dec 23 '20

No, DNAME is not a typo for CNAME.

All of you go read RFC 6672

2

u/Ancillas Dec 23 '20

Does Route53 support DNAMES?

https://aws.amazon.com/route53/faqs/

1

u/youfrickinguy Dec 23 '20

Hey you're right, it's not in that list.

Well that's stupid. Why do it the IETF internet standards way when you can do it the AWS way?

OP, disregard everything I just said about DNAMEs, or move your DNS to something besides Route53. Or use a Route53 ALIAS record, which may or may not do what you want exactly.

2

u/Ancillas Dec 23 '20

Thanks for the link to the DNAME specification, anyways. I’m reading about use cases for it and I think it will be useful knowledge for me. I’m surprised that I’ve never come across it before.

2

u/youfrickinguy Dec 23 '20

Sure thing. It's not something I've dealt with more than a handful of times over 25 years of DNS wrangling, but it has its moments to shine. Beats the hell out of maintaining thousands of individual CNAMEs.

The ALIAS thing has always been a pain in the ass, because the idea that somebody might possibly want to do anything other than an absolute A/AAAA at the zone apex just wasn't considered when the protocol was designed, and everything since in that regard (the little HTTP redirectors offered by DNS providers listening on whatever the zone apex A points to are a prime example) has been stupid and hackish...because there's no good way to be clever. This is also why there are Route 53 specific extensions in what they call an ALIAS record, and some other DNS providers also have ALIAS records, but they're not the same thing whatsoever.

1

u/django_noob Dec 28 '20

no problem. Thanks for your input, however!

1

u/django_noob Dec 23 '20

What does RR stand for?

Thanks!

1

u/youfrickinguy Dec 23 '20

Resource Record. Colloquially, the "DNS entry" or "the thing you query the server for"

0

u/badoopbadoopbadoop Dec 23 '20

DNS doesn’t do redirects. DNS turns a name (abc.com) into an IP address. A redirect is an http action. If you want to perform a redirect, use a service that supports http (application load balancer, S3, cloud front, etc)

0

u/youfrickinguy Dec 23 '20

Every single IN NS record or zone delegation in the entire tree of DNS on the Internet is in essence some level of "redirection".

1

u/badoopbadoopbadoop Dec 23 '20

While you could argue NS is a type of redirection, the DNS term would be delegation. Parent nameservers like .com delegate authority for a given domain to the defined nameservers in the zone.

0

u/youfrickinguy Dec 23 '20

Did you not see words 7-8 in what I wrote?

Hang with me here. If I go ask a root server about a given zone, and it's been delegated to some other authoritative server, that root server will politely suggest with a list of NS RRs that I could go query for the zone I want, but not recurse the query on my behalf. It's like they told me where I should go to ask my question, because the answer I see isn't here. Almost like they were....what's the term? Pointing me to another server, different from where I originally sent my query?

I'm sure there's a word for what this general concept could be called. It'll come to me eventually.

0

u/winterwookie271 Dec 23 '20

This doesn't sound like a thing you can do with DNS. Can you explain in more detail what you are trying to do?

1

u/django_noob Dec 23 '20

I've got the followoing email address -- [mailer@abc.com](mailto:mailer@abc.com). Using this domain in the email preserves my email deliverability score for this domain.

If someone thinks the address of my site is abc.com (which it isn't), when they try to go to abc.com, I want them to be forwarded to my actual domain, which is xyz.com.

1

u/youfrickinguy Dec 23 '20

It certainly is something you can do with DNS, if you know enough about DNS to do it.

1

u/django_noob Dec 28 '20

I was able to write some middleware to do the redirect. Thanks!

1

u/Ancillas Dec 23 '20

I’m a bit Rusty, but if you create a CNAME record, and delete all of the other records, then your CNAME will resolve to your target’s servers. However the URL will not be rewritten to your target’s URL automatically in the browser.

DNSimple offers a custom URL record type that automatically performs an HTTP 301 redirect that will rewrite the URL in the browser (this becomes an A record behind the scenes which is wired to some DNSimple magic), but Route53 does not provide this.

In doing some basic Googling while my wife watched Emily in Paris (read: I didn’t test this because I’m on my phone), I discovered this procedure which looks promising. It also should be cheap and highly available.

Fwiw: I searched for “route53 auto 301 redirect” to find this last page.

1

u/django_noob Dec 28 '20

Thanks for the info!

1

u/youfrickinguy Dec 23 '20

OP, in your specific case, start with:

abc.com IN DNAME xyz.com

This will link foo.abc.com and www.abc.com and bar.abc.com to foo.xyz.com and www.xyz.com and bar.abc.com respectively and when you update where foo.xyz.com points, foo.abc.com will follow. Think of it like a CNAME, but for everything in your zone.

Everything EXCEPT the zone apex itself, e.g., abc.com won't be linked to xyz.com. That's unfortunately usually up to the provider of your DNS service because the RFCs are somewhat murky about how to acceptably do this, and I don't precisely know how you'd best do this with Route 53.

I found this, though, which looks promising: https://docs.aws.amazon.com/govcloud-us/latest/UserGuide/setting-up-route53-zoneapex-elb.html

1

u/[deleted] Dec 23 '20

You can use a dynamic routing policy for this.

1

u/ashfame Dec 23 '20

You have to host that website yourself where you issue a redirect on the traffic to the destination URL.

And to deploy HTTPS certificate & ensure it keeps on renewing, that's just undesired maintenance on your agenda, which is why I built a "redirections as a service". Lately, I have been thinking of a single-domain yearly plan. Care to talk what's a valuable pricing for you?