一、打開虛擬機設置,配置網絡連接,如下圖
二、編輯 /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