Network Configuration after centOS is installed on the VM

Source: Internet
Author: User

The network configuration after centOS is installed on the VM took some time to study the network configuration of the linux virtual machine on the VM. 1. Environment HOST: winXP SP2, home broadband, LAN connected to the router, IP Address: 192.168.1.101. Virtual Machine: centOS (open-source free version of redhat linux), in plain text mode. After CentOS is installed on the VM, two more network connections are added to the Host: VMNet1 and vmnet8. Each network connection has an IP address and subnet mask. VMNet1: 192.168.229.1/255.255.255.0VMNet8: 192.168.30.1/255.255.255.0 2. Next, we want centOS to access the Internet. At first, set the network connection in the VM to briged. After centOS is started, run the ifconfig command to find that the eth0 IP address is set to the IP address of the same network segment as the host: 192.168.1.102. In addition, ssh can be used to connect to centOS, but the host and www.baidu.com cannot be pinged on centOS. Check the configuration file and find that the router on centOS is the host's router, and the dns is also the host's dns. In order to use briged to access the Internet, Baidu has a lot of information and it is useless to try it out. You can't change it to the NAT mode. After restarting, you will find that you can access the Internet. At the same time, it seems faster to use ssh to connect to centOS. After changing to NAT, run the ifconfig command to find that the IP address of centOS is 192.168.30.128 in VMnet8. DNS also becomes 192.168.30.2 under VMnet8. According to the information on the Internet, briged is a physical network card that is directly connected to the machine. In this case, the centOS virtual machine is equivalent to a machine in the same LAN as the host. However, if you use NAT to access the Internet, the relationship between centOS and the host is client/server. The host provides VMnet8 to centOS. For centOS, VMnet8 is equivalent to a gateway or router, while centOS is equivalent to a machine in the LAN in which VMnet8 is responsible. The nat process is as follows: 1. VMware network connection uses the NAT architecture. 2. Check VMnet8 In the NAT entry in the VMware network settings, and set the NAT gateway to 192.168.X.2. 3. In windows, check all network connections. In addition to the original Nic, you should find Vmnet1 and vmnet8. Vmnet1 is the hostonly interface, while Vmnet8 is the NAT Network Interface we want to apply. 4. Use ipconfig on a windows host to view the VMnet8 IP address, usually 192.168.X.1. At this time, VMnet8 should be set to AUTO to get the IP address. Now it is changed to a static IP address, and this IP address is directly entered in VMnet8 without a gateway. 5. In linux, set the nic ip address to the IP address (192.168.X.Y/255.255.255.0) of the same network segment as vmnet8. set the Host Name (open the/etc/sysconfig/network file in the vi Editor) and set/etc/sysconfig/network # vi/etc/sysconfig/networkNETWORKING = yes <= whether to start the network, of course! HOSTNAME = localhost <= Host Name. Be sure! You can modify it at any time! GATEWAY = 192.168.X.2 7. Set Nic parameters (open the/etc/sysconfig/network-scripts/ifcfg-eth0 file in the vi editor) set network card parameters/etc/sysconfig/network-scripts/ifcfg-eth0 # vi/etc/sysconfig/network-scripts/ifcfg-eth0DEVICE = eth0 <= set device name, this must correspond to the file name! ONBOOT = yes <= whether to enable the network card BOOTPROTO = dhcp <= The protocol obtained by the IP address at startup, static is fixed, if it is Cable, change it to dhcp. 8. Set DNS (Open/etc/resolv In the vi editor. conf file) [root @ hostname root] # vi/etc/resolv. conf vi/etc/resolv. confnameserver 192.168.X.2 9. Restart the network configuration [root @ hostname root] # reboot // restart [root @ hostname root] # ifconfig // check that centos has been automatically assigned ip address 192.168.X.Z service network restart // restart the gateway 10. ping 192.168.x.1 in linux, after successfully ping 192.168.x.z in windows, it is confirmed that the host and the virtual machine can access each other. At this moment, the virtual machine can share the ip address of the host to access the Internet.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.