NAT(Network Address Translation),實現本機系統和虛擬系統的雙向訪問。但網絡內其餘機器不能訪問虛擬系統,虛擬系統可經過本機系統用NAT協議訪問網絡內其餘機器。在VM中由VMnet8提供IP,Gateway和DNS。 shell
[root@rhel6 ~]# vi /etc/resolv.conf # Generated by NetworkManager search local nameserver 192.168.102.2
[root@rhel6 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 TYPE=Ethernet ONBOOT=yes #NM_CONTROLLED=no BOOTPROTO=static #BOOTPROTO=dhcp IPADDR=192.168.102.136 BROADCAST=192.168.102.255 NETMASK=255.255.255.0 HWADDR=00:0C:29:9C:68:3D GATEWAY=192.168.102.2 DNS1=192.168.102.2
[root@rhel6 ~]# /etc/init.d/network restart Shutting down interface eth0: Device state: 3 (disconnected) [ OK ] Shutting down loopback interface: [ OK ] Bringing up loopback interface: [ OK ] Bringing up interface eth0: Active connection state: activated Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/5 [ OK ]
ifconfig 網絡
好處:設置靜態IP有利於採用虛擬機開發和調試。 oop