Lab software environment: Virtual Machine VmwareWorkstation10.0, CentOS6.532 bit 1. automatic IP address acquisition: the virtual machine uses the bridge mode. this is equivalent to connecting to the network of the physical machine. the physical machine network has a DHCP server automatically assigned IP address. # Dhclient automatic IP address acquisition command # Nic information in ifconfig query system
Experimental software environment: Virtual Machine Vmware Workstation10.0, CentOS 6.5 32-bit
1. automatically obtain the IP address
The virtual machine uses the bridge mode, which is equivalent to connecting to the network of the physical machine. the physical machine network has a DHCP server automatically assigned an IP address.
# Dhclient command for automatically obtaining IP addresses
# Nic information, IP address, and MAC address in the ifconfig query system
After the IP address is assigned, ping the IP address on the physical machine to check whether the ping is successful.
2. manually set IP addresses
If the virtual machine cannot automatically obtain the IP address, you can only manually configure it as follows:
Enter the command
# Vi/etc/sysconfig/network-scripts/ifcfg-eth0 [edit Nic configuration file]
Enter the preceding command and press enter to open the configuration file. use the arrow key to move the cursor to the last line. press "O" to enter the editing mode. enter the following content:
IPADDR = 192.168.4.10
NETMASK = 255.255.255.0
GATEWAY = 192.168.4.1
In addition, move the cursor to the line "ONBOOT = no" and change it to ONBOOT = yes.
"BOOTPROTO = dhcp", changed to BOOTPROTO = none
After that, press the ESC key in the upper left corner of the keyboard. enter wq in the lower left corner of the screen and press enter to save the configuration file.
Restart the network service. The command is
# Servicenetwork restart
After the network is restarted, the ip address of eth0 takes effect. run the command # ifconfigeth0 to view
Next, check whether the configured IP address can be pinged. on the physical machine, use the shortcut key WINDOWS + R to open the Run box, enter the command cmd, and enter ping 192.168.4.10. ping indicates that the IP address is correctly configured.
Note: The network segment of my physical machine is 192.168.4.0. During the experiment, you can set up your own environment to keep the virtual machine and the physical machine in the same network segment.
3. use NAT mode
The virtual machine network connection uses the NAT mode, and the physical machine network connection uses vmnet8.
In virtual machine settings-network adapter, select NAT mode for network connection.
Choose VM menu bar-edit-virtual network editor and select Vmnet8 NAT mode,
1. set the ip address to 192.168.20.0 subnet mask 255.255.255.0 in the bottom subnet.
2. in the NAT settings, the gateway IP address is 192.168.20.2.
3. using the local DHCP service to allocate IP addresses to virtual machines is not checked
After the settings are complete, click the application to exit.
Physical machine network connection VMNet8 manual setting IP address 192.168.20.1 subnet mask 255.255.255.0
The gateway and DNS address are 192.168.20.2 (that is, the gateway address of the virtual machine NAT)
Edit the configuration file of the linux Nic eth0
# Vi/etc/sysconfig/network-scripts/ifcfg-eth0
Enter the preceding command and press enter to open the configuration file. use the arrow key to move the cursor to the last line. press "O" to enter the editing mode. enter the following content:
IPADDR = 192.168.20.3
NETMASK = 255.255.255.0
GATEWAY = 192.168.20.2
In addition, move the cursor to the line "ONBOOT = no" and change it to ONBOOT = yes.
"BOOTPROTO = dhcp", changed to BOOTPROTO = none
After that, press the ESC key in the upper left corner of the keyboard. enter wq in the lower left corner of the screen and press enter to save the configuration file.
Set the DNS address and run the command # vi/etc/resolv. conf.
Move the cursor to the blank line, press "O", enter nameserver 192.168.20.2, and press ESC, and enter: wq press enter to save the configuration file.
Restart the network service # service network restart
After the instance is restarted, check the configured IP address in ifconfig. ping the IP address on the physical machine to test whether the IP address can be accessed.