ytooyamaのブログ

サーバ構築とか、仕事で発見したこととか、趣味のこととかを書いています。

Fedora 21とdnsmasq

以前、Fedora 20でdnsmasqによる簡易DNSサーバーを構築したのですが、先ほどfedupコマンドでFedora 21 Serverにアップデートしたところ、名前解決ができなくなりました。

ただFedora 21 Server上では名前解決できるので、どうやら待ち受けポートが原因っぽいです。
とりあえずnetstatコマンドを実行してみました。

# netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 1044/dnsmasq

うん。ローカルIPアドレスで待ち受けてますね。そりゃあ他のノードからアクセスできないわな。
Fedora 20当時のdnsmasq.confと新しいものを比較してみました。

# Uncomment these to enable DNSSEC validation and caching:
# (Requires dnsmasq to be built with DNSSEC option.)
#conf-file=%%PREFIX%%/share/dnsmasq/trust-anchors.conf
#dnssec

# Replies which are not DNSSEC signed may be legitimate, because the domain
# is unsigned, or may be forgeries. Setting this option tells dnsmasq to
# check that an unsigned reply is OK, by finding a secure proof that a DS
# record somewhere between the root and the domain does not exist.
# The cost of setting this is that even queries in unsigned domains will need
# one or more extra DNS queries to verify.
#dnssec-check-unsigned

dnssec関連の項目が追加されています。
というわけで古い設定は破棄して、以下の設定を新しい設定ファイルに書き込みました。

# vi /etc/dnsmasq.conf
# Listen on this specific port instead of the standard DNS port
# (53). Setting this to zero completely disables DNS function,
# leaving only DHCP and/or TFTP.
port=53 #コメントを外してポートを変更
bogus-priv #コメントを外す
expand-hosts #コメントを外す
local=/local.tooyama.org/
(shorthostnameで補完するドメインを記述)
domain=local.tooyama.org
(shorthostnameで補完するドメインを記述)

設定を変更したらdnsmasqを再起動

# service dnsmasq restart

ポートの確認

# netstat -tanp|grep dnsmasq
tcp 0 0 0.0.0.0:53 0.0.0.0:* LISTEN 2608/dnsmasq
tcp6 0 0 :::53 :::* LISTEN 2608/dnsmasq

OK!
最後にクライアントにDNSサーバーを指定して、外部ドメインと名前解決できれば完了です。

今考えてみれば、設定ファイルに二つを追記するだけでよかったのかもしれません。コメントアウトしていないので、DNSSECの設定が有効化されて上手く動かなかったのかも。

#conf-file=%%PREFIX%%/share/dnsmasq/trust-anchors.conf
#dnssec
#dnssec-check-unsigned

このブログサイトはJavaScriptを使っていますが、読み込んでいるJavaScriptは全てはてなが提供しているものであり、筆者が設置しているものではありません。