10
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

EC2のPublicDNSの解決の仕組み

Last updated at Posted at 2014-01-07

#結論

  • 同じリージョンであればZoneが異なっても、Public DNSはPrivate IPとして解決される
  • リージョンが異なるとPublic DNSはPublic IPとして解決される

#確認してみた
同じリージョンの異なるゾーンでインスタンスをたてる

1.us-west-2a

Public DNS:ec2-54-203-255-149.us-west-2.compute.amazonaws.com
Public IP:54.203.255.149
Elastic IP:54.203.255.149

Private DNS:ip-10-252-192-161.us-west-2.compute.internal
Private IPs:10.252.192.161

Security groups:launch-wizard-1

2.us-west-2c

Public DNS:ec2-54-245-152-35.us-west-2.compute.amazonaws.com
Public IP:54.245.152.35 

Private DNS:ip-10-217-149-198.us-west-2.compute.internal
Private IPs:10.217.149.198

Security groups:launch-wizard-1

3.ap-northeast-1a
異なるリージョンのサーバーも用意しておく

Public DNS:ec2-54-238-12-24.ap-northeast-1.compute.amazonaws.com
Public IP:54.238.12.24

Private DNS:ip-10-132-73-226.ap-northeast-1.compute.internal
Private IPs:10.132.73.226

IPの解決

###us-west-2cからus-west-2aを呼ぶ場合

[ec2-user@ip-10-217-149-198 ~]$ nslookup ec2-54-203-255-149.us-west-2.compute.amazonaws.com
Server:		172.16.0.23
Address:	172.16.0.23#53

Non-authoritative answer:
Name:	ec2-54-203-255-149.us-west-2.compute.amazonaws.com
Address: 10.252.192.161

[ec2-user@ip-10-217-149-198 ~]$ nslookup ip-10-252-192-161.us-west-2.compute.internal
Server:		172.16.0.23
Address:	172.16.0.23#53

Non-authoritative answer:
Name:	ip-10-252-192-161.us-west-2.compute.internal
Address: 10.252.192.161

Public DNSもPrivate DNSもPrivate IPの10.252.192.161となった

ここで、us-west-2aをStop/Startしてみる

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html
AWSのドキュメント
classicの場合は、Elastic IPが外れるので、手動で再度関連づける

Public DNS:ec2-54-203-255-149.us-west-2.compute.amazonaws.com
Public IP:54.203.255.149
Elastic IP:54.203.255.149

Private DNS:ip-10-217-149-198.us-west-2.compute.internal
Private IP:10.232.1.18

Security groups:launch-wizard-1
[ec2-user@ip-10-217-149-198 ~]$ nslookup ec2-54-203-255-149.us-west-2.compute.amazonaws.com
Server:		172.16.0.23
Address:	172.16.0.23#53

Non-authoritative answer:
Name:	ec2-54-203-255-149.us-west-2.compute.amazonaws.com
Address: 10.232.1.18

[ec2-user@ip-10-217-149-198 ~]$ nslookup ip-10-232-1-18.us-west-2.compute.internal
Server:		172.16.0.23
Address:	172.16.0.23#53

Non-authoritative answer:
Name:	ip-10-232-1-18.us-west-2.compute.internal
Address: 10.232.1.18

Elastic IPはかわらないが、nslookup ip-10-217-149-198.us-west-2.compute.internalの結果は、あたらしいPrivate IP(10.232.1.18)になった(期待通り)

###us-west-2cからap-northeast-1aを呼ぶ場合

[ec2-user@ip-10-217-149-198 ~]$ nslookup ec2-54-238-12-24.ap-northeast-1.compute.amazonaws.com
Server:		172.16.0.23
Address:	172.16.0.23#53

Non-authoritative answer:
Name:	ec2-54-238-12-24.ap-northeast-1.compute.amazonaws.com
Address: 54.238.12.24

[ec2-user@ip-10-217-149-198 ~]$ nslookup ip-10-132-73-226.ap-northeast-1.compute.internal
Server:		172.16.0.23
Address:	172.16.0.23#53

** server can't find ip-10-132-73-226.ap-northeast-1.compute.internal: NXDOMAIN

Public DNSの解決はできたが、Private DNSは解決できない

##まとめ

  • 同じリージョンであればZoneが異なっても、Public DNSPrivate IPとして解決される
  • リージョンが異なるとPublic DNSPublic IPとして解決される
10
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?