Ubuntu系统ECS重启后“/etc/resolv.conf”被还原怎么办?
温馨提示:
本文最后更新于 2025年09月08日,已超过 4 天没有更新。若文章内的图片失效(无法正常加载),请留言反馈或直接联系我。
处理方法
方法一:手动修改/etc/resolv.conf文件。
以root用户登录E CS 。
关闭并禁用systemd-resolved服务。
systemctl stop systemd-resolved
systemctl disable systemd-resolved
默认的/etc/resolv.conf是软链接,删除重建为普通文件。
rm -rf /etc/resolv.conf
编辑/etc/resolv.conf,增加相关DNS配置。
vim /etc/resolv.conf
通过添加自定义的nameserver参数增加DNS配置,如下所示:
nameserver 114.114.114.114
nameserver 8.8.8.8
nameserver 223.5.5.5
将/etc/resolv.conf配置文件加锁,防止被dhcp或者其他服务更改。
chattr +i /etc/resolv.conf
正文到此结束
- 本文标签: Linux
- 本文链接: https://code.itptg.com/article/133
- 版权声明: 本文由老魏原创发布,转载请遵循《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权