174 字
1 分钟
Linux 配置 DNS
如果你在 /etc/resolv.conf 文件中看到了“不要修改”或“这是链接”的提示,这通常意味着你的系统正在使用 resolvconf 或 systemd-resolved 管理 DNS 设置。
方法 1:使用 resolvconf 更新 DNS
如果你的系统使用 resolvconf:
- 编辑
/etc/resolvconf/resolv.conf.d/base文件(如果不存在,就创建它):sudo nano /etc/resolvconf/resolv.conf.d/base - 添加 DNS 服务器地址,例如:
nameserver 8.8.8.8nameserver 8.8.4.4
- 保存文件并退出编辑器。
- 更新
resolvconf:sudo resolvconf -u
方法 2:使用 systemd-resolved 配置 DNS
如果你的系统使用 systemd-resolved:
- 编辑
/etc/systemd/resolved.conf文件:sudo nano /etc/systemd/resolved.conf - 在
[Resolve]部分添加或修改 DNS 设置,例如:DNS=8.8.8.8 8.8.4.4 - 保存文件并退出编辑器。
- 重启
systemd-resolved服务:sudo systemctl restart systemd-resolved
Linux 配置 DNS
https://blog.lpkt.cn/posts/linux-dns-conf/