Virtual machine networking configuration

First select the bridge mode for the virtual machine



find the network card


配置 vi /etc/sysconfig/network-scripts/ifcfg-eth0

Edit or add ( Let the IP address of the virtual machine and the host address be in the same segment, and the rest of the information such as subnet mask, gateway and other information can be the same as the host. )

NETMASK=255.255.255.0
IPADDR=192.168.0.104
GATEWAY=192.168.0.1 (gateway)
BROADCAST=192.168.0.2 (broadcast address)

BOOTPROTO=static (static IP)

reference physical machine

Physical machine: cmd -> ipconfig


Next restart the network service service network restart   

In this way, the virtual machine and the physical machine can be pinged.

Next, configure the virtual machine to ping the external network

Set DNS: vim /etc/resolv.conf  After opening the file, directly add or change DNS1 and DNS2 to the following two lines of code,

  nameserver 8.8.8.8

  nameserver 8.8.4.4

 Then, check the routing table netstat -rn , if the routing table does not set Gateway, add the gateway as follows (the gateway IP corresponds to the local area network where the local computer is located)  Route IP):

 route add default gw 192.168.0.1

 Finally, restart the network service, service network restart

 try to  ping www.baidu.com



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324853630&siteId=291194637