Ubuntu重新夺回对 /etc/resolv.conf 的控制权 解除53端口占用

评论186

如果是 Ubuntu 16.10 或更新的版本,则由 systemd-resolved 服务来管理 DNS,可以使用下面的命令来禁用并立即停止该服务并解除53端口的占用:

systemctl disable --now systemd-resolved.service 
rm /etc/resolv.conf

然后手动创建 /etc/resolv.conf 文件。文章源自合一学院-https://unvmax.com/ubuntu%e9%87%8d%e6%96%b0%e5%a4%ba%e5%9b%9e%e5%af%b9-etc-resolv-conf-%e7%9a%84%e6%8e%a7%e5%88%b6%e6%9d%83-%e8%a7%a3%e9%99%a453%e7%ab%af%e5%8f%a3%e5%8d%a0%e7%94%a8.html

创建 /etc/resolv.conf

最后的最后,就是手动创建 /etc/resolv.conf 文件了,建议权限设置为 644。配置示例:文章源自合一学院-https://unvmax.com/ubuntu%e9%87%8d%e6%96%b0%e5%a4%ba%e5%9b%9e%e5%af%b9-etc-resolv-conf-%e7%9a%84%e6%8e%a7%e5%88%b6%e6%9d%83-%e8%a7%a3%e9%99%a453%e7%ab%af%e5%8f%a3%e5%8d%a0%e7%94%a8.html

nameserver 114.114.114.114 
nameserver 223.5.5.5

当然,除了 nameserver 外,还有其他的参数可以配置,感兴趣可以 man 一下:文章源自合一学院-https://unvmax.com/ubuntu%e9%87%8d%e6%96%b0%e5%a4%ba%e5%9b%9e%e5%af%b9-etc-resolv-conf-%e7%9a%84%e6%8e%a7%e5%88%b6%e6%9d%83-%e8%a7%a3%e9%99%a453%e7%ab%af%e5%8f%a3%e5%8d%a0%e7%94%a8.html

man 5 resolv.conf
文章源自合一学院-https://unvmax.com/ubuntu%e9%87%8d%e6%96%b0%e5%a4%ba%e5%9b%9e%e5%af%b9-etc-resolv-conf-%e7%9a%84%e6%8e%a7%e5%88%b6%e6%9d%83-%e8%a7%a3%e9%99%a453%e7%ab%af%e5%8f%a3%e5%8d%a0%e7%94%a8.html文章源自合一学院-https://unvmax.com/ubuntu%e9%87%8d%e6%96%b0%e5%a4%ba%e5%9b%9e%e5%af%b9-etc-resolv-conf-%e7%9a%84%e6%8e%a7%e5%88%b6%e6%9d%83-%e8%a7%a3%e9%99%a453%e7%ab%af%e5%8f%a3%e5%8d%a0%e7%94%a8.html
教程最后更新:2024-7-18
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证