First of all why to connect the net, very simple, because we have to use Yum to install a variety of sources, it is not difficult to put together, said simple is not easy.
Words not much to say, into the subject.
The two network connection modes that we typically use are bridging and NAT
Bridge Connection:
In bridged mode, the Vmeth0 is used by default, and the virtual machine is in the same position as the host computer, and the virtual machine is like a real host on a local area network. So in bridging mode, we're going to configure IP, gateways, subnet masks, and so on, just like other real computers. When we can freely allocate the LAN IP, the bridge mode can be used to virtual a real host. Bridge connection is suitable for routers to surf the internet, relatively simple
Nat:
In NAT mode, the default use of the VMETH8 host computer is equivalent to a DHCP-enabled route, while the virtual machine is a real host in the intranet, with the router (host computer) DHCP dynamically obtain network parameters. Therefore, in NAT mode, the virtual machine can access the external network, and vice versa, because the virtual machine belongs to the intranet.
The general approach:
Then both modes have DHCP service, either way, as long as the IP can be automatically obtained (Dhclient command), the purpose is to obtain a correct IP and gateway
Then modify the configuration file according to the correct IP and gateway that is obtained Vi/etc/sysconfig/network-scripts/ifcfg-eth0
Device=eth0
Onboot=no not self-initiated to =yes
BOOTPROTO=DHCP Change to Static
Ipaddr=ip Address
netmask=255.255.255.0 Subnet Mask
gateway= Gateway
dns1=
dns2=8.8.8.8 can't directly write dns= to take numbers.
Save exit
Restart the NIC
Service Network restart
As far as I know, the IP and gateway obtained in bridge mode is the same as the local physical machine, so the static IP can be configured without automatic acquisition, directly according to local data (view local IP configuration, win+r->cmd->ipconfig, Note Not ifconfig)
But Nat mode is more complex and prone to problems.
1.dhclient can not get IP, then manually set it, according to what settings, VMware Editor-on-top left corner of the virtual network editing, see vmnet8 corresponding network segment, as well as the gateway address, according to the data here to match.
2. Complete the restart NIC when there is a service often failed, then turn this service off and restart it,/etc/init.d/networkmanager stop
3. If not, go to the virtual network editor inside the NAT corresponding to the network card deleted, re-manually add a, try a few network segments
Report:
Dns:
DNS seems to be used to parse the URL, such as you can QQ but not into the Web page, it is likely that the DNS problem
Usually encountered a problem is ping outside the network IP can pass, ping url is unknown
Here I slowly try to know, to dns1= dns2= This can not directly dns= is really obsessive-compulsive killing people ah!
A brief discussion on CentOS network configuration