为什么Ping这个IP地址Ping得通
本地址
[root@localhost network-scripts]# cat ifcfg-ens33
iTYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
DEVICE=ens33
ONBOOT=no
IPADDR=192.168.235.4
NETMASK=255.255.255.0
GATEWAY=192.168.235.2
DNS1=114.114.114.114
[root@localhost network-scripts]# service network restart
Restarting network (via systemctl): [ 确定 ]
[root@localhost network-scripts]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
[root@localhost network-scripts]# ifup ens33
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/6)
[root@localhost network-scripts]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.235.2 0.0.0.0 UG 100 0 0 ens33
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
192.168.235.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33
[root@localhost network-scripts]# ping 192.168.235.2
PING 192.168.235.2 (192.168.235.2) 56(84) bytes of data.
64 bytes from 192.168.235.2: icmp_seq=1 ttl=128 time=0.646 ms
64 bytes from 192.168.235.2: icmp_seq=2 ttl=128 time=0.232 ms
64 bytes from 192.168.235.2: icmp_seq=3 ttl=128 time=0.210 ms
^C
— 192.168.235.2 ping statistics —
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.210/0.362/0.646/0.201 ms
[root@localhost network-scripts]# cat ifcfg-ens33
iTYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
DEVICE=ens33
ONBOOT=no
IPADDR=192.168.235.4
NETMASK=255.255.255.0
GATEWAY=192.168.235.2
DNS1=114.114.114.114
[root@localhost network-scripts]# ping www.baidu.com
PING www.baidu.com (223.109.82.212) 56(84) bytes of data.
64 bytes from 223.109.82.212 (223.109.82.212): icmp_seq=1 ttl=128 time=16.5 ms
64 bytes from 223.109.82.212 (223.109.82.212): icmp_seq=2 ttl=128 time=15.6 ms
64 bytes from 223.109.82.212 (223.109.82.212): icmp_seq=3 ttl=128 time=16.6 ms
64 bytes from 223.109.82.212 (223.109.82.212): icmp_seq=4 ttl=128 time=15.6 ms
^C
— www.baidu.com ping statistics —
4 packets transmitted, 4 received, 0% packet loss, time 12034ms
rtt min/avg/max/mdev = 15.616/16.114/16.618/0.496 ms
[root@localhost network-scripts]# vim ifcfg-ens33
[root@localhost network-scripts]# cat ifcfg-ens33
iTYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
DEVICE=ens33
ONBOOT=no
IPADDR=192.168.235.3
NETMASK=255.255.255.0
GATEWAY=192.168.235.254
DNS1=114.114.114.114
[root@localhost network-scripts]# service network restart
Restarting network (via systemctl): [ 确定 ]
[root@localhost network-scripts]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
[root@localhost network-scripts]# ifup ens33
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/7)
[root@localhost network-scripts]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.235.254 0.0.0.0 UG 100 0 0 ens33
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
192.168.235.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33
[root@localhost network-scripts]# ping 192.168.235.254
PING 192.168.235.254 (192.168.235.254) 56(84) bytes of data.
^C
— 192.168.235.254 ping statistics —
26 packets transmitted, 0 received, 100% packet loss, time 24999ms 为啥我网关换成192.168.254就Ping不通了
应该就是这里了 默认网关是192.168.235.2
修改成192.168.234.254试一下
通了
在配虚拟机静态地址时 若ping不通外界地址 需看下虚拟地址编辑器内默认网关是多少 静态地址网关需与默认网关一致
OK 双网卡双卡双待 该虚拟机能Ping通外网
在准备配个RealServer就准备休息了
realserver
今日源码
参考