关于嵌入式开发板能ping通局域IP地址但是无法ping通外网例如www.baidu.com的解决方法总结

您所在的位置:网站首页 虚拟机ping不通外网怎么办 关于嵌入式开发板能ping通局域IP地址但是无法ping通外网例如www.baidu.com的解决方法总结

关于嵌入式开发板能ping通局域IP地址但是无法ping通外网例如www.baidu.com的解决方法总结

2024-07-15 14:04| 来源: 网络整理| 查看: 265

当在ping外网百度的时候出现ping: bad address 'www.baidu.com’的提示,在网上也找过一些解决方法,但是可能每个人的具体情况不同,特把我总结的解决方法整理如下: 1、首先在开发板ping了www.baidu.com,后出现ping: bad address 'www.baidu.com’的提示; 2、然后又直接ping了百度的IP,ping 202.108.22.5,后出现ping: sendto: Network is unreachable提示 3、使用查看路由表命令:route Route命令 : 在数据包没有有效传递的情况下,可以利用route命令查看路由表

[root@Itop-4412:/]#route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.0.0 * 255.255.255.0 U 0 0 0 eth0

发现是没有配置网关(gateway) 4、解决的方法 输入命令:route add default gw 192.168.0.1 然后再查看一下路由表看一下是否添加上了。

[root@iTOP-4412]# route add default gw 192.168.0.1 [root@iTOP-4412]# route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default 192.168.0.1 0.0.0.0 UG 0 0 0 eth0 192.168.0.0 * 255.255.255.0 U 0 0 0 eth0

5、添加成功后测试一下是否解决问题:

[root@iTOP-4412]# [root@iTOP-4412]# ping 202.108.22.5 PING 202.108.22.5 (202.108.22.5): 56 data bytes 64 bytes from 202.108.22.5: seq=0 ttl=51 time=24.781 ms 64 bytes from 202.108.22.5: seq=1 ttl=51 time=23.996 ms 64 bytes from 202.108.22.5: seq=2 ttl=51 time=24.809 ms 64 bytes from 202.108.22.5: seq=3 ttl=51 time=24.300 ms 64 bytes from 202.108.22.5: seq=4 ttl=51 time=23.713 ms 64 bytes from 202.108.22.5: seq=5 ttl=51 time=24.447 ms 64 bytes from 202.108.22.5: seq=6 ttl=51 time=25.266 ms 64 bytes from 202.108.22.5: seq=7 ttl=51 time=23.630 ms 64 bytes from 202.108.22.5: seq=8 ttl=51 time=23.517 ms ^C --- 202.108.22.5 ping statistics --- 9 packets transmitted, 9 packets received, 0% packet loss round-trip min/avg/max = 23.517/24.273/25.266 ms [root@iTOP-4412]# [root@iTOP-4412]# [root@iTOP-4412]# [root@iTOP-4412]# ping www.baidu.com PING www.baidu.com (220.181.38.150): 56 data bytes 64 bytes from 220.181.38.150: seq=0 ttl=52 time=26.332 ms 64 bytes from 220.181.38.150: seq=1 ttl=52 time=25.699 ms 64 bytes from 220.181.38.150: seq=2 ttl=52 time=26.228 ms 64 bytes from 220.181.38.150: seq=3 ttl=52 time=25.744 ms ^C --- www.baidu.com ping statistics --- 4 packets transmitted, 4 packets received, 0% packet loss round-trip min/avg/max = 25.699/26.000/26.332 ms [root@iTOP-4412]# [root@iTOP-4412]#

6、问题解决后续记录 但是之前也在一些地方找过解决的方法,很多。各不相同。有的说是在/etc下缺少hosts文件和resolv.conf文件,或者有这两个文件但是需要修改,在解决问题之前我也做了修改,特把相应修改后的文件代码记录如下: hosts文件内容:

127.0.0.1 localhost 127.0.1.1 ubuntu # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters

resolv.conf文件内容

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN nameserver 127.0.0.1

一些心里话:现在觉的网上的学习氛围很好,大家的分享精神值得我学习,现在起我也把我的一些学习中遇到问题解决的方法分享给大家,我们一起学习探讨。



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3