AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 886168
Accepted
Thomas
Thomas
Asked: 2017-12-02 08:11:15 +0800 CST2017-12-02 08:11:15 +0800 CST 2017-12-02 08:11:15 +0800 CST

即使流量双向流动,OpenVPN 客户端也会因 --ping-restart 重新连接

  • 772

情况:

  • 1.1.1.1使用 UDP 协议在 Amazon EC2 中运行的具有公共 IP 的 OpenVPN (2.3.12) 服务器。
  • 具有公共 IP 的远程 OpenVPN (2.3.10) 客户端2.2.2.2,位于 ADSL 连接上的某处,位于 wifi 家庭路由器和防火墙后面。

问题是客户端不断重新连接,每 40 秒一次,即使连接似乎工作正常。

如下图所示,我们已经keepalive 10 40在服务器端进行了配置,并及时推送到客户端。我可以更改该值,但当然我们确实希望客户端在连接实际断开时重新连接(例如,wifi 路由器重新启动并忘记了其所有有状态的 UDP 规则)。所以这不是一个好的选择。

即使我ssh通过 VPN 连接到客户端并通过例如向上和向下滚动来双向生成一些流量,或者如果我通过 VPNless连续运行到客户端,也会发生断开连接。ping

我们也遇到了由 MTU 大小引起的丢包问题,但已通过mssfix 1200在客户端上使用解决了这个问题。作为记录,客户端可以使用 ping 服务器(在 VPN 之外)

ping -M do -s 1412 -c 1 1.1.1.1

所以我们的mssfix值理论上可以根据这个答案设置为1372 ;1200 只是为了增加一个安全边际(因此我们可以在其他网络上的其他客户端上重用这个配置)。

从客户端日志:

[server] Inactivity timeout (--ping-restart), restarting
TCP/UDP: Closing socket
SIGUSR1[soft,ping-restart] received, process restarting
Restart pause, 2 second(s)
Re-using SSL/TLS context
LZO compression initialized
Control Channel MTU parms [ L:1558 D:1212 EF:38 EB:0 ET:0 EL:3 ]
Socket Buffers: R=[212992->212992] S=[212992->212992]
Data Channel MTU parms [ L:1558 D:1200 EF:58 EB:143 ET:0 EL:3 AF:3/1 ]
Local Options String: 'V4,dev-type tun,link-mtu 1558,tun-mtu 1500,proto UDPv4,comp-lzo,cipher AES-256-CBC,auth SHA1,keysize 256,key-method 2,tls-client'
Expected Remote Options String: 'V4,dev-type tun,link-mtu 1558,tun-mtu 1500,proto UDPv4,comp-lzo,cipher AES-256-CBC,auth SHA1,keysize 256,key-method 2,tls-server'
Local Options hash (VER=V4): '22188c5b'
Expected Remote Options hash (VER=V4): 'a8f55717'
UDPv4 link local: [undef]
UDPv4 link remote: [AF_INET]1.1.1.1:1194
TLS: Initial packet from [AF_INET]1.1.1.1:1194, sid=78ff051d c8d027a7
VERIFY OK: depth=1, CN=REDACTED
Validating certificate key usage
++ Certificate has key usage  00a0, expects 00a0
VERIFY KU OK
Validating certificate extended key usage
++ Certificate has EKU (str) TLS Web Server Authentication, expects TLS Web Server Authentication
VERIFY EKU OK
VERIFY OK: depth=0, CN=server
Data Channel Encrypt: Cipher 'AES-256-CBC' initialized with 256 bit key
Data Channel Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Data Channel Decrypt: Cipher 'AES-256-CBC' initialized with 256 bit key
Data Channel Decrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Control Channel: TLSv1.2, cipher TLSv1/SSLv3 DHE-RSA-AES256-GCM-SHA384, 2048 bit RSA
[server] Peer Connection Initiated with [AF_INET]1.1.1.1:1194
SENT CONTROL [server]: 'PUSH_REQUEST' (status=1)
PUSH: Received control message: 'PUSH_REPLY,route-gateway 10.84.0.1,topology subnet,ping 10,ping-restart 40,ifconfig 10.84.0.6 255.255.0.0'
OPTIONS IMPORT: timers and/or timeouts modified
OPTIONS IMPORT: --ifconfig/up options modified
OPTIONS IMPORT: route-related options modified
Preserving previous TUN/TAP instance: tun0
Initialization Sequence Completed

从服务器日志:

MULTI: multi_create_instance called
93.254.95.157:33098 Re-using SSL/TLS context
93.254.95.157:33098 LZO compression initialized
93.254.95.157:33098 Control Channel MTU parms [ L:1558 D:1212 EF:38 EB:0 ET:0 EL:3 ]
93.254.95.157:33098 Data Channel MTU parms [ L:1558 D:1450 EF:58 EB:143 ET:0 EL:3 AF:3/1 ]
93.254.95.157:33098 Local Options String: 'V4,dev-type tun,link-mtu 1558,tun-mtu 1500,proto UDPv4,comp-lzo,cipher AES-256-CBC,auth SHA1,keysize 256,key-method 2,tls-server'
93.254.95.157:33098 Expected Remote Options String: 'V4,dev-type tun,link-mtu 1558,tun-mtu 1500,proto UDPv4,comp-lzo,cipher AES-256-CBC,auth SHA1,keysize 256,key-method 2,tls-client'
93.254.95.157:33098 Local Options hash (VER=V4): 'a8f55717'
93.254.95.157:33098 Expected Remote Options hash (VER=V4): '22188c5b'
93.254.95.157:33098 TLS: Initial packet from [AF_INET]93.254.95.157:33098, sid=a3383b01 bc17f487
93.254.95.157:33098 VERIFY OK: depth=1, CN=REDACTED
93.254.95.157:33098 VERIFY OK: depth=0, CN=ClientName
93.254.95.157:33098 Data Channel Encrypt: Cipher 'AES-256-CBC' initialized with 256 bit key
93.254.95.157:33098 Data Channel Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
93.254.95.157:33098 Data Channel Decrypt: Cipher 'AES-256-CBC' initialized with 256 bit key
93.254.95.157:33098 Data Channel Decrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
93.254.95.157:33098 Control Channel: TLSv1.2, cipher TLSv1/SSLv3 DHE-RSA-AES256-GCM-SHA384, 2048 bit RSA
93.254.95.157:33098 [ClientName] Peer Connection Initiated with [AF_INET]93.254.95.157:33098
MULTI: new connection by client 'ClientName' will cause previous active sessions by this client to be dropped.  Remember to use the --duplicate-cn option if you want multiple clients using the same certificate or username to concurrently connect.
MULTI_sva: pool returned IPv4=10.84.0.6, IPv6=(Not enabled)
MULTI: Learn: 10.84.0.6 -> ClientName/2.2.2.2:33098
MULTI: primary virtual IP for ClientName/2.2.2.2:33098: 10.84.0.6
ClientName/2.2.2.2:33098 PUSH: Received control message: 'PUSH_REQUEST'
ClientName/2.2.2.2:33098 send_push_reply(): safe_cap=940
ClientName/2.2.2.2:33098 SENT CONTROL [ClientName]: 'PUSH_REPLY,route-gateway 10.84.0.1,topology subnet,ping 10,ping-restart 40,ifconfig 10.84.0.6 255.255.0.0' (status=1)

客户端配置:

client
dev tun
proto udp
remote 1.1.1.1 1194
resolv-retry infinite
nobind
user nobody
group nogroup
persist-key
persist-tun
ca /etc/openvpn/ca.crt
cert /etc/openvpn/client.crt
key /etc/openvpn/client.key
remote-cert-tls server
cipher AES-256-CBC
comp-lzo
verb 4
mssfix 1200

服务器配置:

port 1194
proto udp
dev tun
ca /etc/openvpn/ca.crt
cert /etc/openvpn/server.crt
key /etc/openvpn/server.key
dh /etc/openvpn/dh.pem
topology subnet
server 10.84.0.0 255.255.0.0
ifconfig-pool-persist ipp.txt
client-to-client
keepalive 10 40
cipher AES-256-CBC
comp-lzo
user nobody
group nobody
persist-key
persist-tun
status openvpn-status.log
verb 4

我也许可以通过切换到 TCP 而不是 UDP 来解决这个问题,但我对开销和风险保持警惕,并且觉得即使它最终可以工作,它也是一个愚蠢的“解决方案”。

关于在哪里寻找和尝试什么的任何其他想法?

openvpn
  • 2 2 个回答
  • 15795 Views

2 个回答

  • Voted
  1. Best Answer
    Thomas
    2017-12-02T08:44:50+08:002017-12-02T08:44:50+08:00

    你知道什么有帮助吗?不在openvpn客户端机器上同时运行两个客户端进程。第一个将重新连接,此时服务器忘记了第二个并停止 ping 它,因此第二个最终重新连接,依此类推......

    我现在觉得有点傻,但我会留下这个,以防其他人也同样愚蠢。

    • 8
  2. Silk0vsky
    2021-04-22T09:05:58+08:002021-04-22T09:05:58+08:00

    通过在不同的机器上运行具有相同客户端名称 (CN) 的两个客户端,我遇到了同样的问题。为了解决这个问题,我创建了不同的客户端宠物机。

    • 0

相关问题

  • OpenVPN:在哪里生成私钥?

  • 将 iPhone 连接到 OpenVPN

  • OpenVPN 的 Linux IP 转发 - 正确的防火墙设置?

  • 最好的点对点 VPN?

  • 通过 VPN 使您的打印机可用的最佳方法是什么?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve