qphoney記

beta

unboundを使ってVPC内のDNSに名前解決する話

全国1億5千万人のAWSファンの皆さんこんにちは。
本ブログの読者の方々は熱烈なAWSファンしかいないので既にご存知だと思いますがRoute53でプライベートDNS機能が発表されましたね。


Amazon Web Services ブログ: Route53のアップデート - プライベートDNS、他


コレ、かなり便利なんですがVPCの内部からしか名前解決出来ないんですよね。しかもVPC内のDNSキャッシュサーバーってVPC内部からしか接続出来ないんですよ。なのでVPC内部にDNSフォワーダをunboundで作ってみました。

やりたいこと

f:id:qphoney:20141114172024p:plain

unboundの設定

きっとこんな感じでunboundを設定すれば動くと思います。
色々と適宜読み替えてください。あとDNSSECは無効にしないとダメっぽい。
設定周りはまだ甘いと思うので調べてダイエットします。

$ sudo yum install -y unbound --enablerepo=epel
$ sudo vi /etc/unbound/unbound.conf
$ sudo diff -u /etc/unbound/unbound.conf.org /etc/unbound/unbound.conf
--- /etc/unbound/unbound.conf.org	2014-11-14 08:24:40.415838696 +0000
+++ /etc/unbound/unbound.conf	2014-11-14 07:57:50.322571090 +0000
@@ -35,7 +35,7 @@
 	# specify 0.0.0.0 and ::0 to bind to all available interfaces.
 	# specify every interface on a new 'interface:' labelled line.
 	# The listen interfaces are not changed on reload, only on restart.
-	# interface: 0.0.0.0
+	interface: 0.0.0.0
 	# interface: ::0
 	# interface: 192.0.2.153
 	# interface: 192.0.2.154
@@ -181,6 +181,7 @@
 	# Choose deny (drop message), refuse (polite error reply),
 	# allow (recursive ok), allow_snoop (recursive and nonrecursive ok)
 	# access-control: 0.0.0.0/0 refuse
+	access-control: 0.0.0.0/0 allow
 	# access-control: 127.0.0.0/8 allow
 	# access-control: ::0/0 refuse
 	# access-control: ::1 allow
@@ -346,7 +347,7 @@
 	# File with DLV trusted keys. Same format as trust-anchor-file.
 	# There can be only one DLV configured, it is trusted from root down.
 	# Downloaded from https://secure.isc.org/ops/dlv/dlv.isc.org.key
-	dlv-anchor-file: "/etc/unbound/dlv.isc.org.key"
+	#dlv-anchor-file: "/etc/unbound/dlv.isc.org.key"
 
 	# File with trusted keys for validation. Specify more than one file
 	# with several entries, one file per entry.
@@ -371,8 +372,8 @@
 	# trusted-keys-file: ""
 	#
 	# trusted-keys-file: /etc/unbound/rootkey.bind
-	trusted-keys-file: /etc/unbound/keys.d/*.key
-	auto-trust-anchor-file: "/var/lib/unbound/root.anchor"
+	#trusted-keys-file: /etc/unbound/keys.d/*.key
+	#auto-trust-anchor-file: "/var/lib/unbound/root.anchor"
 
 	# Ignore chain of trust. Domain is treated as insecure.
 	# domain-insecure: "example.com"
@@ -562,3 +563,6 @@
 # You can now also dynamically create and delete forward-zone's using
 # unbound-control forward_add domain.com 1.2.3.4 5.6.7.8
 # unbound-control forward_remove domain.com 1.2.3.4 5.6.7.8
+forward-zone:
+    name: "."
+    forward-addr: 10.0.0.2

正座して読め

はい、正座して読みます。

第4回 Unboundサーバ運用Tips:Unbound,知ってる? この先10年を見据えたDNS|gihyo.jp … 技術評論社

Special Thanks

滝澤先生、マジ滝澤。