Three methods for configuring IP address of CentOS 6.5 under virtual machine

  
Experimental software environment: virtual machine Vmware Workstation10.0, CentOS 6.5 32 bit
1, automatically obtain IP address
Virtual machine uses bridge mode, equivalent to connect to In the network of the physical machine, the physical machine network has a DHCP server automatically assigning an IP address.
#dhclient Get the IP address command automatically
#ifconfig Query the network card information in the system, ip address, MAC address
After assigning to the ip address, use the physical machine to ping the ip address and check whether it is pinged.
2, manually set the ip address
If the virtual machine can not automatically obtain the IP, can only be manually configured, the configuration method is as follows:
Enter the command
#vi /etc/sysconfig/network-scripts/ifcfg- Eth0 [Edit NIC configuration file]
Enter the above command and press Enter to open the configuration file. Use the arrow keys to move the cursor to the last line. Press the letter key “O”” to enter the edit mode and 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” this line, change to ONBOOT=yes
“BOOTPROTO=dhcp&rdquo ;, change to BOOTPROTO=none
When finished, press the ESC key in the upper left corner of the keyboard, type: wq to see at the bottom left of the screen, enter Enter to save the configuration file.
After restarting the network service, the command is
#servicenetwork restart
After the network restarts, the ip of eth0 takes effect, use the command #ifconfigeth0 to view
Next, check whether the configured IP can be pinged. In the physical machine, use the shortcut key WINDOWS+R to open the run box, enter the command cmd, enter ping 192.168.4.10
to detect, ping通 indicates that the IP configuration is correct.
Note: The physical network segment where I am located is 192.168.4.0 network segment. When you do the experiment, you can set it according to your own environment, and keep the virtual machine and the physical machine in the same network segment.
3, using NAT mode
Virtual machine network connection using NAT mode, physical machine network connection using Vmnet8.
The virtual machine settings inside —— network adapter, network connection select NAT mode.
Virtual machine menu bar — edit & mdash; virtual network editor, select Vmnet8 NAT mode,
1. Set ip to 192.168.20.0 subnet mask 255.255.255.0 in the bottom subnet 2. NAT settings inside the gateway IP is 192.168.20.2



3. use local DHCP server to assign IP addresses to click apply and exit the virtual machine is not checked
set.
Physical machine network connection VMNet8 Manually set ip address 192.168.20.1 Subnet mask 255.255.255.0
Gateway and DNS address is 192.168.20.2 (that is, gateway address of virtual machine NAT)
Edit linux network card eth0 Configuration file
#vi /etc/sysconfig/network-scripts/ifcfg-eth0
Enter the above command and press Enter to open the configuration file. Use the arrow keys to move the cursor to the last line and press the letter key “O”, Enter edit mode and 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” this line, change to ONBOOT=yes
“BOOTPROTO=dhcp”, change to BOOTPROTO=none
When finished, press the ESC key in the upper left corner of the keyboard, type: wq to see at the bottom left of the screen, enter Enter to save the configuration file .
Set the DNS address, run the command #vi /etc/resolv.conf
Move the cursor to the blank line, press the ““O” key, enter the nameserver 192.168.20.2 and press the ESC key. Enter: wq Enter to save the configuration. file.
Restart Network Service
#service network restart
After restarting #ifconfig View the configured IP address, and the physical machine pings this address to test whether it can pass.

Copyright © Windows knowledge All Rights Reserved