linux下GPRS ppp拨号默认路由问题(存在eth0)

问题描述:(linux版本是Linux 2.6.33-rc4,)

 第一种情况:
     eth0:192.168.1.2
     eth0 gw:192.168.1.1
     ppp0:10.0.0.1
     eth0的IP地址和gw在同一个网段下,此时的默认路由是
     Destination    Gateway        Genmask    Flags    Metric   Ref    Iface
     0.0.0.0        192.168.1.1    0.0.0.0    UG       0        0      eth0
     此时ppp0无法联网。
 第二种情况:
     eth0:192.168.1.2
     eth0 gw:192.168.3.1
     ppp0:10.0.0.1
     eth0的IP地址和gw不在同一个网段下,此时的默认路由是
     Destination    Gateway        Genmask    Flags    Metric   Ref    Iface
     0.0.0.0        10.0.0.254     0.0.0.0    UG       0        0      ppp0
     此时ppp0可以联网

解决方案:

    1、在拨号前将默认路由删除(如果已经存在默认路由,pppd拨号是不会修改这个的,具体解释见How to hook up PPP in Linux的no default route)。
    2、将ppp0设置为默认路由。 
       先删除原来路由,route del default 
       再将ppp0设置为默认路由,route add default dev ppp0    
  

参考资料:

    1、https://blog.csdn.net/zhang_danf/article/details/48138037
    2、http://linux-sxs.org/networking/pppunruh.html#NoDefault
    3、https://blog.csdn.net/chenliang0224/article/details/72758640                     
 
    原文作者:mark
    原文地址: https://segmentfault.com/a/1190000015953777
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞