我在运行Debian 5的VPS上运行OpenVPN服务器,在Ubuntu 11.04桌面上运行OpenVPS客户端。 我想要从客户端传出的所有stream量通过VPN服务器进行隧道传输。
我能够发起从客户端到服务器的连接,并在它们之间成功ping通,但是当我尝试从客户端访问外部IP地址时,我不成功。
例如,当通过IP ping Google时:
ping -n 74.125.91.106 PING 74.125.91.106 (74.125.91.106) 56(84) bytes of data. ^C --- 74.125.91.106 ping statistics --- 7 packets transmitted, 0 received, 100% packet loss, time 6048ms
在服务器端,我可以看到来自隧道的ping请求,但没有回复:
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 21:24:59.384736 IP 10.8.0.6 > qy-in-f106.1e100.net: ICMP echo request, id 7537, seq 1, length 64 21:25:00.391970 IP 10.8.0.6 > qy-in-f106.1e100.net: ICMP echo request, id 7537, seq 2, length 64 21:25:01.400394 IP 10.8.0.6 > qy-in-f106.1e100.net: ICMP echo request, id 7537, seq 3, length 64 21:25:02.408914 IP 10.8.0.6 > qy-in-f106.1e100.net: ICMP echo request, id 7537, seq 4, length 64 21:25:03.416378 IP 10.8.0.6 > qy-in-f106.1e100.net: ICMP echo request, id 7537, seq 5, length 64 21:25:04.424289 IP 10.8.0.6 > qy-in-f106.1e100.net: ICMP echo request, id 7537, seq 6, length 64 21:25:05.431804 IP 10.8.0.6 > qy-in-f106.1e100.net: ICMP echo request, id 7537, seq 7, length 64
我也可以在服务器上的venet0接口上看到这些信息:
tcpdump -i venet0:0 'icmp[icmptype] == icmp-echo or icmp[icmptype] == icmp-echoreply' tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on venet0:0, link-type LINUX_SLL (Linux cooked), capture size 65535 bytes 21:39:11.397967 IP 10.8.0.6 > qy-in-f106.1e100.net: ICMP echo request, id 7588, seq 1, length 64 21:39:12.407609 IP 10.8.0.6 > qy-in-f106.1e100.net: ICMP echo request, id 7588, seq 2, length 64 21:39:13.415194 IP 10.8.0.6 > qy-in-f106.1e100.net: ICMP echo request, id 7588, seq 3, length 64 21:39:14.423050 IP 10.8.0.6 > qy-in-f106.1e100.net: ICMP echo request, id 7588, seq 4, length 64 21:39:15.431005 IP 10.8.0.6 > qy-in-f106.1e100.net: ICMP echo request, id 7588, seq 5, length 64 21:39:16.439687 IP 10.8.0.6 > qy-in-f106.1e100.net: ICMP echo request, id 7588, seq 6, length 64 21:39:17.446949 IP 10.8.0.6 > qy-in-f106.1e100.net: ICMP echo request, id 7588, seq 7, length 64
我也可以从服务器ping谷歌。
任何想法可能导致这个?
服务器configuration文件:
dev tun 服务器10.8.0.0 255.255.255.0 ifconfig-pool-persist ipp.txt ca ca.crt cert server.crt 密钥server.key dh dh1024.pem 推“路由10.8.0.0 255.255.255.0” 推“redirect网关” COMP-LZO 保持活力10 60 平定时器雷姆 坚持-TUN 坚持键 组守护进程 守护进程
客户端configuration文件:
远程<服务器IP> dev tun COMP-LZO ca ca.crt 证书client1.crt key client1.key 路由延迟2 路线方法EXE redirect网关def1 dhcp-option DNS 10.8.0.1 动词3
您需要将“传入”stream量映射为正确路由到客户端。 即您需要在服务器上为客户端的IP(VPN一)设置NAT转换。
你看到的是服务器不知道如何转发的答复。
这里是说明如何做到这一点: http : //openvpn.net/index.php/open-source/documentation/howto.html#redirect – 看看服务器上的iptablesconfiguration。
启用IP转发? 源nating的VPN客户端?
Source nating正在将(vpn客户端)地址转换为外部IP地址。 正如Sunny所说的那样,即使您的ISP没有对其进行过滤,接收服务器也不会知道如何路由回到内部IP。
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE iptables -a FORWARD -i tun0 -j ACCEPT