The solution to ping failure under linux


When I was doing the exercise today, I found that I could not ping the external network. After asking for help from various networks, the problem has been solved. The summary is as follows:

 

1. Check carefully to determine whether the network card mode of the virtual machine is selected correctly. Use the router to select the bridge mode in the physical environment, select the NAT mode for the stand-alone or dial-up Internet access, and select the host mode if you do not want to use the virtual machine to access the Internet ( the problem is small, but it is very important )

 

 

 

2. Check whether the gateway is configured correctly

 

1. Do dhclien t first to get the ip address automatically

 

 

 

2. Configuration check via # vi /etc/sysconfig/network-scripts/ifctg-eth0

 

 

 

Set ONBOOT= yes to automatically turn on the network card, and change dhcp to static static configuration, pay attention

1 ) ip and gateway must be in the same network segment

2 ) DNS is generally set to be the same as the gateway

3 ) Refer to the real machine gateway configuration

 

 

3. Restart the network card to ensure DNS can be resolved

 

# service network restart 


 


4. Check DNS resolution

 

# grep hosts /etc/nsswitch.conf

 



If there is any problem with the above after correcting it test it again ( ctrl+c to terminate) it should be no problem :



Copyright statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission. https://blog.csdn.net/ZKCoCo2014/article/details/50012861


When I was doing the exercise today, I found that I could not ping the external network. After asking for help from various networks, the problem has been solved. The summary is as follows:

 

1. Check carefully to determine whether the network card mode of the virtual machine is selected correctly. Use the router to select the bridge mode in the physical environment, select the NAT mode for the stand-alone or dial-up Internet access, and select the host mode if you do not want to use the virtual machine to access the Internet ( the problem is small, but it is very important )

 

 

 

2. Check whether the gateway is configured correctly

 

1. Do dhclien t first to get the ip address automatically

 

 

 

2.通过#vi /etc/sysconfig/network-scripts/ifctg-eth0进行配置检查

 

 

 

ONBOOT=yes设置为网卡自动开启,并将dhcp改为static静态配置,要注意

1ip、网关一定要在同一网段内

2DNS一般设与网关相同

3)可参考真机网关配置

 

 

3.重启下网卡确保DNS可以解析

 

# service network restart 


 


4.查看DNS解析情况

 

# grep hosts /etc/nsswitch.conf

 



如果以上哪个有问题修正后再测试(ctrl+c终止)应该就没问题了:



版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/ZKCoCo2014/article/details/50012861

Guess you like

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