forward query to Public Hosted Zone if no match in Private Hosted Zone [duplicate] - amazon-web-services

I've read through all the AWS docs I can find and GoogleFoo has not resulted in anything.
My case here is we have one domain example.com and up to now we have used it only for Public records. There is one Hosted Zone set to Public. I want to now create a subdomain for private records to use inside of our VPC group for our application (e.g. to point at an ElastiCache instance).
I attempted to create private.example.com as a Private Hosted Zone pointing at our VPC and then created cache.private.example.com as a record under it but it will not resolve.
I am curious if I can configure a subdomain of our main domain somehow?
example.com - Public
** app.example.com
private.example.com - Private
** cache.private.example.com - VPC
OR
Can also create a Private Hosted Zone with the same top level domain example.com? I am nervous to try that because I do not want to affect the application.
example.com - Public
** app.example.com
example.com - Private
** cache.example.com - VPC

For Googlers trying to "subsetting" a public host zone, or to make a private host zone "fallback" or "extend" to public. Read on.
Firstly, R53 is authoritative, means you have to provide exact resolution, so the common way of using different BIND views will not work. Also when host zone names overlap, the private one prevails.
Secondly, R53 will determine which host zone to use based on "specificity". So when user asks for www.example.com, then a host zone named www.example.com prevails another named example.com. This is something we can make use of.
Follow the procedure:
Create a public host zone for your public DNS record (e.g. example.com), or just use any other public DNS record and skip this step
Create a private host zone for each of your sub domain name that has a local / private mirror / cache (e.g. www.example.com)
Create a default record set for each of the private host zones (leaving the "Name" field empty) and point them to local addresses
Attach the private host zones to your selected VPC's
In this way, if your machine asks for www.example.com, and a private host zone matches, it will return local addresses, otherwise, it will fallback to use the public host zone.
The pitfall for this solution is that R53 charges you by number of host zones, so you will have to pay a bit more. Also this is a bit hacky. Otherwise it eliminates the complexity of creating and managing your own BIND server, syncing public records, etc.

You will need to have a different domain for the private zone. Something like "example.internal" Then you could have "cache.example.internal"
cache.private.example.com will not resolve in your current setup, because it will be looking to example.com to resolve that dns. Also note it will only resolve inside the VPC.

Related

How can I get new hosts to inherit the private dns domain name to automatically form an FQDN in AWS?

Even though I have a private domain configured in route 53 resolver for a vpc, new instances still have default names like:
ip-10-1-1-170.ap-southeast-2.compute.internal
Is there a way to configure things such that new instances will automatically have an FQDN of the (sub)domain I have configured like:
ip-10-1-1-170.green.example.com
I am hoping to ensure that instances in seperate deployments (dev/green/blue) have FQDN's in seperate sub domains (and different VPCs), so that I can configure my onsite DNS to know where any host is based on that sub domain in its name, but automatically getting the host name on start is the first step on that journey.
I can successfully create route 53 records to achieve this too one by one, but it seems a bit nuts for a compute cluster, so I'm hoping that theres a way to achieve it just with the host name and the route53 resolver will still correctly handle DNS requests to those hosts somehow.
This domains are actually related to the domain controller that the instances are bound to.
When you create a VPC, the default DHCP configuration is amazons DNS (AmazonProvidedDNS) which in your case is providing the ap-southeast-2.compute.internal domain names.
If you added a custom DHCP option set of green.example.com then this would become part of that domain and show the DNS as you expect, although you are limited to one DHCP option set per VPC.
AWS have the following services which can act as domain controllers although you would need to ensure that your on premise can also forward requests to these name servers to resolve the domains:
Simple AD
Managed Microsoft AD
This is quite a bit of overhead in order to get the DNS names like those domains, it might be simpler by using 2 private hosted zones and automatings adding hosts to the domains along with an inbound endpoint instead from your on premise.

AWS Route 53 Domain not available

I want to connect a domain to my EC2 instance via the Route 53 service I set up 4 days ago. I have followed the documentation and the dig-interface shows the correct output, but when I try to access it in the browser, it sais the host can't be resolved. What have I configured wrong?
Domain: http://yet-another-blog.com
IP of the server: 52.59.214.55
Route 53 configuration:
digwebinterface.com result:
If you check the NS record of your domain it shows different nameservers than what is defined in your public zone.
It seems you created another public zone after you registered the domain or in a different AWS account.
Simply to solve this update the nameservers in the registrar to match the one in your public zone
Looks like yet-another-blog.com does not resolve because there’s no nameserver for that domain.
If you own this domain you’ll need to make sure it’s nameserver is set to target amazons name servers.
Making a public hosted zone isn’t enough.

redirecting a subdomain to google cloud

I have domain under which there are multiple subdomains pointing to different websites hosted on azure. I am starting to explore google cloud and want to host a subdomain on google cloud.
Below is how DNS record should look like
A - GO Daddy hosted main website IP address
CNAME - subdomain.example.com - subdomain.cloudapp.net
CNAME - subdomain2.exapmple.com - subdomain2.cloudapp.net
now I want to add a cname for another subdomain to be hosted on google cloud
CNAME - subdomain3.example.com ??.googleapi.com
I have public IP address from GCP, but how do I get subdomain for GCP to be used for CNAME record? As per answers to my another question GCP does not provide public CNAME for VM instances. So what should I provided in CNAME record. (I do not want to move the DNS to google, or to azure for that matter)
Based on your question and the reference to Google not providing names for VM instances, I am assuming that you are trying to create a DNS record for the external address of a VM instance.
If you have a static IP address, you should just configure your DNS provider to use an A record for that IP address, rather than a CNAME.
CNAME records just create aliases for the target names, where A records can point directly to the correct IP.
Note that if the IP on your instance is ephemeral rather than static, then you would need to keep updating the DNS record whenever you restart the instance (and get a new IP), so it would be highly recommended to use a static IP for the instance in this case.
I often use App Engine, for a CNAME, you have to map to ghs.googlehosted.com (https://cloud.google.com/appengine/docs/standard/python/mapping-custom-domains).
It seems possible to do the same on Compute Engine through the network service (https://cloud.google.com/dns/docs/quickstart#create_a_cname_record). If you don't really need the CNAME record, you should use the classical A record. It's a bit easier.
Don't hesite to look into documentations, everything is explained.

How does Route 53 connect multiple public hosted zones to one domain name?

I have two public hosted zones in Amazon Route 53 for the same domain name (which has Route 53 as registrar), for the reason that Route 53 automatically created one when I registered the domain name and that the second one was created by Terraform.
As far as I can tell, DNS record sets in the second zone aren't applied, i.e. they're not returned for queries to the domain. Do I have to delete the first zone in order for record sets in the second zone to be active?
As far as I can tell, which hosted zone is active, meaning that its record sets are returned for queries to the domain, depends on the name servers registered with the domain. So, in order to make my second zone active I have to update the domain's name servers, in Route 53, to correspond to those of the desired hosted zone.
Following is an extract from the AWS Route 53 FAQ
Q. Can I create multiple hosted zones for the same domain name? 
Yes. Creating multiple hosted zones allows you to verify your DNS setting in a “test” environment, and then replicate those settings on a “production” hosted zone. For example, hosted zone Z1234 might be your test version of example.com, hosted on name servers ns-1, ns-2, ns-3, and ns-4. Similarly, hosted zone Z5678 might be your production version of example.com, hosted on ns-5, ns-6, ns-7, and ns-8. Since each hosted zone has a virtual set of name servers associated with that zone, Route 53 will answer DNS queries for example.com differently depending on which name server you send the DNS query to.
Click here for more details
How is Domain-Name, Namespaces, and Hosted-Zone connected?
Imagine you bought a new name from GoDaddy - example.com. Then you setup your website in your EC2 machine which has IP 100.0.0.10. To point example.com to your webserver, you will need to first choose a DNS resolver. AWS provides one - Route53. A DNS resolver translates names like example.com to IP address like 100.0.0.10.
AWS Route53 has a concept of Hosted Zones. You will need to create a hosted zone for example.com. Route53 will then give you nameservers (bunch of different URLs, AWS gives you 4). You will take these nameservers and go back to GoDaddy and there is a section to put those nameservers. This tells GoDaddy where to send the request to.
Why did we do above ^^^ ?
When you purchased the name from GoDaddy, GoDaddy became your registrator i.e. it registered your name with the DNS authorities. So whenever someone requests example.com to the DNS authorities, they will forward the request to GoDaddy. So GoDaddy needs to know where to send the request to. These nameservers tells GoDaddy that exact information.
After the request reaches AWS Route53, it knows that this domain name example.com needs to go to 100.0.0.10.
What if I create 2 Hosted Zones with the same domain name example.com?
A hosted-zone is nothing but Route53's way to define a set of route rules for a domain.
If you have 2 hosted-zone with the same domain name, you will have 2 sets of namespaces. For AWS, each set has 4 namespace, so total of 8 namespaces).
So now it depends which namespaces you give to GoDaddy. You can give it set A, in which case your second hosted-zone will not receive any traffic. You can give it set B, in which case your first hosted-zone will not receive any traffic. Or, you can give it a mixture of both set A and set B, in which case GoDaddy will send some requests to set A and some to set B, not both though.

AWS Route53: Private and public hosted zones under the same domain

I've read through all the AWS docs I can find and GoogleFoo has not resulted in anything.
My case here is we have one domain example.com and up to now we have used it only for Public records. There is one Hosted Zone set to Public. I want to now create a subdomain for private records to use inside of our VPC group for our application (e.g. to point at an ElastiCache instance).
I attempted to create private.example.com as a Private Hosted Zone pointing at our VPC and then created cache.private.example.com as a record under it but it will not resolve.
I am curious if I can configure a subdomain of our main domain somehow?
example.com - Public
** app.example.com
private.example.com - Private
** cache.private.example.com - VPC
OR
Can also create a Private Hosted Zone with the same top level domain example.com? I am nervous to try that because I do not want to affect the application.
example.com - Public
** app.example.com
example.com - Private
** cache.example.com - VPC
For Googlers trying to "subsetting" a public host zone, or to make a private host zone "fallback" or "extend" to public. Read on.
Firstly, R53 is authoritative, means you have to provide exact resolution, so the common way of using different BIND views will not work. Also when host zone names overlap, the private one prevails.
Secondly, R53 will determine which host zone to use based on "specificity". So when user asks for www.example.com, then a host zone named www.example.com prevails another named example.com. This is something we can make use of.
Follow the procedure:
Create a public host zone for your public DNS record (e.g. example.com), or just use any other public DNS record and skip this step
Create a private host zone for each of your sub domain name that has a local / private mirror / cache (e.g. www.example.com)
Create a default record set for each of the private host zones (leaving the "Name" field empty) and point them to local addresses
Attach the private host zones to your selected VPC's
In this way, if your machine asks for www.example.com, and a private host zone matches, it will return local addresses, otherwise, it will fallback to use the public host zone.
The pitfall for this solution is that R53 charges you by number of host zones, so you will have to pay a bit more. Also this is a bit hacky. Otherwise it eliminates the complexity of creating and managing your own BIND server, syncing public records, etc.
You will need to have a different domain for the private zone. Something like "example.internal" Then you could have "cache.example.internal"
cache.private.example.com will not resolve in your current setup, because it will be looking to example.com to resolve that dns. Also note it will only resolve inside the VPC.