搭建编译环境的时候,安装g++出现了如下的报错:
Do you want to continue? [Y/n] y
Err:1 http://cn.archive.ubuntu/ubuntu xenial/main amd64 libmpc3 amd64 1.0.3-1
Temporary failure resolving 'cn.archive.ubuntu'
Err:2 http://cn.archive.ubuntu/ubuntu xenial-updates/main amd64 binutils amd64 2.26.1-1ubuntu1~16.04.7
Temporary failure resolving 'cn.archive.ubuntu'
Err:3 http://cn.archive.ubuntu/ubuntu xenial/main amd64 libisl15 amd64 0.16.1-1
Temporary failure resolving 'cn.archive.ubuntu'
......
看上去是不能resolve这个域名:cn.archive.ubuntu。
顺手nslookup www.baidu
果然
openwrt@ubuntu:~$ curl -v www.baidu
* Rebuilt URL to: www.baidu/
* Could not resolve host: www.baidu
* Closing connection 0
curl: (6) Could not resolve host: www.baidu
给的服务器dns都木有配,醉了
自己来
root@ubuntu:~# vi /etc/resolv.conf
# 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
nameserver x.x.x.x
nameserver 114.114.114.114
nameserver 8.8.8.8
在/etc/resolv.conf添加对应的域名解析服务器,上面的x.x.x.x是公司内网的dns服务器,这里用x代替了,114和8这两个服务器是公网的。
修改完,再试
root@ubuntu:~# apt-get install g++
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
binutils cpp cpp-5 g++-5 gcc gcc-5 libasan2 libatomic1 libc-dev-bin libc6-dev libcc1-0 libcilkrts5 libgcc-5-dev libgomp1 libisl15 libitm1 liblsan0 libmpc3 libmpx0 libquadmath0
libstdc++-5-dev libtsan0 libubsan0 linux-libc-dev manpages-dev
Suggested packages:
binutils-doc cpp-doc gcc-5-locales g++-multilib g++-5-multilib gcc-5-doc libstdc++6-5-dbg gcc-multilib make autoconf automake libtool flex bison gdb gcc-doc gcc-5-multilib
libgcc1-dbg libgomp1-dbg libitm1-dbg libatomic1-dbg libasan2-dbg liblsan0-dbg libtsan0-dbg libubsan0-dbg libcilkrts5-dbg libmpx0-dbg libquadmath0-dbg glibc-doc libstdc++-5-doc
The following NEW packages will be installed:
binutils cpp cpp-5 g++ g++-5 gcc gcc-5 libasan2 libatomic1 libc-dev-bin libc6-dev libcc1-0 libcilkrts5 libgcc-5-dev libgomp1 libisl15 libitm1 liblsan0 libmpc3 libmpx0
libquadmath0 libstdc++-5-dev libtsan0 libubsan0 linux-libc-dev manpages-dev
0 upgraded, 26 newly installed, 0 to remove and 10 not upgraded.
Need to get 37.0 MB of archives.
After this operation, 139 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://cn.archive.ubuntu/ubuntu xenial/main amd64 libmpc3 amd64 1.0.3-1 [39.7 kB]
Get:2 http://cn.archive.ubuntu/ubuntu xenial-updates/main amd64 binutils amd64 2.26.1-1ubuntu1~16.04.7 [2,309 kB]
Get:3 http://cn.archive.ubuntu/ubuntu xenial/main amd64 libisl15 amd64 0.16.1-1 [524 kB]
Get:4 http://cn.archive.ubuntu/ubuntu xenial-updates/main amd64 cpp-5 amd64 5.4.0-6ubuntu1~16.04.11 [7,660 kB]
......
这样改了是能够解决当时更新的问题,但是我们在更新/etc/resolv.conf 的时候看到里面有这样一句提示:
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
所以设备一旦重启,配置就会被重写,如果想彻底改变,有两种方法:
1 修改/etc/network/interfaces,在最后添加:
dns-nameservers x.x.x.x
dns-nameservers 114.114.114.114
dns-nameservers 8.8.8.8
重启网络就可以了。
2 修改/etc/resolvconf/resolv.conf.d/base,在里面添加:
nameserver 10.1.1.4
nameserver 114.114.114.114
nameserver 8.8.8.8
然后
resolvconf -u
使其生效。
更多推荐
Ubuntu apt-get install出现“Temporary failure resolving 'cn.archive.ubuntu.com
发布评论