systemd-resolvedを制御する

systemd

systemd-resolvedの動作を理解し,制御できるようにします.

systemd-resolvedについて

systemd-resolvedとは,簡単に言うとDNSのリゾルバ(DNSのクライアント)を制御するための仕組みと考えておけばいいでしょう.ここは後で詳しく調べることにします.

systemd-resolvedの定義ファイル

fedora 35において,systemd-resolvedの定義ファイルは,/etc/systemd/resolved.confとなっています.このファイルに各種パラメータの設定を行うことによってsystemd-resolvedの動作を制御します.

/etc/resolv.confファイル

/etc/resolv.confは,/run/systemd/resolve/stub-resolv.confへのシンボリックリンクになっています.

# ls -l /etc/resolv.conf
lrwxrwxrwx. 1 root root 37 Jan 13 15:19 /etc/resolv.conf -> /run/systemd/resolve/stub-resolv.conf

/etc/systemd/resolved.confでDNSStubListener=noを指定し,systemclt restart systemd-resolvedコマンドを実行すると,

systemctl restart systemd-resolved

/etc/resolv.confは,/run/systemd/resolve/stub-resolv.confへのシンボリックリンクはそのままに,/run/systemd/resolve/resolv.confが作成され,さらに/run/systemd/resolve/stub-resolv.confが/run/systemd/resolve/resolv.confへのシンボリックリンクとなります.

# pwd
/run/systemd/resolve
# ls -l
-rw-r--r--.  1 systemd-resolve systemd-resolve 844 Mar 18 17:50 resolv.conf
lrwxrwxrwx.  1 systemd-resolve systemd-resolve  11 Mar 18 17:50 stub-resolv.conf -> resolv.conf

よって,systemd-resolvedが起動しているときは,/etc/resolv.confを直接編集することは推奨できません.

コメント

タイトルとURLをコピーしました