|
Experimental Software Environment: Virtual Machine VMware Workstation10.0, CentOS 6.5 32-bit client Windows 7
1, automatically obtain IP address
Virtual machines using bridged mode, the equivalent of a physical machine connected to the network, the physical machine network DHCP server automatically assigns IP addresses.
#dhclient automatically obtain ip address command
#ifconfig card information inquiry system, ip address, MAC address
After assigned to ip address, physical machines ping ip address to check whether the ping.
2, manually set ip address
If the virtual machine does not automatically obtain IP, only manual configuration, configuration is as follows:
Enter the command
#vi / etc / sysconfig / network-scripts / ifcfg-eth0
NIC configuration file editing
After entering the above command carriage return, open the configuration file, use the arrow keys to move the cursor to the last line, press the letter key "O", enter edit mode, enter the following:
IPADDR = 192.168.4.10
NETMASK = 255.255.255.0
GATEWAY = 192.168.4.1
Also move the cursor to "ONBOOT = no" line, change to ONBOOT = yes
"BOOTPROTO = dhcp", change the BOOTPROTO = none
When finished, click the top left corner of the keyboard ESC key, enter: wq can be seen in the bottom left of the screen, press enter to save the configuration file.
After the need to restart the network service, the command is
#service network restart
After restarting the network, eth0 the ip to become effective, use the command # ifconfigeth0 View
Next, test the configured IP to ping in the physical machine using the shortcut keys WINDOWS + R to open the Run box, enter the command cmd, enter ping 192.168.4.10 is detected, the ping Description IP is configured correctly.
Note: Our physical machine where the network segment 192.168.4.0 network segment. When we do the experiment according to their own environment settings, maintaining virtual and physical machines in the same segment.
3, using NAT mode
Virtual machine network connection using NAT mode, the physical network connection Vmnet8.
Inside the virtual machine settings - network adapters, network connectivity options NAT mode.
Virtual Machine menu bar - Edit - Virtual Network Editor, select Vmnet8 NAT mode,
1. In the bottom of the set ip subnet to subnet mask 255.255.255.0 192.168.20.0
2. NAT is set up inside the gateway IP 192.168.20.2
3. Use local DHCP service to assign IP addresses to the virtual machine is not checked
After setting Click Apply to exit.
Physical network connection VMNet8 manually set ip address 192.168.20.1 subnet mask of 255.255.255.0
Gateway and DNS addresses 192.168.20.2 (ie, virtual machine NAT gateway address)
Edit linux network card eth0 configuration file
#vi / etc / sysconfig / network-scripts / ifcfg-eth0
After entering the above command carriage return, open the configuration file, use the arrow keys to move the cursor to the last line, press the letter key "O", enter edit mode, enter the following:
IPADDR = 192.168.20.3
NETMASK = 255.255.255.0
GATEWAY = 192.168.20.2
Also move the cursor to "ONBOOT = no" line, change to ONBOOT = yes
"BOOTPROTO = dhcp", change the BOOTPROTO = none
When finished, click the top left corner of the keyboard ESC key, enter: wq can be seen in the bottom left of the screen, press enter to save the configuration file.
DNS address settings, run the command
#vi /etc/resolv.conf
Move the cursor to an empty line, press the "O" key, enter the nameserver 192.168.20.2 exit press the ESC key, enter: wq Enter to save the configuration file.
Network Service Restart
#service network restart
After the restart
#ifconfig
Check configure ip address, physical address ping test whether this can pass. |
|
|
|