我是这个社区的新手,并希望有人可以帮助我。如果我没有发布所有必填信息,请告诉我。
情况:
我有一个Linux服务器(raspberry pi,192.168.1.2),用作付费VPN提供商的OpenVPN客户端(tun1)。我确实通过使用linux服务器作为默认网关(192.168.1.2)与LAN客户端在本地共享此VPN连接。这是没有任何问题的工作。
在同一台Linux服务器上,我正在运行一个单独的openVPN实例(VPN服务器,tun0),以允许WAN客户端进行连接。只要未建立与付费VPN提供商的VPN客户端连接,此方法也不会出现任何问题。
我的最终目标是与通过单独的openVPN服务器(tun0)实例连接的WAN客户端共享付费VPN连接(tun1)。
我的本地网络设置方案:
问题:
只要我不同时运行它们,openVPN客户端和openVPN服务器实例就可以正常工作。一旦他们的openVPN客户端与付费VPN提供商建立连接,WAN客户端便无法连接到openVPN服务器。
通过查看日志文件,我发现,一旦建立了付费VPN连接,WAN客户端握手就会失败。我认为这是由于以下事实:一旦建立了此付费VPN连接,所有传出的互联网流量都将通过隧道(tun1)进行路由,因此客户端的握手请求仍未得到响应。我不知道该怎么解决。
ifconfig
pi@server:~ $ ifconfig -a
eth0 Link encap:Ethernet HWaddr b8:27:eb:f2:c1:98
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
eth1 Link encap:Ethernet HWaddr 58:82:a8:8d:9a:fa
inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:203 errors:0 dropped:0 overruns:0 frame:0
TX packets:165 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:22948 (22.4 KiB) TX bytes:24938 (24.3 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.77.0.1 P-t-P:10.77.0.2 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
tun1 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.130.1.70 P-t-P:10.130.1.69 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
iptables
pi@server:~ $ sudo iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT udp -- anywhere anywhere udp dpt:1199
Chain FORWARD (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT all -- 10.77.0.0/24 anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
路线-n(当tun0 / tun1未运行且未连接时)
pi@server:~ $ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth1
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
路线-n(运行tun0并已连接时)
pi@server:~ $ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth1
10.77.0.0 10.77.0.2 255.255.255.0 UG 0 0 0 tun0
10.77.0.2 0.0.0.0 255.255.255.255 UH 0 0 0 tun0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
路线-n(当tun1正在运行并已连接时)
pi@raspi-cyberghost:~ $ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.130.0.133 128.0.0.0 UG 0 0 0 tun1
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth1
10.77.0.0 10.77.0.2 255.255.255.0 UG 0 0 0 tun0
10.77.0.2 0.0.0.0 255.255.255.255 UH 0 0 0 tun0
10.130.0.1 10.130.0.133 255.255.255.255 UGH 0 0 0 tun1
10.130.0.133 0.0.0.0 255.255.255.255 UH 0 0 0 tun1
107.183.241.2 192.168.1.1 255.255.255.255 UGH 0 0 0 eth1
128.0.0.0 10.130.0.133 128.0.0.0 UG 0 0 0 tun1
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
在连接OpenVPN客户端(tun1)的情况下尝试连接时出现OpenVPN服务器(tun0)错误日志
Tue Mar 21 08:06:19 2017 us=593849 172.56.28.50:24844 TLS: Initial packet from [AF_INET]172.56.28.50:24844, sid=d25df6fb 2136a7cc
Tue Mar 21 08:07:19 2017 us=128339 172.56.28.50:24844 TLS Error: TLS key negotiation failed to occur within 60 seconds (check your network connectivity)
Tue Mar 21 08:07:19 2017 us=128603 172.56.28.50:24844 TLS Error: TLS handshake failed
Tue Mar 21 08:07:19 2017 us=129254 172.56.28.50:24844 SIGUSR1[soft,tls-error] received, client-instance restarting
找到了我的解决方案。问题在于,有必要构建两个路由表:一个处理路由到Pi的传入流量(及其相应的答复),另一个处理来自Pi的传出流量(及其答复)。
第二个路由表为我解决了这个问题:
ip rule add from 192.168.1.2 lookup 10 # Pi server
ip route add default via 192.168.1.1 table 10 # LAN router
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句