我似乎有问题,我的openvpn服务器 – 客户端连接。
现在,重要的信息在我的客户端的日志(verb3)中:
Mon Mar 30 17:09:59 2015 OpenVPN 2.2.2 x86_64-slackware-linux-gnu [SSL] [LZO2] [EPOLL] [eurephia] built on Jul 4 2012 Mon Mar 30 17:09:59 2015 NOTE: OpenVPN 2.1 requires '--script-security 2' or higher to call user-defined scripts or executables Mon Mar 30 17:09:59 2015 LZO compression initialized Mon Mar 30 17:09:59 2015 Control Channel MTU parms [ L:1546 D:138 EF:38 EB:0 ET:0 EL:0 ] Mon Mar 30 17:09:59 2015 Socket Buffers: R=[229376->131072] S=[229376->131072] Mon Mar 30 17:10:00 2015 Data Channel MTU parms [ L:1546 D:1300 EF:46 EB:135 ET:0 EL:0 AF:3/1 ] Mon Mar 30 17:10:00 2015 Fragmentation MTU parms [ L:1546 D:1300 EF:45 EB:135 ET:1 EL:0 AF:3/1 ] Mon Mar 30 17:10:00 2015 Local Options hash (VER=V4): 'c086e1aa' Mon Mar 30 17:10:00 2015 Expected Remote Options hash (VER=V4): '8e7959c7' Mon Mar 30 17:10:00 2015 NOTE: UID/GID downgrade will be delayed because of --client, --pull, or --up-delay Mon Mar 30 17:10:00 2015 UDPv4 link local: [undef] Mon Mar 30 17:10:00 2015 UDPv4 link remote: xxxx:32386
这是卡住的地方。 请注意,xxxx是我服务器的IP地址,openvpn侦听端口是32386.一段时间后会出现
Mon Mar 30 17:12:04 2015 TLS Error: TLS key negotiation failed to occur within 60 seconds (check your network connectivity) Mon Mar 30 17:12:04 2015 TLS Error: TLS handshake failed Mon Mar 30 17:12:04 2015 TCP/UDP: Closing socket Mon Mar 30 17:12:04 2015 SIGUSR1[soft,tls-error] received, process restarting Mon Mar 30 17:12:04 2015 Restart pause, 2 second(s)
如果我禁用我的客户端的防火墙,并重新启动openvpn客户端,它连接正常。
所以问题与防火墙有关。 我设置了一个tcpdump -i <external_if> host <public_ip_of_the_other_pc>来侦听两台计算机之间的数据包。
到达客户端的两个最新数据包:
18:58:14.193351 IP adsl-xxxxtellas.gr.26382 > 192.168.201.210.42983: UDP, length 14 18:58:14.796510 IP 192.168.201.210.42983 > adsl-xxxxtellas.gr.32386: UDP, length 14 18:58:14.821572 IP adsl-xxxxtellas.gr.26382 > 192.168.201.210.42983: UDP, length 22
注意,192.168.201.210是客户端上的ADSL调制解调器的IP地址。
同时防火墙丢弃到达端口42983的数据包
Mar 30 18:57:44 halki INPUT packet died: IN=eth1 OUT= MAC=00:11:6b:32:f7:7e:00:13:33:16:36:12:08:00 SRC=xxxx DST=192.168.201.210 LEN=54 TOS=1C PREC=0x20 TTL=56 ID=0 DF PROTO=UDP SPT=26382 DPT=42983 LEN=34 Mar 30 18:57:50 halki INPUT packet died: IN=eth1 OUT= MAC=00:11:6b:32:f7:7e:00:13:33:16:36:12:08:00 SRC=xxxx DST=192.168.201.210 LEN=50 TOS=1C PREC=0x20 TTL=56 ID=0 DF PROTO=UDP SPT=26382 DPT=42983 LEN=30 Mar 30 18:58:14 halki INPUT packet died: IN=eth1 OUT= MAC=00:11:6b:32:f7:7e:00:13:33:16:36:12:08:00 SRC=xxxx DST=192.168.201.210 LEN=42 TOS=1C PREC=0x20 TTL=56 ID=0 DF PROTO=UDP SPT=26382 DPT=42983 LEN=22
显然,42983是一个很高的端口,客户端不需要打开。 但是,由于我已经在客户端的防火墙中启用了有状态的数据包检查,考虑到刚才客户端已经启动了与该源端口上的服务器的连接,端口42983应该可以被外界访问。
为了logging我的客户端的防火墙的INPUT链如下所示:
echo "Process INPUT chain ..." $IPT -A INPUT -p ALL -i $LO_IFACE -j ACCEPT $IPT -A INPUT -p ALL -i $INET_IFACE -m state --state ESTABLISHED,RELATED -j ACCEPT $IPT -A INPUT -p ALL -i $LOCAL_IFACE -s $LOCAL_NET -j ACCEPT $IPT -A INPUT -p TCP -i $INET_IFACE -j tcp_inbound $IPT -A INPUT -p UDP -i $INET_IFACE -j udp_inbound $IPT -A INPUT -p ICMP -i $INET_IFACE -j icmp_packets $IPT -A INPUT -m pkttype --pkt-type broadcast -j DROP $IPT -A INPUT -m limit --limit 3/minute --limit-burst 3 -j ULOG --ulog-prefix "INPUT packet died: " --ulog-nlgroup 1
所以ESTABLISHED,RELATED连接应该能够通过。 或者我错过了什么,防火墙不允许从openvpn服务器到客户端的响应?
编辑:
$IPT -A udp_inbound -p UDP -s 0/0 --destination-port 113 -j REJECT $IPT -A udp_inbound -p UDP -s 0/0 --destination-port 137 -j DROP $IPT -A udp_inbound -p UDP -s 0/0 --destination-port 138 -j DROP $IPT -A udp_inbound -p UDP -s $MODEM --destination-port 123 -j ACCEPT #NTP $IPT -A udp_inbound -p UDP -j RETURN $IPT -A tcp_inbound -p TCP -s 0/0 --destination-port 113 -j REJECT $IPT -A tcp_inbound -p TCP -s 0/0 --destination-port 51235 -j ACCEPT #SSH $IPT -A tcp_inbound -p TCP -j RETURN $IPT -A icmp_packets --fragment -p ICMP -j ULOG --ulog-prefix "ICMP Fragment: " --ulog-nlgroup 1 $IPT -A icmp_packets --fragment -p ICMP -j DROP $IPT -A icmp_packets -p ICMP -s $LOCAL_NET -d $VPN_NET --icmp-type 0 -j ACCEPT $IPT -A icmp_packets -p ICMP -s $LOCAL_NET -d $VPNCL_NET --icmp-type 0 -j ACCEPT $IPT -A icmp_packets -p ICMP -s 0/0 --icmp-type 8 -j ACCEPT $IPT -A icmp_packets -p ICMP -s 0/0 --icmp-type 11 -j ACCEPT $IPT -A icmp_packets -p ICMP -j RETURN
事实certificate,问题不在我的服务器或客户端openvpnconfiguration,而是在我的服务器端的ADSL调制解调器的固件。
该固件有一个错误,并错误地改变了传出数据包的源端口。 所以,虽然openvpn会响应服务器端口,ADSL调制解调器将更改openvpn数据包的源端口。 结果是客户端会丢弃这些数据包,openvpn连接将不会保持“活动”状态。
更改ADSL调制解调器的固件解决了这个问题。