為什么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
今日源碼
參考