[DHCP]いくつかのオプション

[DHCP]いくつかのオプション

systemd-resolved.serviceについて読みました。https://www.freedesktop.org/software/systemd/man/systemd-resolved.service.htmlそして/etc/resolv.confを扱う4つのモードを学びました。

  1. /run/systemd/resolve/stub-resolv.conf
  2. /usr/lib/systemd/resolv.conf
  3. /run/systemd/resolve/resolv.conf
  4. /etc/resolv.confは他のパッケージで管理できます。

私はこれを何度も読みましたが、一般ユーザーとして選択する必要がある/etc/resolv.confのモードを決定する方法についてまだ混乱しています。

たとえば、いくつかのカスタムDNSサーバーを追加してみました。

  1. /etc/systemd/resolved.confにDNS=8.8.8.8 8.8.4.4を追加し、/run/systemd/resolve/resolv.conf、8.8.8.8、8.8.4.4があることを確認します。
  2. /run/systemd/resolve/resolv.confが/etc/resolv.confにシンボリックリンクされている場合、8.8.8.8と8.8.4.4は/run/systemd/resolve/resolv.confから消えます。

アップデート1:

test@instance-1:~$ cat /run/systemd/resolve/resolv.conf 
...
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.
nameserver 8.8.8.8
nameserver 8.8.4.4

test@instance-1:/etc$ sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf 
test@instance-1:/etc$ ls -alh /etc/resolv.conf 
lrwxrwxrwx 1 root root 32 Mar 18 07:22 /etc/resolv.conf -> /run/systemd/resolve/resolv.conf
test@instance-1:/etc$ sudo reboot

test@instance-1:~$ cat /etc/resolv.conf 
domain c.prime-poetry-197705.internal
search c.prime-poetry-197705.internal. google.internal.
nameserver 169.254.169.254

test@instance-1:~$ cat /run/systemd/resolve/resolv.conf 
domain c.prime-poetry-197705.internal
search c.prime-poetry-197705.internal. google.internal.
nameserver 169.254.169.254

test@instance-1:~$ ls -alh /etc/resolv.conf 
lrwxrwxrwx 1 root root 32 Mar 18 07:22 /etc/resolv.conf -> /run/systemd/resolve/resolv.conf

アップデート2:/etc/resolv.confのシンボリックリンク

test@instance-1:~$ sudo ln -sf /etc/resolv.conf /run/systemd/resolve/resolv.conf 
test@instance-1:~$ ls -alh /run/systemd/resolve/resolv.conf 
lrwxrwxrwx 1 root root 16 Mar 18 07:51 /run/systemd/resolve/resolv.conf -> /etc/resolv.conf
test@instance-1:~$ sudo reboot

test@instance-1:~$ ls -alh /run/systemd/resolve/resolv.conf 
-rw-r--r-- 1 systemd-resolve systemd-resolve 603 Mar 18 07:52 /run/systemd/resolve/resolv.conf

ベストアンサー1

私の考えでは、DHCPからIP設定をインポートし、ファイルresolved.conf(からsystemd.network(5))のDNS情報を上書きするようです。

[DHCP]いくつかのオプション

[...]

UseDNS=(デフォルト)の場合、trueDHCPサーバーから受信したDNSサーバーが使用され、静的に構成されたサーバーよりも優先されます。

これはnameserverのオプションに対応しますresolv.conf(5)

{networkname}.networkファイル()に以下を追加してみてください/etc/systemd/network

[DHCP]
UseDNS=false

おすすめ記事