LoginSignup
10
13

More than 5 years have passed since last update.

127.0.0.53:53 って 誰が 使ってるの?

Last updated at Posted at 2017-07-12

dnsdist を使って 内外の振り分けする DNS権威サーバを 構築しようとしたら ポート使ってるって エラーになった。

計画は こうだった。

1、bindから脱却する
2、DNS権威サーバに NSDを採用
3、リゾルバに unboundを採用
4、内向きと外向きで別にしたいのでdnsdistで 振り分け
5、それ以外は unboundで 解決させる

ubuntuのLTSの 16.04で dnsdist を aptで インストールしたら 1.0α だったので 17.04 にしてみた。 すると 1.1.0 になったので これで チャレンジしてみることにした。

最初の設定は ↓のような感じ

/etc/dnsdist/dnsdist.conf
newServer({address="127.0.0.1:8053", pool="auth"}) 
newServer({address="127.0.0.1:8153", pool="local"}) 
newServer({address="127.0.0.1:8253", pool="resolver"}) 
authdomains = newSuffixMatchNode() 
authdomains:add(newDNSName("example.com.")) 
allow_recursion = newNMG() 
allow_recursion:addMask("10.0.0.0/8") 
addAction(AndRule({SuffixMatchNodeRule(authdomains),NetmaskGroupRule(allow_recursion)}), PoolAction("local")) 
addAction(SuffixMatchNodeRule(authdomains), PoolAction("auth")) 
addAction(NetmaskGroupRule(allow_recursion), PoolAction("resolver")) 
addAction(AllRule(), RCodeAction(5)) 
addACL("0.0.0.0/0") 
addACL("::0/0") 
addLocal("0.0.0.0:53") 
addLocal("[::]:53")

sudo systemctl start dnsdist.service で 起動するとエラーが発生し、journalctl -xe で内容を確認した。

-- Unit dnsdist.service has begun starting up.
Jul 12 12:24:08 DNSmaster dnsdist[1868]: Configuration '/etc/dnsdist/dnsdist.conf' OK!
Jul 12 12:24:08 DNSmaster dnsdist[1868]: Configuration '/etc/dnsdist/dnsdist.conf' OK!
Jul 12 12:24:08 DNSmaster dnsdist[1881]: Added downstream server 127.0.0.1:10053
Jul 12 12:24:08 DNSmaster dnsdist[1881]: Added downstream server 127.0.0.1:20053
Jul 12 12:24:08 DNSmaster dnsdist[1881]: Fatal error: binding socket to 0.0.0.0:53: Address already in use
Jul 12 12:24:08 DNSmaster systemd[1]: dnsdist.service: Main process exited, code=exited, status=1/FAILURE
Jul 12 12:24:08 DNSmaster systemd[1]: Failed to start DNS Loadbalancer.

と bindできないという エラーになった。

netstat で しらべると

tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:5355            0.0.0.0:*               LISTEN
tcp6       0      0 :::22                   :::*                    LISTEN
tcp6       0      0 :::5355                 :::*                    LISTEN
udp        0      0 127.0.0.53:53           0.0.0.0:*
udp        0      0 0.0.0.0:5355            0.0.0.0:*
udp6       0      0 :::5355                 :::*

127.0.0.53 が いるじゃないか。
おもわず 「誰だよ」と こえが 出てしまった。
調べてわかったのだが、systemdの一部として 提供されている リゾルバだった。設定も /etc/systemd/resolved にあり、 停止することもできるようだ。
(参考にしたページ
https://kledgeb.blogspot.jp/2016/06/ubuntu-1610-7-dnssystemd-resolved.html
http://nao-yu-ki-pc.blogspot.jp/2017/04/systemd-resolveubuntudns.html )

その正体こそ systemd-resolved だ。 ubuntu では 16.10から すべてのリリースで採用されたので ubuntu server でも 採用されたのだった。

標準提供される リゾルバが あるんだったら 利用しないてはないので 先ほどの設定ファイルを 次のように修正した。

/etc/dnsdist/dnsdist.conf
newServer({address="127.0.0.1:8053", pool="auth"}) 
newServer({address="127.0.0.1:8153", pool="local"}) 
newServer({address="127.0.0.53:53", pool="resolver"}) 
authdomains = newSuffixMatchNode() 
authdomains:add(newDNSName("example.com.")) 
allow_recursion = newNMG() 
allow_recursion:addMask("10.0.0.0/8") 
addAction(AndRule({SuffixMatchNodeRule(authdomains),NetmaskGroupRule(allow_recursion)}), PoolAction("local")) 
addAction(SuffixMatchNodeRule(authdomains), PoolAction("auth")) 
addAction(NetmaskGroupRule(allow_recursion), PoolAction("resolver")) 
addAction(AllRule(), RCodeAction(5)) 
addACL("0.0.0.0/0") 
addLocal("10.0.0.10:53") 

さて、 この設定で うまいこと いくかな。

10
13
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
13