Home > OS >  A great god taught: virtual machine CentOS 7 can ping the host, but can't outside the network,
A great god taught: virtual machine CentOS 7 can ping the host, but can't outside the network,

Time:09-29

A great god taught:
Virtual machine CentOS 7 can ping the host, but can't outside the network, such as baidu, what should I do?

CodePudding user response:

Can ping local LAN host, if can't ping the network can consider sticking out of the network devices banned icmp packet

CodePudding user response:

host can I surf the Internet host, please check the network adapter configuration

CodePudding user response:

refer to the second floor weixin_45480856 response:
host can I surf the Internet host access, please check the network adapter configuration

The host is normal, do not have what problem

CodePudding user response:

What is your virtual machine network model?

CodePudding user response:

reference 4 floor zhouchao6 response:
what is your virtual machine network model?

Bridge, NAT has tried, all not line

CodePudding user response:

DNS Settings? Add try

CodePudding user response:

33 VMware virtual machine installation centos7 and set a static IP connection outside net
Download VMware virtual machine: http://xzc.197746.com/VMware-Workstation-12.5.9.zip
Then download centos7 mirror: http://vault.centos.org/

Hardware: because it is run on the host virtualization software install centos, so the configuration of the host machine must request, at the very least I5CPU dual-core, hard disk 500 g, memory is more than 4 g,


2. The virtual machine to
1. Open the VMwear select the new virtual machine

2. The typical installation and custom installation
Typical installation: VMwear will apply the configuration of the mainstream operating system in virtual machine, for beginners to friendly,
Custom installation: custom installation can put some resources to strengthen pertinence, removed the unnecessary resources, avoid the waste of resources,
Here I choose custom installation,

The installation process according to clew to can! Here we focused on how to set the static IP and connected after install net here I chose bridge models use NAT
A, bridge pattern of VMware setup:
VMware - & gt; [Edit] - & gt; [Virtual Network Edit]




Two, bridge model of virtual machine Settings:


Three, bridge pattern set static IP address
Configured to bridge network connection mode of the virtual machine as part of the host where the Ethernet, virtual system and the relationship between the host machine, like the connection of two computers on the same Hub,
Can be like the host can access all the Shared resources in the Ethernet and the network connection, can be directly Shared hosting network access to the Internet access to the Internet line, between the host and virtual machine,
And can exchange of visits between the virtual machine, corresponding to the virtual machine was as Ethernet host is an independent physical machine, the virtual machine by default VMnet0 card and host Ethernet connection,
Virtual network for VMnet0 between virtual machine, then your virtual machine is like a separate physical machines in a local area network (LAN), the operating system in the virtual machine can PING other host,
In turn other host can also PING virtual machine, want to let them communicate, you need to configure the IP address and subnet mask for the virtual system, otherwise we are unable to communicate,
So configuration before, I need to have a look at the IP address of the physical host: (I here physical host USES wireless card wifi)
1. Ipconfig to check the physical host IP address (use the card on the network IP address)

2. According to the IP address of the physical host, set the IP address of the Linux virtual machine:
Ps: if it is centos7 ifcfg - eth0 may be ifcfg - ens33
Vim/etc/sysconfig/network - scripts/ifcfg - eth0
DEVICE=eth0 card # virtual machine name,
TYPE=Ethernet
ONBOOT=yes # boot enabled network configuration,
NM_CONTROLLED=yes
BOOTPROTO=# static static, static IP, DHCP, obtain IP address automatically, rather than
IPADDR=192.168.31.77 # set I want to use a static IP address, and physical host on the same network segment, but cannot be the same again,
A subnet mask NETMASK=255.255.255.0 #, as well as physical host,
GATEWAY=192.168.31.1 # as well as physical host
DNS1=# 8.8.8.8 DNS, write the address of the Google,
HWADDR=00:0 c: covereth: 05:4 c
IPV6INIT=no
USERCTL=no


I use xshell connection of Linux, it looks clearer:

Restart the network service:
/root @ xiaolyu77 ~ # service network restart

3. In the network configuration file/etc/sysconfig/network, gateway address is added to the

/root @ xiaolyu77 ~ # vim/etc/sysconfig/network

NETWORKING=yes
The HOSTNAME=xiaolyu77
GATEWAY=# 192.168.31.1 GATEWAY address, the same physical host GATEWAY address


4. Test:
1) virtual machine ping physical host:
/root @ xiaolyu77 ~ # ping 192.168.31.160


2) physical host ping virtual machine
C: \ Users \ Administrator> Ping 192.168.31.77

3) virtual machine test network:
/root @ xiaolyu77 ~ # ping www.baidu.com

OK, done!
Question: if can't, on the network: "ping: unknown host www.baidu.com"
If a Linux server can't domain name, the following tips:
/root @ xiaolyu75 ~ # ping www.baidu.com
Ping: unknown host www.baidu.com

Solution:
First determine has been connected to the router, and router, access to the network can be determined through the access gateway
/root @ xiaolyu75 ~ # ping 192.168.31.1

If the network under the condition of no problem, can through the following steps to find a solution:
1) to determine the set the domain name server
If not, it is suggested that Google's public DNS service, it should not be a problem of

/root @ xiaolyu75 ~ # cat/etc/resolv. Conf

The DNS is added to the file, found in the testing process, this is not necessary, network also can be added to the file,
2) make sure the gateway has been set
/root @ xiaolyu75 ~ # grep GATEWAY/etc/sysconfig/network - scripts/ifcfg *

My xiaolyu75 machine can't on the network, because network setting is wrong, I set a GETWAY=192.168.31.1.
If not set, through the following ways to increase the gateway:

/root @ xiaolyu75 ~ # route add default gw 192.168.31.1

Or manually written/etc/sysconfig/network - scripts/ifcfg * file, restart the network service:

/root @ xiaolyu75 ~ # service network restart
The/etc/sysconfig/network - scripts/ifcfg - eth0: GATEWAY=192.168.31.1

3) to ensure that the available DNS
/root @ xiaolyu75 ~ # grep hosts/etc/nsswitch. Conf
# hosts: db files nisplus nis DNS
Hosts: files DNS

4) test:
/root @ xiaolyu75 ~ # ping - c 3 www.baidu.com

OK, done!

CodePudding user response:

The DNS configuration? The/etc/resolv. Conf

CodePudding user response:

Under the selected bridge, and that probably called copy local network status on the hook
  • Related