《課題》
VPC内でのみ名前解決をできるようにRoute 53でPrivate DNSを設定する
・Private DNSに以下の設定をする
sub.example.com A xxx.xxx.xxx.xxx
《前提条件》
・AWSの構成
VPCにEC2インスタンスが一つ
《手順》
▼Route 53の設定
・Hosted zonesの作成
プライベートホストゾーンを作成して対象のVPCに関連付ける
####1. サイドメニュー[Hosted zones]をクリックし、[Create Hosted Zone]ボタンをクリック
2. Hosted zonesの情報を入力し、[Create]ボタンをクリック
Domain Name : example.com
Comment : 任意のコメント
Type : Private Hosted Zone for Amazon VPC
VPC ID : 対象のVPC
NSレコードとSOAレコードが登録されたHosted zonesが作成される
3. [Create Record Set]ボタンをクリック
4. Record 情報を入力し、[Create]ボタンをクリック
Name : sub.example.com.
Type : A – IPv4 address
Alias : No
TTL (Seconds) : 300
Value : xxx.xxx.xxx.xxx(対象IPアドレス)
Routing Policy : simple
Routing Policyで様々のルールでのルーティングが可能。simpleは通常のDNS。
詳細は「ルーティングポリシーの選択」を参照
▼VPCの設定
・Private Hosted Zoneを利用できる様に設定
参照:[Amazon Route 53 - プライベートホストゾーンの使用]
(http://docs.aws.amazon.com/ja_jp/Route53/latest/DeveloperGuide/hosted-zones-private.html)
####1. サイドメニュー[VPC]をクリックし、対象のVPCを選択
2. [アクション]-[DNS 解決の編集]をクリックし、設定変更し[保存]ボタンをクリック
DNS解決 : はい
※enableDnsHostnamesをtrue
3. [アクション]-[DNS ホスト名の編集]をクリックし、設定変更し[保存]ボタンをクリック
DNS ホスト名の編集 : はい
※enableDnsSupportをtrue
▼名前解決の確認
VPCに属するEC2インスタンスからnslookupの実行
設定前
$ nslookup sub.example.com
Server: 10.0.0.2
Address: 10.0.0.2#53
** server can't find sub.example.com: NXDOMAIN
>
```bash:設定後
$ nslookup sub.example.com
Server: 10.0.0.2
Address: 10.0.0.2#53
>
Non-authoritative answer:
Name: sub.example.com
Address: xxx.xxx.xxx.xxx
正しく設定したIPアドレスが返ってくればOK