CentOS7.x以上版本配置DNS失效解决办法
生活随笔
收集整理的這篇文章主要介紹了
CentOS7.x以上版本配置DNS失效解决办法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
這2周做實驗,centos7.x經常出現yum安裝軟件包的時候找不到解析地址,提示如下錯誤
正在嘗試其它鏡像。Error downloading packages: pam-devel-1.1.8-22.el7.x86_64: [Errno 256] No more mirrors to try. libcom_err-1.42.9-12.el7_5.x86_64: [Errno 256] No more mirrors to try. keyutils-libs-devel-1.5.8-3.el7.x86_64: [Errno 256] No more mirrors to try. libverto-devel-0.2.5-4.el7.x86_64: [Errno 256] No more mirrors to try. e2fsprogs-1.42.9-12.el7_5.x86_64: [Errno 256] No more mirrors to try. pcre-devel-8.32-17.el7.x86_64: [Errno 256] No more mirrors to try. krb5-devel-1.15.1-19.el7.x86_64: [Errno 256] No more mirrors to try. libcom_err-devel-1.42.9-12.el7_5.x86_64: [Errno 256] No more mirrors to try. lzo-devel-2.06-8.el7.x86_64: [Errno 256] No more mirrors to try. krb5-libs-1.15.1-19.el7.x86_64: [Errno 256] No more mirrors to try. zlib-devel-1.2.7-17.el7.x86_64: [Errno 256] No more mirrors to try. libsepol-devel-2.5-8.1.el7.x86_64: [Errno 256] No more mirrors to try. ▽libss-1.42.9-12.el7_5.x86_64: [Errno 256] No more mirrors to try. libselinux-devel-2.5-12.el7.x86_64: [Errno 256] No more mirrors to try. 1:openssl-devel-1.0.2k-12.el7.x86_64: [Errno 256] No more mirrors to try. e2fsprogs-libs-1.42.9-12.el7_5.x86_64: [Errno 256] No more mirrors to try. libkadm5-1.15.1-19.el7.x86_64: [Errno 256] No more mirrors to try. lzo-minilzo-2.06-8.el7.x86_64: [Errno 256] No more mirrors to try.查看 /etc/resolv.conf 中DNS配置,竟然為空,之前明明配置好了的,真是奇怪,難怪不行
[root@opvnserver ~]# cat /etc/resolv.conf # Generated by NetworkManager #<==啥也沒有百度和Google了一下,NetworkManager與network可能會出現沖突的情況,由于做實驗要添加網卡,重啟服務,于是重新配置好DNS文件
[root@opvnserver ~]# cat /etc/resolv.conf # Generated by NetworkManager nameserver 202.96.128.86 nameserver 202.96.128.166然后關閉NetworkManager,這樣就不會出現之前的情況了,重新yum安裝軟件也正常了
[root@opvnserver ~]# systemctl stop NetworkManager [root@opvnserver ~]# systemctl disable NetworkManager [root@opvnserver ~]# systemctl restart network更好的方法:在網卡配置文件中添加DNS地址,格式如下:
[root@opvnserver ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 TYPE=Ethernet BOOTPROTO=static DEFROUTE=yes IPV4_FAILURE_FATAL=no NAME=eth0 DEVICE=eth0 ONBOOT=yes IPADDR=10.0.0.3 GATEWAY=10.0.0.254 NETMASK=255.255.255.0 DNS1=202.96.128.86 DNS2=202.96.128.166注意:在centos7.x 中,DNS不在 /etc/resolv.conf 中配置了,而是直接在網卡配置文件中配置DNS,這和centos6.x版本有點區別,真是無語,改來改去,呵呵!
?
轉載于:https://www.cnblogs.com/blog-tim/p/10316176.html
總結
以上是生活随笔為你收集整理的CentOS7.x以上版本配置DNS失效解决办法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux系统下对磁盘的命名原则?
- 下一篇: 出现$ref的原因及解决方案