0


【Ubuntu】sudo apt-get update无法解析域名

问题描述

在ubuntu18.04系统的终端运行命令

sudo apt-get update

报错:无法解析域名“ip”
具体信息如下:
报错信息


原因分析

出现这个问题之前,我尝试使用网络代理

proxy

下载一些外网的资源,按照CSDN的教程创建了一些网络代理环境,但是还是没有成功,然后清除这些配置,但是可能没有清除干净,导致我的

apt

所使用的域名仍然是之前设置的一个海外的ip。


比较奇怪的是,我的网络是没有问题的
网页可以正常打开

ping baidu.com

正常

ping 8.8.8.8

也正常
唯独

sudo apt-get update

报错
无法解析域名“ip”

CSDN上的解决方案基本都试过了

1.添加DNS服务器

sudo gedit /etc/resolv.conf

添加内容

nameserver 114.114.114.114
nameserver 8.8.8.8

无效


2.换源

sudo gedit /etc/apt/sources.list

也无效


解决方案

最终解决:查看这个路径

/etc/apt/apt.conf.d

下有一个这个文件

proxy.conf
cat /etc/apt/apt.conf.d/proxy.conf

显示内容
Acquire {HTTP::proxy “http://ip:88”; HTTPS::proxy “http://ip:88”;}

是这里在设置代理网址的时候填入了

ip

,导致在输入

sudo apt-get update

时报错

无法解析域名“ip"

那么现在要做的就是删除掉这个文件,或者是不让它生效
可以使用如下命令

mv  /etc/apt/apt.conf.d/proxy.conf  /etc/apt/apt.conf.d/proxy.conf.bak

使用

mv

指令,在新的文件路径后面加上

.bak

就相当于把这个文件重命名为bak类型的备份文件了,这样它就不生效了。


再次尝试命令

sudoapt-get update

得到结果

qingliu@QingLiu-Lenovo:~$ sudo apt-get update [sudo] qingliu 的密码: 忽略:1 http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu bionic InRelease
获取:2 http://mirrors.tuna.tsinghua.edu.cn/ros2/ubuntu bionic InRelease
[4,680 B] 命中:3 http://mirrors.aliyun.com/ubuntu
bionic InRelease 命中:4
http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu bionic Release
命中:5 http://mirrors.aliyun.com/ubuntu bionic-updates InRelease
命中:6 http://packages.microsoft.com/repos/code stable InRelease
命中:7 http://mirrors.aliyun.com/ubuntu bionic-backports InRelease
命中:9 http://ppa.launchpad.net/apandada1/brightness-controller/ubuntu
bionic InRelease 命中:10
https://apollo-pkg-beta.cdn.bcebos.com/apollo/core bionic InRelease
命中:11 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu bionic InRelease
命中:12 http://security.ubuntu.com/ubuntu bionic-security InRelease
命中:13 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu bionic
InRelease 命中:14
http://ppa.launchpad.net/oibaf/graphics-drivers/ubuntu bionic
InRelease 命中:15
http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu bionic
InRelease 命中:16
https://nvidia.github.io/libnvidia-container/stable/ubuntu18.04/amd64
InRelease 命中:17
https://nvidia.github.io/nvidia-container-runtime/stable/ubuntu18.04/amd64
InRelease 命中:18
https://nvidia.github.io/nvidia-docker/ubuntu18.04/amd64 InRelease
已下载 4,680 B,耗时 3秒 (1,385 B/s) 正在读取软件包列表… 完成

OK,解决!

标签: ubuntu linux 运维

本文转载自: https://blog.csdn.net/weixin_51200029/article/details/135662039
版权归原作者 清流君 所有, 如有侵权,请联系我们删除。

“【Ubuntu】sudo apt-get update无法解析域名”的评论:

还没有评论