2020/8/3

systemd-resolved 手動設定 dns server

現在都用這個了,加上nat 的主機,使用 dnsmasq,跟這個衝突,所以一堆 nat 後面的機器,dns 都指向nat,然後 nat 的 dns 又fail..
所以常常要手動設定。

寫一下systemd-resolved 怎麼手動設 dns server 好了。

ref: 使用 systemd-resolved 之後,原來的 /etc/resolv.conf 指向自己了..
而且是由 systemd-resolved 產生,所以改/etc/resolv.conf 沒用。

要改 systemd-resolved 的 config 檔: /etc/systemd/resolv.conf

安裝完的 /etc/systemd/resolv.conf ,內容是都 comment 掉的,
所以要修改就要把 comment 拿掉,加入自己的選項。
例如:用 1.1.1.1 做 dns:
[Resolved]
DNS=1.1.1.1

改完之後,重新啟動 systemd-resolved:
$ sudo service systemd-resolved restart

要看看現在的 dns server ip
systemd-resolve --status
ref: 這一篇有清處的說明。
就是要區分 interface。dnsmasq 的 dns 服務限制在 enp0xxx。
然後給 dnsmasq 獨立的 resolv.conf ,他會依照這個 resolv.conf 的內容(mirror) dns 服務給剛剛設定的interface。
原來的 systemd-resolved 就用原來的 127.0.0.53
這樣就不衝突。

沒有留言:

張貼留言