我已经购买了VPN解决scheme,当configuration文件中有“redirect-gateway def1”(通过VPN路由所有stream量)时,它可以正常工作。
但是,当我从configuration文件中删除该行,我仍然能够ping出机器(ping -I tap0),但是我无法ping分配给本机的IP(这是一个公共IP),我得到错误: 目标主机不可达。
我只想让某些应用程序通过VPN通道发送stream量(例如:ZNC,irssi),我可以select使用哪个IP。 但是他们不能接收任何数据,使得在禁用redirect网关时隧道对我来说基本上是无用的。
关于如何允许特定应用程序使用隧道的任何想法,而不是强迫所有事情都经过它?
我的configuration文件如下:
dev tap remote #.#.#.# float #.#.#.# port 5129 comp-lzo ifconfig #.#.#.# 255.255.255.128 route-gateway #.#.#.# #redirect-gateway def1 secret key.txt cipher AES-128-CBC
当连接隧道时ifconfig -a的输出:
tap0 Link encap:Ethernet HWaddr 00:ff:47:d3:6d:f3 inet addr:#.#.#.# Bcast:#.#.#.# Mask:255.255.255.255 inet6 addr: <snip> Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:612 errors:0 dropped:0 overruns:0 frame:0 TX packets:35 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:100 RX bytes:25704 (25.1 KiB) TX bytes:6427 (6.2 KiB)
编辑:Bcast:#。#。#。(ifconfig)不同于route-gateway#。#。#。(openvpn),如果有什么区别的话。
我想你可以使用iptables来做到这一点:
#!/bin/bash # Create new routing table echo 200 vpn >> /etc/iproute2/rt_tables # assign iptables mark "1" to this table ip rule add fwmark 1 table vpn #next hop for the new routing table will be trough openvpn ip route add table vpn eql nexthop via <remotevpnip> dev tap0 #with iptables, add mark "1" to the traffic that must be sent trough the vpn # Sample using the -m owner iptables module iptables -t mangle -A OUTPUT -p tcp -m owner --uid-owner <user> -j MARK --set-mark 0x01
这适用于udp&tcpstream量,而不是icmp。
您可能错过了VPN上的路由器。 像路由添加[networking在VPN的其他方面] gw [VPN地址]应该做的伎俩。