一、打开虚拟机设置,配置网络连接,如下图
二、编辑 /etc/sysconfig/network,以配置网关
vim /etc/sysconfig/network
NETWORKING=yes HOSTNAME=mylinux03 #添加网关 GATEWAY=192.168.26.2
三、编辑 /etc/sysconfig/network-scripts/ifcfg-eth0,以配置IP
vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 TYPE=Ethernet UUID=7fa84877-75e9-4d0d-9e54-cdcd288dbc49 ONBOOT=yes NM_CONTROLLED=no # yes改为no BOOTPROTO=static # dhcp改为static HWADDR=00:0C:29:BF:EB:97 DEFROUTE=yes PEERDNS=yes PEERROUTES=yes IPV4_FAILURE_FATAL=yes IPV6INIT=no NAME="System eth0" #添加IP、子网掩码、网关、DNS1 配置 IPADDR=192.168.26.12 NETMASK=255.255.255.0 GATEWAY=192.168.26.2 DNS1=192.168.26.2
四、重启服务
service network restart
参考:http://blog.csdn.net/jack85986370/article/details/51009053