我正在我的 Arch Linux 服务器上配置 OpenVPN 2.3.6-1,以加密公共互联网上的 SMB 流量。当我在我的 Linux 虚拟机客户端之一上测试设置时,我收到错误:TLS Error: TLS handshake failed
.
我快速阅读(OpenVZ TLS 错误上的 OpenVPN:TLS 握手失败(谷歌建议的解决方案没有帮助))并尝试从默认 UDP 切换到 TCP,但这只会导致客户端反复报告连接超时。我还尝试禁用密码和 TLS 身份验证,但这导致服务器因Assertion failed at crypto_openssl.c:523
. 在这两种情况下,对客户端和服务器配置都进行了所需的更改。
我一直在按照(https://wiki.archlinux.org/index.php/OpenVPN)的说明设置 OpenVPN 和(https://wiki.archlinux.org/index.php/Create_a_Public_Key_Infrastructure_Using_the_easy-rsa_Scripts ) 来创建密钥和证书。我对这些说明所做的唯一偏差是指定了我自己的计算机名称及其相应的密钥/证书文件名。
另请参阅我关于通过 Internet 保护 SMB 流量的原始问题:(Samba 共享的简单加密)
谁能解释我如何解决这个问题?
细节:
服务器:Arch Linux(最新)通过以太网电缆直接连接到网关。没有iptables。
客户端:VirtualBox 4.3.28r100309 Windows 8.1 主机上的 Arch Linux(最新)虚拟机,桥接网络适配器。没有iptables。Windows 防火墙已禁用。
网关:启用端口 1194 的端口转发,没有防火墙限制。
这里分别是服务器端和客户端的配置文件。我根据 Arch Wiki 上的说明创建了这些。
/etc/openvpn/server.conf
(仅限非注释行):
port 1194
proto udp
dev tun
ca /etc/openvpn/ca.crt
cert /etc/openvpn/server-name.crt
key /etc/openvpn/server-name.key
dh /etc/openvpn/dh2048.pem
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
keepalive 10 120
tls-auth /etc/openvpn/ta.key 0
comp-lzo
user nobody
group nobody
persist-key
persist-tun
status openvpn-status.log
verb 3
Run Code Online (Sandbox Code Playgroud)
/etc/openvpn/client.conf
(仅限非注释行):
client
dev tun
proto udp
remote [my public IP here] 1194
resolv-retry infinite
nobind
user nobody
group nobody
persist-key
persist-tun
ca /etc/openvpn/ca.crt
cert /etc/openvpn/client-name.crt
key /etc/openvpn/client-name.key
remote-cert-tls server
tls-auth /etc/openvpn/ta.key 1
comp-lzo
verb 3
Run Code Online (Sandbox Code Playgroud)
以下是在具有上述配置的机器上运行 openvpn 的输出。我先启动服务器,然后是客户端。
openvpn /etc/openvpn/server.conf
服务器上的输出:
Thu Jul 30 17:02:53 2015 OpenVPN 2.3.6 x86_64-unknown-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [MH] [IPv6] built on Dec 2 2014
Thu Jul 30 17:02:53 2015 library versions: OpenSSL 1.0.2d 9 Jul 2015, LZO 2.09
Thu Jul 30 17:02:53 2015 NOTE: your local LAN uses the extremely common subnet address 192.168.0.x or 192.168.1.x. Be aware that this might create routing conflicts if you connect to the VPN server from public locations such as internet cafes that use the same subnet.
Thu Jul 30 17:02:53 2015 Diffie-Hellman initialized with 2048 bit key
Thu Jul 30 17:02:53 2015 Control Channel Authentication: using '/etc/openvpn/ta.key' as a OpenVPN static key file
Thu Jul 30 17:02:53 2015 Outgoing Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
Thu Jul 30 17:02:53 2015 Incoming Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
Thu Jul 30 17:02:53 2015 Socket Buffers: R=[212992->131072] S=[212992->131072]
Thu Jul 30 17:02:53 2015 ROUTE_GATEWAY 192.168.0.1/255.255.255.0 IFACE=enp5s0 HWADDR=##:##:##:##:##:##
Thu Jul 30 17:02:53 2015 TUN/TAP device tun0 opened
Thu Jul 30 17:02:53 2015 TUN/TAP TX queue length set to 100
Thu Jul 30 17:02:53 2015 do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0
Thu Jul 30 17:02:53 2015 /usr/bin/ip link set dev tun0 up mtu 1500
Thu Jul 30 17:02:53 2015 /usr/bin/ip addr add dev tun0 local 10.8.0.1 peer 10.8.0.2
Thu Jul 30 17:02:53 2015 /usr/bin/ip route add 10.8.0.0/24 via 10.8.0.2
Thu Jul 30 17:02:53 2015 GID set to nobody
Thu Jul 30 17:02:53 2015 UID set to nobody
Thu Jul 30 17:02:53 2015 UDPv4 link local (bound): [undef]
Thu Jul 30 17:02:53 2015 UDPv4 link remote: [undef]
Thu Jul 30 17:02:53 2015 MULTI: multi_init called, r=256 v=256
Thu Jul 30 17:02:53 2015 IFCONFIG POOL: base=10.8.0.4 size=62, ipv6=0
Thu Jul 30 17:02:53 2015 IFCONFIG POOL LIST
Thu Jul 30 17:02:53 2015 Initialization Sequence Completed
Run Code Online (Sandbox Code Playgroud)
openvpn /etc/openvpn/client.conf
客户端的输出:
Thu Jul 30 21:03:02 2015 OpenVPN 2.3.6 x86_64-unknown-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [MH] [IPv6] built on Dec 2 2014
Thu Jul 30 21:03:02 2015 library versions: OpenSSL 1.0.2d 9 Jul 2015, LZO 2.09
Thu Jul 30 21:03:02 2015 WARNING: file '/etc/openvpn/client-name.key' is group or others accessible
Thu Jul 30 21:03:02 2015 WARNING: file '/etc/openvpn/ta.key' is group or others accessible
Thu Jul 30 21:03:02 2015 Control Channel Authentication: using '/etc/openvpn/ta.key' as a OpenVPN static key file
Thu Jul 30 21:03:02 2015 Outgoing Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
Thu Jul 30 21:03:02 2015 Incoming Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
Thu Jul 30 21:03:02 2015 Socket Buffers: R=[212992->131072] S=[212992->131072]
Thu Jul 30 21:03:02 2015 NOTE: UID/GID downgrade will be delayed because of --client, --pull, or --up-delay
Thu Jul 30 21:03:02 2015 UDPv4 link local: [undef]
Thu Jul 30 21:03:02 2015 UDPv4 link remote: [AF_INET][my public IP here]:1194
Thu Jul 30 21:04:02 2015 TLS Error: TLS key negotiation failed to occur within 60 seconds (check your network connectivity)
Thu Jul 30 21:04:02 2015 TLS Error: TLS handshake failed
Thu Jul 30 21:04:02 2015 SIGUSR1[soft,tls-error] received, process restarting
Thu Jul 30 21:04:02 2015 Restart pause, 2 second(s)
Run Code Online (Sandbox Code Playgroud)
我也有这个问题。
我正在为我的服务器使用 digitalocean 提供商,问题在于浮动 ip 功能。
为了解决这个问题,您必须更新 openvpn 配置设置:
local <ip anchor>
Run Code Online (Sandbox Code Playgroud)
ip 锚点应该是从ip addr
命令收集的 ip 地址,请参见示例:
正如 Michael Hampton 和 Michal Sokolowski 在对我的问题的评论中所建议的那样,这是我在网关上创建的端口转发规则的问题。OpenVPN 配置为使用 UDP,我忘记在网关上从 TCP 切换到 UDP,因为我通常不使用该协议。转发规则现在使用 UDP,我的 VPN 可以正常工作。
归档时间: |
|
查看次数: |
238359 次 |
最近记录: |