Virtual machines using Oracle Vitualbox
PS: Virtual machine network settings use "Bridge"
One, configure IP
#vi/etc/sysconfig/network-scripts/ifcfg-eth0
Device=eth0 #物理设备名
ipaddr=192.168.2.200 #IP地址
netmask=255.255.255.0 #掩码值
gateway=192.168.2.1 #网关地址
Onboot=yes # [Yes|no] (whether the device is activated at boot time)
Userctl=no #[yes|no] (whether the device can be controlled by a non-root user)
Bootproto=static #[none|static|bootp|dhcp] (non-use protocol at boot | static Assignment | BOOTP protocol | DHCP protocol)
Second, configure the gateway
Vi/etc/sysconfig/network
Networking=yes (Indicates whether the system uses a network and is generally set to Yes.) If set to no, the network cannot be used, and many system services programs will not start.
Hostname=localhost.localmain (Set the hostname of this machine, the host name set here should correspond to the hostname set in/etc/hosts)
gateway=192.168.2.1
Third, modify the DNS
#vi/etc/resolv.conf
NameServer 8.8.8.8 #google域名服务器
NameServer 8.8.4.4 #google域名服务器
At last
#service Network Restart
CentOS Configuration Nic