10 此时可以ping通大功告成
ping通后可以使用如Xshell等 支持SSH协议的工具连接虚拟机,简化操作。
虚拟机上网设置
1 当前模式下,检查能否ping通外网。下面结果说明可以ping通
[root@TESTATEWAY=192 ~]# ping baidu.com
PING baidu.com (220.181.111.86) 56(84) bytes of data.
64 bytes from 220.181.111.86: icmp_seq=1 ttl=128 time=7.75 ms
64 bytes from 220.181.111.86: icmp_seq=2 ttl=128 time=51.3 ms
64 bytes from 220.181.111.86: icmp_seq=3 ttl=128 time=9.57 ms
64 bytes from 220.181.111.86: icmp_seq=4 ttl=128 time=8.38 ms
64 bytes from 220.181.111.86: icmp_seq=5 ttl=128 time=7.39 ms
64 bytes from 220.181.111.86: icmp_seq=6 ttl=128 time=7.83 ms
64 bytes from 220.181.111.86: icmp_seq=7 ttl=128 time=7.16 ms
64 bytes from 220.181.111.86: icmp_seq=8 ttl=128 time=91.2 ms
^C
--- baidu.com ping statistics ---
8 packets transmitted, 8 received, 0% packet loss, time 7194ms
rtt min/avg/max/mdev = 7.163/23.834/91.244/29.166 ms
2 如果是下面结果则说明ping不通外网。返回未知的主机名。
[root@TESTATEWAY=192 ~]# ping baidu.com
ping: unknown host baidu.com
3 如果虚拟机想上外网,则需要修改网卡的配置信息。在文件中加入DNS地址,与网关相同即可。
[root@TESTATEWAY=192 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
BDEVICE=eth0
HWADDR=00:0C:29:7F:EF:4C
TYPE=Ethernet
UUID=34adef05-91e5-4f4a-9776-df983b2a8787
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
NETMASK=255.255.255.0
IPADDR=192.168.84.101
GATEWAY=192.168.84.2
<span>DNS1=192.168.84.2</span>
IPV6INIT=no
ARPCHECK=no
4 重启网络服务,并再次ping外网。发现此时可以ping通外网了。
[root@TESTATEWAY=192 ~]# service network restart
Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: [ OK ]
[root@TESTATEWAY=192 ~]# ping baidu.com
PING baidu.com (220.181.111.86) 56(84) bytes of data.
64 bytes from 220.181.111.86: icmp_seq=1 ttl=128 time=7.64 ms
64 bytes from 220.181.111.86: icmp_seq=2 ttl=128 time=8.44 ms
64 bytes from 220.181.111.86: icmp_seq=3 ttl=128 time=8.43 ms