mod*_*tos 5 networking linux dns arch-linux
如何更换我的 DNS?我不使用网络管理员,除了systemd-networkd
和wpa_supplicant
无线,带wpa_cli
。如果重要的话,我在 Arch Linux 上。
尽管我可以将 DNS 添加到我的配置中、systemctl restart systemd-resolved
覆盖/etc/resolv.conf
(符号链接到/run/systemd/resolve/resolv.conf
)或重新启动,但以某种方式将默认的 ISP DNS 添加到/etc/resolv.conf
. 有谁知道为什么,或如何解决此问题以仅使用我配置的 DNS?
当我编辑/etc/resolv.conf
为只包含
nameserver 208.67.222.222
nameserver 208.67.220.220
Run Code Online (Sandbox Code Playgroud)
并运行systemctl restart systemd-resolved
或重新启动,默认的 ISP DNS 被覆盖,cat /etc/resolv.conf
是这样的:
# This file is managed by systemd-resolved(8). Do not edit.
#
# Third party programs must not access this file directly, but
# only through the symlink at /etc/resolv.conf. To manage
# resolv.conf(5) in a different way, replace the symlink by a
# static file or a different symlink.
nameserver 75.75.75.75
nameserver 192.168.1.1
nameserver 208.67.222.222
# Too many DNS servers configured, the following entries may be ignored.
nameserver 75.75.76.76
nameserver 208.67.220.220
Run Code Online (Sandbox Code Playgroud)
如下所述man resolved.conf
,我确保我只有一个配置文件/etc/systemd/resolved.conf.d/resolv.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.
#
# See resolved.conf(5) for details
[Resolve]
DNS=208.67.222.222 208.67.220.220
#FallbackDNS=8.8.8.8 8.8.4.4 2001:4860:4860::8888 2001:4860:4860::8844
#LLMNR=yes
Run Code Online (Sandbox Code Playgroud)
并且没有其他文件从此处的所有配置文件中定义我的 DNS:
/etc/systemd/resolved.conf
/etc/systemd/resolved.conf.d/*.conf
/run/systemd/resolved.conf.d/*.conf
/usr/lib/systemd/resolved.conf.d/*.conf
Run Code Online (Sandbox Code Playgroud)
我也不相信我正在运行任何 dhcpcd 或 netctl 服务systemctl | grep dhcpcd
,并且systemctl | grep netctl
没有返回任何内容。
我通过将以下内容添加到我的网络配置文件中解决了此问题/etc/systemd/network/*.network
:
[DHCP]
UseDNS=false
Run Code Online (Sandbox Code Playgroud)
默认情况下,这是正确的,这意味着 DNS 服务器是从 DHCP 网络连接中获取的。如果我禁用此功能,并输入我自己的静态 DNS(即 OpenDNS),那么我可以确保只使用我选择的 DNS。
归档时间: |
|
查看次数: |
5136 次 |
最近记录: |