Linux Mint から LMDE に移行したら systemd-resolved が自動起動しておらず、そこら辺の設定変更をしている中でようやく DNSサーバーの設定が落ち着きました。
まずは現状です。systemd-resolved を起動させ、ちょっと設定を反映させた状態です。
$ resolvectl status Global Protocols: +LLMNR +mDNS -DNSOverTLS DNSSEC=no/unsupported resolv.conf mode: stub Fallback DNS Servers: 1.1.1.1 1.0.0.1 2606:4700:4700::1111 2606:4700:4700::1001 Link 2 (eno1) Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6 Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported Current DNS Server: 2409:11:a720:f00:8222:a7ff:fea8:f0f0 DNS Servers: 2409:11:a720:f00:8222:a7ff:fea8:f0f0 DNS Domain: flets-east.jp iptvf.jp
LMDE では systemd-resolved が自動起動する設定になっていないので、glibc resolver が DNS 問い合わせを担当しており、このスタブリゾルバーは問い合わせ結果をキャッシュしないとのことでした。
どうりで apt update とかの動きが遅かったわけです。
(Firefox は自分で DNS 問い合わせ結果をキャッシュするので、あまり遅さは感じませんでした)
ということで、まずは systemd-resolved が起動するように準備しました。
まずは systemd-resolved に FallbackDNS を設定します。
(これはもうお好みで)
cat /etc/systemd/resolved.conf
# This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # Entries in this file show the compile time defaults. # You can change settings by editing this file. # Defaults can be restored by simply deleting this file. # # See resolved.conf(5) for details [Resolve] # Some examples of DNS servers which may be used for DNS= and FallbackDNS=: # Cloudflare: 1.1.1.1 1.0.0.1 2606:4700:4700::1111 2606:4700:4700::1001 # Google: 8.8.8.8 8.8.4.4 2001:4860:4860::8888 2001:4860:4860::8844 # Quad9: 9.9.9.9 2620:fe::fe #DNS= FallbackDNS=1.1.1.1 1.0.0.1 2606:4700:4700::1111 2606:4700:4700::1001 #Domains= #DNSSEC=no #DNSOverTLS=no #MulticastDNS=yes #LLMNR=yes #Cache=yes #DNSStubListener=yes #DNSStubListenerExtra= #ReadEtcHosts=yes #ResolveUnicastSingleLabel=no
続いて、systemd-resolved が自動起動するようにします。
systemctl enable systemd-resolved.service
スタブリゾルバーの向き先を systemd-resolved となるようにシンボリックリンクを張ります。
sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
systemd-resolved を起動します。
systemctl start systemd-resolved.service
これで DNS 問い合わせ結果がキャッシュされるようになり、apt update もスムーズに動くようになりました。
この状態で resolvectl status で確認すると先ほどの結果が応答されるのですが、Current DNS Server が「2409:11:a720:f00:8222:a7ff:fea8:f0f0」となっています。
調べてみると、これは transix の IPv6 な DNS サーバーのようです。NetworkManager では IPv4 も IPv6 も DNS サーバーは自動設定にしてありますが、IPv4 な DNS 問い合わせはどうやって処理しているんだろうという疑問が沸きました。
またまた調べてみると、IPv6 な DNS サーバーは IPv6 用の AAAA レコードと IPv4 用の A レコードの両方に対応できるらしく、なるほどそういうことかと納得できました。
そうすると、resolved.conf に指定した FallbackDNS も IPv6 だけで良いような気がしてきました。
・FallbackDNS は transix の DNS サーバーが死んでしまった場合に活躍する
・IPoE なインターネット回線なので、IPv4 だけ使えない状況は発生するかもしない
・IPv6 が使えない時は回線自体が使えないはずなので DNS どころの話ではない
ということで、resolved.conf を再度編集してから systemd-resolved を再起動してワタシの DNS 設定は完成しました。
$ systemctl restart systemd-resolved.service $ resolvectl status Global Protocols: +LLMNR +mDNS -DNSOverTLS DNSSEC=no/unsupported resolv.conf mode: stub Fallback DNS Servers: 2606:4700:4700::1111 2606:4700:4700::1001 Link 2 (eno1) Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6 Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported DNS Servers: 2409:11:a720:f00:8222:a7ff:fea8:f0f0 DNS Domain: flets-east.jp iptvf.jp
これでスッキリです。