如何还原/重新创建etc / resolv.conf文件


10

假设resolvconf导致UCK失败,我错误地删除了resolvconf文件夹和resolv.conf文件/etc。现在,该应用程序已升级,可以解决此问题,但是显示no file named resolv.conf in /etc。它说的正确,因为我删除了这些文件。有什么方法可以重新创建文件或从其他位置还原吗?

Answers:


21

您可以重新安装resolvconf以恢复默认配置:

sudo apt-get install --reinstall resolvconf

另一个想法是删除“ resolvconf”,然后安装:

sudo apt-get remove --purge resolvconf && sudo apt-get install resolvconf

3
放大:为确保resolvconf完全还原,您必须清除它并重新安装,然后重新启动。如果您不清除它而仅将其删除,则它将不会在重新安装时在/etc/resolv.conf中安装符号链接。如果您不重新启动,那么在您重新启动...或重新配置(向下和向上)所有活动接口之前,resolvconf的数据库通常将缺少名称服务器信息。
— jdthood 2012年

这破坏了我的互联网,现在我无法从ubuntu仓库中获取任何软件包。
— thouliha '16

1
这也破坏了互联网,被卸载,重新安装失败,现在我无法更新任何内容。
— CHammond '17

1
如果您发现自己无法获取新软件包,请us.archive.ubuntu.com在另一台计算机上ping通,获取返回的直接IP地址,然后在wget(即:)中使用该IP地址,wget http://91.189.91.26/ubuntu/pool/main/r/resolvconf/resolvconf_1.78ubuntu4_all.deb然后使用dkpg(即:) 安装dpkg -i resolvconf_1.78ubuntu4_all.deb并重新启动。替代方法是将IP放入您的IP中,/etc/hosts以完成更新/安装。
— vandsh

ln:无法删除“ /etc/resolv.conf”:设备或资源繁忙
— 1rq3fea324wre

9

如果resolvconf -u显示的警告/etc/resolv.conf不是符号链接,/run/resolvconf/resolv.conf则只需备份该resolv.conf并建立符号链接:

$ cd /etc
$ sudo ln -s /run/resolvconf/resolv.conf

2
这应该是公认的答案!无法解析主机名时,您将如何重新安装resolvconf?
— Evils'Apr


1

尝试这个:

nano /etc/resolv.conf

加:

nameserver 8.8.8.8

名称服务器192.168.xx(检查ifconfig输出中的正确地址)

然后

sudo service resolvconf start
sudo systemctl enable resolvconf

重新安装resolvconf可能是一个更好的主意
— pim
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.