ubuntu resolvconf 设置永久dns
最近发现我在/etc/resolv.conf中设置的dns老是被抹去. resolv.conf这个文件其实会被动态改变的, 不能直接修改里面的内容,网上看了解决方案是安装resolvconf。
1. 安装resolvconf
sudo install resolvconf
2. 修改head
vim /etc/resolvconf/resolv.conf.d/head
在 head中添加你想使用的dns
nameserver 8.8.8.8
nameserver 114.114.114.114
3. 刷新/etc/resolv.conf
执行resolvconf -u
命令来刷新/etc/resolv.conf
就可以看到在resolv.conf
的开头已经有了你在head
中添加的nameserver
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.
#
nameserver 8.8.8.8
nameserver 114.114.114.114
我一开用的是阿里的源sources.list
, 怎么都安装不了resolvconf
, 我将原来自带的源sources.list
复原之后,在/etc/resolv.conf
加上8.8.8.8
的dns再执行apt install resolvconf
, 就可以安装成功了
本文作者:_戈多
本文链接:https://www.cnblogs.com/godots/p/15783325.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步