yum不能正常动作,惯性认为是需要替换BaseURL,结果后来才发现是Gateway不知什么时候被错误设定了,memo如下。
现象
表现于yum不能正常动作,确认ping的操作,发现是不能解析DNS
[[email protected] ~]# ping www.baidu.com
^C 长时间等待 ctrl + C退出
[[email protected] ~]#
确认DNS设定
[[email protected] ~]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 8.8.8.8
nameserver 8.8.4.4
[[email protected] ~]#
DNS正常设定,表明问题更加基础,应该在于网络完全没有被正确设定。果然8.8.8.8无法ping通
[[email protected] ~]# ping -w1 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
--- 8.8.8.8 ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms
[[email protected] ~]#
自身连接确认没有问题
[[email protected] ~]# ping -w1 192.168.32.123
PING 192.168.32.123 (192.168.32.123) 56(84) bytes of data.
64 bytes from 192.168.32.123: icmp_seq=1 ttl=64 time=0.023 ms
64 bytes from 192.168.32.123: icmp_seq=2 ttl=64 time=0.059 ms
- -- 192.168.32.123 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.023/0.041/0.059/0.018 ms
[[email protected] ~]#
网关连接确认
PING 192.168.32.2 (192.168.32.2) 56(84) bytes of data.
64 bytes from 192.168.32.2: icmp_seq=1 ttl=128 time=0.334 ms
--- 192.168.32.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.334/0.334/0.334/0.000 ms
[[email protected] ~]#
ip addr
ip addr确认网络状况,状态如下
[[email protected] ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:9d:48:21 brd ff:ff:ff:ff:ff:ff
inet 192.168.32.123/24 brd 192.168.32.255 scope global eno16777736
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe9d:4821/64 scope link
valid_lft forever preferred_lft forever
[[email protected] ~]#
设定确认
CentOS和RHEL的网络设定文件都位于/etc/sysconfig/network-scripts下,当前设定确认如下:
[[email protected] ~]# cat /etc/sysconfig/network-scripts/ifcfg-eno16777736
TYPE="Ethernet"
BOOTPROTO="none"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
NAME="eno16777736"
UUID="56975740-33eb-4306-9ecf-f7d62745c3a0"
DEVICE="eno16777736"
ONBOOT="yes"
IPADDR="192.168.32.123"
PREFIX="24"
GATEWAY="192.168.32.31"
DNS1="8.8.8.8"
DNS2="8.8.4.4"
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
IPV6_PRIVACY="no"
[[email protected] ~]#
立即确认出GATEWAY设定有误
对应方式
修正后重启即可
修正
[[email protected] ~]# diff /etc/sysconfig/network-scripts/ifcfg-eno16777736 /etc/sysconfig/network-scripts/ifcfg-eno16777736.bak
15c15
< GATEWAY="192.168.32.2"
---
> GATEWAY="192.168.32.31"
[[email protected] ~]#
ifdown
[root@liumiaocn ~]#
[root@liumiaocn ~]# ifdown eno16777736
ifup
如果ifdown是使用终端来做的话,此条命令执行之后自然会关掉当前终端,在能够直接连接地方使用ifup启动即可
结果确认
重新通过终端连接,确认结果, 可以正常动作了
PING www.a.shifen.com (14.215.177.37) 56(84) bytes of data.
64 bytes from 14.215.177.37: icmp_seq=1 ttl=128 time=164 ms
--- www.a.shifen.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 164.538/164.538/164.538/0.000 ms
[[email protected] ~]#
[[email protected] ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:9d:48:21 brd ff:ff:ff:ff:ff:ff
inet 192.168.32.123/24 brd 192.168.32.255 scope global eno16777736
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe9d:4821/64 scope link
valid_lft forever preferred_lft forever
[[email protected] ~]#
总结
超级简单的一个问题,但却是头疼医脚的结果。RCA告诉我们,问题出现的地方,并不一定是需要动刀的地方,经验主义经常会浪费掉我们宝贵的时间。
原文链接:https://blog.csdn.net/liumiaocn/article/details/60467892
原文地址:https://www.cnblogs.com/isme-zjh/p/11448132.html