What should I do if centos7 cannot ping the gateway under the virtual machine?

王林
Release: 2020-05-20 14:47:48
Original
3694 people have browsed it

What should I do if centos7 cannot ping the gateway under the virtual machine?

1. Change the network connection mode to NAT mode

What should I do if centos7 cannot ping the gateway under the virtual machine?

2. Check the centos server related information

What should I do if centos7 cannot ping the gateway under the virtual machine?

3. Use the vim /etc/sysconfig/network-scripts/ifcfg-ens33 command to modify the relevant configuration, as shown in the figure below:

Press the a key to start modifying the file. After the modification is completed, first press the Esc key, then press the English: key, and finally press the wq key to save!

wq: save; q!: do not save

The relevant configuration is:

TYPE=Ethernet
BOOTPROTO=static
#配置静态IP,网关,子网掩码
IPADDR=192.168.204.100
NETMASK=255.255.255.0
GATEWAY=192.168.204.2
取消networkmanager 管理
NM_CONTROLLED=no

DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=ens33
UUID=d8b51bef-1883-419d-a7b2-3ddf580af668
DEVICE=ens33
ONBOOT=yes
Copy after login

Then restart the network card:

systemctl restart network
Copy after login
Copy after login

or

service network restart
Copy after login
Copy after login

4. Configure DNS

Switch to the networkmanager directory c

d /etc/NetworkManager
Copy after login

Modify the NetworkManager.conf configuration file and add dns=none at the end

Modify resolv.conf and add a new dns configuration vi /etc/resolv.conf, as shown below:

#主DNS
nameserver 8.8.8.8
#备DNS
nameserver 114.114.114.114
search localdomain
Copy after login

5. Restart the network card

systemctl restart network
Copy after login
Copy after login

or

service network restart
Copy after login
Copy after login

. Just complete the above steps.

Recommended tutorial: centos tutorial

The above is the detailed content of What should I do if centos7 cannot ping the gateway under the virtual machine?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!