Know How Guide and Hands on Guide for AWS
如何在不同账号间迁移hosted zone?
enableDnsHostnames
and enableDnsSupport
in your VPC settingAttribute | Description |
---|---|
enableDnsHostnames | Indicates whether instances with public IP addresses get corresponding public DNS hostnames.</br> If this attribute is true, instances in the VPC get public DNS hostnames, but only if the enableDnsSupport attribute is also set to true. |
enableDnsSupport | Indicates whether the DNS resolution is supported. </br> If this attribute is false, the Amazon-provided DNS server that resolves public DNS hostnames to IP addresses is not enabled. </br> If this attribute is true, queries to the Amazon provided DNS server at the 169.254.169.253 IP address, or the reserved IP address .2 will succeed. |
More information, please check https://docs.aws.amazon.com/vpc/latest/userguide/vpc-dns.html
https://docs.aws.amazon.com/vpc/latest/userguide/VPC_DHCP_Options.html
When EC2 inside the VPC queries DNS by use the AmazonProvidedDNS, if there is a www.mycompany.com record in the private hosted zone, DNS Server will resolve to private hosted zone record address. If there is no www.mycompany.com record in the private hosted zone, DNS Server will forward it to the up Authoritative DNS server (such as public DNS) to resolve the name.
For example:
[ec2-user@ip-10-0-2-83 workspace]$ nslookup www.amazon.com
Server: 10.0.0.2
Address: 10.0.0.2#53
Non-authoritative answer:
www.amazon.com canonical name = tp.47cf2c8c9-frontier.amazon.com.
tp.47cf2c8c9-frontier.amazon.com canonical name = www.amazon.com.edgekey.net.
www.amazon.com.edgekey.net canonical name = e15316.e22.akamaiedge.net.
Name: e15316.e22.akamaiedge.net
Address: 23.34.96.95
More details please check
In global region, you can leverage the Route53 resolver
How to use the Route53 API in my code
Please check the sample code writtern by go-sdk route53-demo.go
测试场景
How do I associate a Route 53 private hosted zone with a VPC on a different AWS account?
The key points:
# authorize the association between the private hosted zone in Account A (hosted-zone-id) and the VPC in Account B (vpc-id). Running on Account A
aws route53 create-vpc-association-authorization --hosted-zone-id <hosted-zone-id> --vpc VPCRegion=<region>,VPCId=<vpc-id>
# create the association between the private hosted zone in Account A (hosted-zone-id) and the VPC in Account B (vpc-id). Running on Account B
aws route53 associate-vpc-with-hosted-zone --hosted-zone-id <hosted-zone-id> --vpc VPCRegion=<region>,VPCId=<vpc-id>
# delete the association authorization after the association is created. Running on Account A
aws route53 delete-vpc-association-authorization --hosted-zone-id <hosted-zone-id> --vpc VPCRegion=<region>,VPCId=<vpc-id>
# EC2 instances in the VPC from Account B can now resolve records in the private hosted zone in Account A.
Please make sure your VPC DNS setting and DHCP setting
[ec2-user@ip-10-0-7-116 ~]$ nslookup www.amazon.com
Server: 10.0.0.2
Address: 10.0.0.2#53
Non-authoritative answer:
www.amazon.com canonical name = tp.47cf2c8c9-frontier.amazon.com.
tp.47cf2c8c9-frontier.amazon.com canonical name = d3ag4hukkh62yn.cloudfront.net.
Name: d3ag4hukkh62yn.cloudfront.net
Address: 13.225.132.237
[ec2-user@ip-10-0-7-116 ~]$ nslookup www.baidu.com
Server: 10.0.0.2
Address: 10.0.0.2#53
Non-authoritative answer:
www.baidu.com canonical name = www.a.shifen.com.
Name: www.a.shifen.com
Address: 220.181.38.149
Name: www.a.shifen.com
Address: 220.181.38.150
Name: www.a.shifen.com
Address: 240e:83:205:59:0:ff:b09b:159e
Name: www.a.shifen.com
Address: 240e:83:205:58:0:ff:b09f:36bf
Then I add the API Gateway VPC endpoint and query the API Gateway url domain name
[ec2-user@ip-10-0-7-116 ~]$ nslookup gret8sxv4j.execute-api.cn-north-1.amazonaws.com.cn
Server: 10.0.0.2
Address: 10.0.0.2#53
Non-authoritative answer:
gret8sxv4j.execute-api.cn-north-1.amazonaws.com.cn canonical name = execute-api.cn-north-1.amazonaws.com.cn.
Name: execute-api.cn-north-1.amazonaws.com.cn
Address: 10.0.4.49
Name: execute-api.cn-north-1.amazonaws.com.cn
Address: 10.0.1.52
[ec2-user@ip-10-0-7-116 ~]$ nslookup 6foorhitui.execute-api.cn-north-1.amazonaws.com.cn
Server: 10.0.0.2
Address: 10.0.0.2#53
Non-authoritative answer:
6foorhitui.execute-api.cn-north-1.amazonaws.com.cn canonical name = execute-api.cn-north-1.amazonaws.com.cn.
Name: execute-api.cn-north-1.amazonaws.com.cn
Address: 10.0.1.52
Name: execute-api.cn-north-1.amazonaws.com.cn
Address: 10.0.4.49