linux,如何配置路由,使得局域网内的流量不走vpn?

171 views
Skip to first unread message

Zhentao Zhu

unread,
Jun 14, 2014, 4:27:55 AM6/14/14
to ustc_lug
环境就是,机器A 和 机器B 在同一个网段内 10.5.1.0/24
机器A  10.5.1.177 拨了LUG vpn, 然后想要直接访问机器B 10.5.1.76

机器A 获得的vpn内网ip 是10.8.0.124

--
Best wishs        //smash the scabbard

Yifan Gao

unread,
Jun 14, 2014, 10:02:17 AM6/14/14
to ustc...@googlegroups.com
删掉openvpn的0.0.0.0/1路由,再添加一个vpn的默认路由就行了


--
-- 来自USTC LUG
请使用gmail订阅,不要灌水。
更多信息more info:http://groups.google.com/group/ustc_lug?hl=en?hl=en

---
You received this message because you are subscribed to the Google Groups "USTC_LUG" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ustc_lug+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Zhang Cheng

unread,
Jun 14, 2014, 10:33:57 AM6/14/14
to USTC LUG

On Sat, Jun 14, 2014 at 4:27 PM, Zhentao Zhu <skt0...@gmail.com> wrote:
环境就是,机器A 和 机器B 在同一个网段内 10.5.1.0/24
机器A  10.5.1.177 拨了LUG vpn, 然后想要直接访问机器B 10.5.1.76

机器A 获得的vpn内网ip 是10.8.0.124

​这个感觉跟vpn应该没有关系,同网段的访问路由一般是networking服务自动配置的,除非你手动删掉了。比如我当前的路由:

​$ ip route​

default via 192.168.10.1 dev vnet0 
172.16.254.0/24 dev vnet1  proto kernel  scope link  src 172.16.254.1 
192.168.10.0/24 dev vnet0  proto kernel  scope link  src 192.168.10.150


​(把这里的vnet0想象成eth0),对192.168.10.0/24这个网段的访问由第三行决定,也就是对这个网段的访问都直接从vnet0这个网卡送出去,并且没有网关。

​你的A上面的路由表应该类似于这个样子:

​$ ip route
default via 10.5.1.1 dev eth0
0.0.0.0/1 via 10.8.0.1 dev tun0
128.0.0.0/1 via 10.8.0.1 dev tun0
10.5.1.0/24 dev eth0 proto kernel scope link src 10.5.1.0/24

除非第四行被删掉了,否则前三行的路由是不会影响你访问B机器的。


--
Cheng,
Best Regards

Bojie Li

unread,
Jun 14, 2014, 10:57:57 AM6/14/14
to USTC_LUG
ip route add 10.5.1.0/24 dev 物理网卡名称

Zhentao Zhu <skt0...@gmail.com>编写:

环境就是,机器A 和 机器B 在同一个网段内 10.5.1.0/24
机器A  10.5.1.177 拨了LUG vpn, 然后想要直接访问机器B 10.5.1.76

机器A 获得的vpn内网ip 是10.8.0.124
--
Best wishs        //smash the scabbard
Reply all
Reply to author
Forward
0 new messages