Failed to fetch http://mirrors.aliyun.com/debian/dists/wheezy/InRelease Temporary failure resolving

我要安装nginx的时候,在下载阿里云的yum源的时候,执行这条命令

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

的时候,一直报错

Resolving mirrors.aliyun.com (mirrors.aliyun.com)... failed: Name or service

然后百度查了一下,按照那个人教的
1.打开/etc/resolv.conf;

$sudo vim /etc/resolv.conf

2.修改nameserver后的ip地址;

加入:

nameserver 8.8.8.8
nameserver 8.8.4.4

3.重起网卡;

sudo /etc/init.d/networking restart

我醉了,根本没用,后来使用命令

cd /etc/sysconfig/network-scripts

编辑ifcfg-ens33文件,

vi ifcfg-ens33

在里面找的DNS这些东西,没有的话添加上

dns1=114.114.114.114  
dns2=223.5.5.5 
dns3=8.8.8.8

然后重启虚拟机reboot,还是没用

1 然后我再检查配置文件有没有问题

cat /etc/sysconfig/network-scripts/ifcfg-ens33

2 可能与NetworkManager服务有冲突,直接关闭该服务即可,再重启

systemctl stop NetworkManager
systemctl restart network

3 若1、2两种方法查验后仍然不行,可尝试将/etc/sysconfig/network-scripts下,将其余无关的网卡位置文件全删掉,避免不必要的影响

[root@db01 network-scripts]# ls
ifcfg-ens33      ifdown-ipv6      ifdown-tunnel  ifup-isdn    ifup-TeamPort
ifcfg-ens33.bak  ifdown-isdn      ifup           ifup-plip    ifup-tunnel
ifcfg-lo         ifdown-post      ifup-aliases   ifup-plusb   ifup-wireless
ifdown           ifdown-ppp       ifup-bnep      ifup-post    init.ipv6-global
ifdown-bnep      ifdown-routes    ifup-eth       ifup-ppp     network-functions
ifdown-eth       ifdown-sit       ifup-ib        ifup-routes  network-functions-ipv6
ifdown-ib        ifdown-Team      ifup-ippp      ifup-sit
ifdown-ippp      ifdown-TeamPort  ifup-ipv6      ifup-Team

[root@db01 network-scripts]# rm -r /etc/sysconfig/network-scripts

然后再用ifconfig看看机器的IP地址是否出现,刚才我用ifconfig,在ens33那里是看不到我的IP地址的,是没有的。现在ip地址出现了
说明网络应该通了,

[root@192 yum.repos.d]# ifconfig -a
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.137.128  netmask 255.255.255.0  broadcast 192.168.137.255
        inet6 fe80::20c:29ff:fefb:544c  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:fb:54:4c  txqueuelen 1000  (Ethernet)
        RX packets 39285  bytes 43633247 (41.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 17882  bytes 1683057 (1.6 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 248  bytes 760742 (742.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 248  bytes 760742 (742.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:0d:34:ee  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0-nic: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether 52:54:00:0d:34:ee  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

再ping一下百度网吧,看看好了没

ping www.baidu.com
PING www.a.shifen.com (180.101.50.188) 56(84) bytes of data.
64 bytes from 180.101.50.188 (180.101.50.188): icmp_seq=1 ttl=128 time=14.4 ms
64 bytes from 180.101.50.188 (180.101.50.188): icmp_seq=2 ttl=128 time=12.7 ms
64 bytes from 180.101.50.188 (180.101.50.188): icmp_seq=3 ttl=128 time=15.8 ms
64 bytes from 180.101.50.188 (180.101.50.188): icmp_seq=4 ttl=128 time=13.6 ms

好了。

然后执行

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

成功了

  • 7
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值