有没有办法configurationOpenVPN客户端直接(即不通过VPN),而是通过客户端的常规默认网关为HTTP端口80和HTTPS端口443路由stream量。 所有其他stream量应该通过VPN。
我的客户端在Windows上运行OpenVPN,我的当前configuration如下所示:
client dev tun proto tcp remote my-server-2 1194 resolv-retry infinite nobind persist-key persist-tun ca ../keys/ca.crt cert ../keys/client1.crt key ../keys/client1.key ns-cert-type server verb 3 route-metric 1 show-net-up dhcp-renew dhcp-release route-delay 0 120 hand-window 180 management localhost 13010 management-hold management-query-passwords management-forget-disconnect management-signal auth-user-pass
OpenVPN无法过滤stream量 – 它只是发送它通过VPN隧道传递的IP数据包。 您需要的function需要由操作系统提供。 OS需要决定是使用OpenVPN路由一个数据包,还是使用本地networking上的网关。 在Linux上,使用iptables来标记某些数据包,使用iproute2来select不同的路由表。 据我所知,这不能在Windows上完成。
连接到VPN时,会对路由表进行一些更改,以决定哪些stream量进入openvpn接口,哪些stream量发送到本地网关。
它可以通过几种方式configuration,其中2个如下。 (我想你需要谷歌的“拆分隧道”configuration更多细节。)
1)默认configuration是服务器向客户端推送一个以tun接口网关为默认路由的路由表项,在这种情况下, 所有stream量(包括端口80和443)都通过openVPN隧道进行路由。
2)你想要什么(我想)是configuration连接的OpenVPN服务器,只推送专用networkingstream量的路由到路由表,所以一切都发送到本地网关。 (http,httpd,dns保持本地)
通常这包括在server.conf文件中设置指令push ;
push "route 10.251.69.0 255.255.255.0"
有一个例子来禁用“客户的互联网stream量应该通过VPN路由吗?” 在这里的openvpn webpipe理面板上
您也可以根据每个客户端进行设置,但是根据评论中链接的博客文章 ,很难(不可能)??从服务器中取消设置的路由,而不运行一些bash脚本来包装它。 (因此,如果您可以在server.conf为所有客户端设置相同的话,那么这样更容易)。
如果您的OpenVPN客户端驻留在LAN网关中,则可以执行以下操作。
用iptables标记传入的httpstream量
( iptables -t mangle -A PREROUTING -p tcp --dport 80 -j MARK --set-mark 0x80 。
然后专门为已标记的stream量创build路由表。
echo "80 http" >> /etc/iproute2/rt_tables
ip route add default 11.22.33.44 dev ethX table http
最后,根据全新的表添加用于路由标记的stream量的规则。
ip rule add fwmark 0x80 lookup 80
您可以在Linux高级路由和stream量控制操作指南 – http://www.lartc.org中了解有关Linux策略路由的更多信息