路由不能使用OpenVPN

我试图在Debian 6.0.5上安装OpenVPN服务器(通过apt安装),但我坚持路由问题。

这是我的networkingconfiguration:

Client <-> Router+Firewall <-> OVPN Server <-> Subnet A AND Subnet B 172.17.17.6 197.174.211.77 197.174.211.0/27 197.174.211.64/27 

我可以连接到服务器并获取IP,但无法访问两个子网上的服务器。 我确信OpenVPN可以ping,wget等到子网A和B中的服务器。

这是我的服务器configuration:

 port 1194 proto tcp dev tun ca ca.crt cert server.crt key server.key # This file should be kept secret dh dh1024.pem server 172.17.17.0 255.255.255.0 ifconfig-pool-persist ipp.txt route 197.174.211.0 255.255.255.224 route 197.174.211.64 255.255.255.224 push "route 197.174.211.0 255.255.255.224" push "route 197.174.211.64 255.255.255.224" client-to-client duplicate-cn keepalive 10 120 comp-lzo max-clients 20 user nobody group nogroup persist-key persist-tun status openvpn-status-tcp.log log-append /var/log/openvpn-tcp.log verb 5 

我的服务器路由表:

 Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 172.17.17.2 * 255.255.255.255 UH 0 0 0 tun0 197.174.211.64 172.17.17.2 255.255.255.224 UG 0 0 0 tun0 197.174.211.64 * 255.255.255.224 U 0 0 0 eth0 172.17.17.0 172.17.17.2 255.255.255.0 UG 0 0 0 tun0 default 197.174.211.65 0.0.0.0 UG 0 0 0 eth0 

当我做

 cat /proc/sys/net/ipv4/ip_forward 1 

所以我猜ip_forward被激活…

我看到OpenVPN从隧道接收stream量,但不转发它…

 **root@vpn:/etc/openvpn# tcpdump -i tun0 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on tun0, link-type RAW (Raw IP), capture size 65535 bytes 15:24:42.913610 IP 172.17.17.6 > : ICMP echo request, id 1, seq 729, length 40 15:24:47.743495 IP 172.17.17.6 > 197.174.211.11: ICMP echo request, id 1, seq 730, length 40 

但我的客户没有回应:-(

我没有使用iptables或任何防火墙在我的服务器上…

有没有人有一个想法?

客户端(172.17.17.6)< – >路由器+防火墙OVPN Srv(WAN:197.174.211.77)子网A 197.174.211.0/255.255.255.224与子网B 197.174.211.64/255.255.255.224

所以你的OpenVPN服务器位于子网B.我假设你的子网A服务器可以路由到子网B.

 route 197.174.211.0 255.255.255.224 <---- You don't need this, remove it route 197.174.211.64 255.255.255.224 <---- You don't need this, remove it push "route 197.174.211.0 255.255.255.224" push "route 197.174.211.64 255.255.255.224" Destination Gateway Genmask Flags Metric Ref Use Iface 172.17.17.2 * 255.255.255.255 UH 0 0 0 tun0 197.174.211.64 172.17.17.2 255.255.255.224 UG 0 0 0 tun0 <-- Bad 197.174.211.64 * 255.255.255.224 U 0 0 0 eth0 172.17.17.0 172.17.17.2 255.255.255.0 UG 0 0 0 tun0 default 197.174.211.65 0.0.0.0 UG 0 0 0 eth0 

现在197.174.211.65是你的默认路由器。 您需要configuration路由172.17.17.0/24到197.174.211.77。 您还需要在子网A中为此configuration路由器。

另一个解决scheme(安装iptables):

 iptables -t nat -A POSTROUTING -s 172.17.17.0/24 -o eth0 -j MASQUERADE