- # 假设路由器网段为 192.168.1.0
- # 1. 开启 VPN 后, 执行如下命令判断是否已添加局域内网白名单
- ip route list table 0x3c
- # 如果有以下内容, 则不用再添加, 没有的话执行第二步
- # 192.168.1.0/24 dev wlan0 proto static scope link
- # 2. 添加局域内网段白名单
- # 此命令实现开 VPN 时, 外网走 VPN, 内网直接走路由器
- ip route add 192.168.1.0/24 dev wlan0 proto static scope link table 0x3c
- # 3. 这时就可以 ping 通内网 IP 了, 外网走 VPN, 内网直接走路由器
- busybox ping 192.168.1.102
注:
其中
0x3c
是 VPN 新添加的路由表名称, 有些设备是 ppp0, 需要以情况而定;
不能 ping 通其他网段的 IP(比如
192.168.2.* 192.168.3.*
), 因为如果需要 ping 通局域网其他网段还需要指定上级网关;
来源: http://www.jianshu.com/p/18ef04294129