Set vm virtual machine centos make a successful connection to external networks Comments

First talk about two kinds of connection mode virtual machine
NAT mode and bridge mode.
Direct use of the vernacular, so as not to be puzzled

Bridge mode is that you can directly connect to the network current physical host, but you need the current set ip address and physical host in the same network segment

NAT mode is that you can set up the virtual machine and the gateway ip address so a series of content, then you can assign ip address of another segment to you directly through the DHCP function, although you are not the same network segment and the host, but the virtual machine has a routing function, when you access the Internet will automatically convert your ip so you can access the Internet

First try to connect to external networks NAT mode

1. First, the network adapter is set to NAT
Here Insert Picture Description
2. Click -> Edit -> Virtual Network Editor -> lower right corner to change the settings -> VMnet8 to the following
Here Insert Picture Description3. Click the NAT settings would read as follows
Here Insert Picture Description4. Configure good above must go to take a look at the network connection ip address VMnet8 species is not and you set the same, if not the same modify this ip address.
Here Insert Picture Description
5. You can then open the virtual machine, enter the command line static address configuration of the virtual machine and modify the host name

cd /etc/sysconfig/network-scripts/
sudo vim ifcfg-eth0

Modify the contents of the following

DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=static
NAME="eth0"
IPADDR=192.168.1.99
PREFIX=24
GATEWAY=192.168.1.2
DNS1=192.168.1.2

Modify the host name

vim /etc/sysconfig/network

Modifications are as follows

NETWORKING=yes
HOSTNAME=yunwei100

Enter the following commands to restart the virtual machine 5. Command Line

reboot

Then win the command line
Here Insert Picture Description
in a virtual models to test whether you can connect outside the network
Here Insert Picture Description
if there is no ping through carefully check whether the above steps did the right thing.

Then try to connect to external networks bridge mode

It will be set before turning on the virtual machine as a bridge
and then the fifth step replaced by the following content types, and then something set ip address, subnet mask and gateway deleted directly, you can use dhcp ip automatically set for a virtual machine

BOOTPROTO=auto

Then in the virtual machine can test

ping www.baidu,com

Currently not tried bridging set a static ip, you can try.

Published 66 original articles · won praise 44 · views 10000 +

Guess you like

Origin blog.csdn.net/qq_42584411/article/details/104482262