openwrt ping: sendto: Network unreachable解决办法

root@OpenWrt:/# ping zhihu.com
PING zhihu.com (103.41.167.234): 56 data bytes
ping: sendto: Network unreachable
  • 这个错误一般是由于网关配置错误导致的
  • 通过 route 查看路由表
    root@OpenWrt:/# route
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    172.17.0.0      *               255.255.0.0     U     0      0        0 docker0
    192.168.11.0    *               255.255.255.0   U     1      0        0 eth1
    192.168.12.0    *               255.255.255.0   U     1      0        0 eth2
    192.168.233.0   *               255.255.255.0   U     0      0        0 br-lan

     

  • 可以看到Gateway一栏为空,也就是没有配置网关,路由不知将数据转发到哪个网口。解决办法是增加一条默认网关。添加命令: route add default gw XXX.XXX.XXX.XXX ,XXX.XXX.XXX.XXX为你的上级网关,一般为光猫的IP。添加完成后通过 route 查看路由表是否生效
    复制代码
    route add default gw 192.168.11.1
    root@OpenWrt:/# route
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    default         192.168.11.1    0.0.0.0         UG    0      0        0 eth1
    172.17.0.0      *               255.255.0.0     U     0      0        0 docker0
    192.168.11.0    *               255.255.255.0   U     1      0        0 eth1
    192.168.12.0    *               255.255.255.0   U     1      0        0 eth2
    192.168.233.0   *               255.255.255.0   U     0      0        0 br-lan
    root@OpenWrt:/# 
    复制代码
  • 可以看到默认网关default已被添加进路由表,ping外网成功
  • 复制代码
    root@OpenWrt:/# ping bilibili.com
    PING bilibili.com (
    110.43.34.66): 56 data bytes 64 bytes from 110.43.34.66: seq=0 ttl=51 time=27.996 ms 64 bytes from 110.43.34.66: seq=1 ttl=51 time=18.906 ms 64 bytes from 110.43.34.66: seq=2 ttl=51 time=19.691 ms 64 bytes from 110.43.34.66: seq=3 ttl=51 time=19.945 ms 64 bytes from 110.43.34.66: seq=4 ttl=51 time=19.169 ms 64 bytes from 110.43.34.66: seq=5 ttl=51 time=22.988 ms 64 bytes from 110.43.34.66: seq=6 ttl=51 time=19.152 ms ^C --- bilibili.com ping statistics --- 7 packets transmitted, 7 packets received, 0% packet loss round-trip min/avg/max = 18.906/21.121/27.996 ms root@OpenWrt:/#
    复制代码

     

posted @   贾斯丁哔哔  阅读(2934)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
点击右上角即可分享
微信分享提示