有没有熟悉 openvpn 的同学给看看

48 天前
 fever
openvpn 两边 service 都启动起来了 连接不成功,或者说一连上就被重置了,似乎是拒绝了
服务端的转发有开 /etc/sysctl.conf
服务端的端口 51199 是正常开放的
看日志 Connection reset, restarting [-1] 这个错误也找不到相关解释


服务端配置:
proto tcp-server
dev tun
port 51199
ifconfig 10.10.4.1 10.10.4.2
tls-server
remote-cert-tls client
tls-auth /etc/openvpn/server/ta.key 0
ca /etc/openvpn/server/ca.crt
cert /etc/openvpn/server/server.crt
key /etc/openvpn/server/server.key
dh /etc/openvpn/server/dh2048.pem
cipher AES-128-CBC
comp-lzo adaptive
push "comp-lzo adaptive"
persist-tun
persist-key
verb 4
keepalive 10 60
user openvpn
group openvpn
log /var/log/openvpn_test.log
log-append /var/log/openvpn_test.log
route 192.168.144.0 255.255.248.0 vpn_gateway


客户端配置:
proto tcp-client
dev tun
remote x.x.x.x 51199
ifconfig 10.10.4.2 10.10.4.1
tls-client
remote-cert-tls server
tls-auth /etc/openvpn/server/ta.key 1
ca /etc/openvpn/server/ca.crt
cert /etc/openvpn/server/server.crt
key /etc/openvpn/server/server.key
dh /etc/openvpn/server/dh2048.pem
cipher AES-128-CBC
comp-lzo adaptive
persist-tun
persist-key
verb 4
keepalive 10 60
user openvpn
group openvpn
log /var/log/openvpn_us.log
log-append /var/log/openvpn_us.log
route 192.168.40.0 255.255.248.0 vpn_gateway



客户端日志:
2024-04-02 19:53:17 us=761923 Restart pause, 300 second(s)
2024-04-02 19:58:17 us=762021 Re-using SSL/TLS context
2024-04-02 19:58:17 us=762156 Outgoing Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
2024-04-02 19:58:17 us=762173 Incoming Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
2024-04-02 19:58:17 us=762235 Control Channel MTU parms [ L:1559 D:1182 EF:68 EB:0 ET:0 EL:3 ]
2024-04-02 19:58:17 us=762253 Preserving previous TUN/TAP instance: tun4
2024-04-02 19:58:17 us=762271 Data Channel MTU parms [ L:1559 D:1450 EF:59 EB:395 ET:0 EL:3 ]
2024-04-02 19:58:17 us=762307 Local Options String (VER=V4): 'V4,dev-type tun,link-mtu 1559,tun-mtu 1500,proto TCPv4_CLIENT,ifconfig 10.10.4.1 10.10.4.2,keydir 1,cipher AES-128-CBC,auth SHA1,keysize 128,tls-auth,key-method 2,tls-client'
2024-04-02 19:58:17 us=762319 Expected Remote Options String (VER=V4): 'V4,dev-type tun,link-mtu 1559,tun-mtu 1500,proto TCPv4_SERVER,ifconfig 10.10.4.2 10.10.4.1,keydir 0,cipher AES-128-CBC,auth SHA1,keysize 128,tls-auth,key-method 2,tls-server'
2024-04-02 19:58:17 us=762331 TCP/UDP: Preserving recently used remote address: [AF_INET]xxxx:51199
2024-04-02 19:58:17 us=762362 Socket Buffers: R=[131072->131072] S=[16384->16384]
2024-04-02 19:58:17 us=762371 Attempting to establish TCP connection with [AF_INET]xxxx:51199 [nonblock]
2024-04-02 19:58:17 us=937632 TCP connection established with [AF_INET]xxxx:51199
2024-04-02 19:58:17 us=937679 TCP_CLIENT link local: (not bound)
2024-04-02 19:58:17 us=937689 TCP_CLIENT link remote: [AF_INET]xxxx:51199
2024-04-02 19:58:18 us=791085 Connection reset, restarting [-1]
2024-04-02 19:58:18 us=791173 TCP/UDP: Closing socket
2024-04-02 19:58:18 us=791200 SIGUSR1[soft,connection-reset] received, process restarting
2024-04-02 19:58:18 us=791215 Restart pause, 300 second(s)


服务端日志
2024-04-02 19:58:18 us=709684 TCP connection established with [AF_INET]x.x.x.x:37360
2024-04-02 19:58:18 us=709738 TCPv4_SERVER link local (bound): [AF_INET][undef]:51199
2024-04-02 19:58:18 us=709745 TCPv4_SERVER link remote: [AF_INET]x.x.x.x:37360
2024-04-02 19:58:18 us=709757 Server poll timeout, restarting
2024-04-02 19:58:18 us=709799 TCP/UDP: Closing socket
2024-04-02 19:58:18 us=709860 SIGUSR1[soft,server_poll] received, process restarting
2024-04-02 19:58:18 us=709880 net_route_v4_best_gw query: dst 0.0.0.0
2024-04-02 19:58:18 us=709965 net_route_v4_best_gw result: via 192.168.40.253 dev eth0
2024-04-02 19:58:18 us=709996 Re-using SSL/TLS context
2024-04-02 19:58:18 us=710069 Outgoing Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
2024-04-02 19:58:18 us=710081 Incoming Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
2024-04-02 19:58:18 us=710127 Control Channel MTU parms [ L:1559 D:1182 EF:68 EB:0 ET:0 EL:3 ]
2024-04-02 19:58:18 us=710194 Preserving previous TUN/TAP instance: tun0
2024-04-02 19:58:18 us=710205 Data Channel MTU parms [ L:1559 D:1450 EF:59 EB:395 ET:0 EL:3 ]
2024-04-02 19:58:18 us=710224 Local Options String (VER=V4): 'V4,dev-type tun,link-mtu 1559,tun-mtu 1500,proto TCPv4_SERVER,ifconfig 10.10.4.2 10.10.4.1,keydir 0,cipher AES-128-CBC,auth SHA1,keysize 128,tls-auth,key-method 2,tls-server'
2024-04-02 19:58:18 us=710229 Expected Remote Options String (VER=V4): 'V4,dev-type tun,link-mtu 1559,tun-mtu 1500,proto TCPv4_CLIENT,ifconfig 10.10.4.1 10.10.4.2,keydir 1,cipher AES-128-CBC,auth SHA1,keysize 128,tls-auth,key-method 2,tls-client'
2024-04-02 19:58:18 us=710282 Could not determine IPv4/IPv6 protocol. Using AF_INET
2024-04-02 19:58:18 us=710300 Socket Buffers: R=[131072->131072] S=[16384->16384]
2024-04-02 19:58:18 us=710314 Listening for incoming TCP connection on [AF_INET][undef]:51199
3829 次点击
所在节点    宽带症候群
57 条回复
fever
48 天前
@defunct9 在线求助老哥,感谢感谢
Jamy
48 天前
如果是国内连国外的话,请加上能穿墙的代理
wws2023
48 天前
楼上正解,你没一个能转发的 怎么直连
fever
48 天前
@Jamy #2
@wws2023 #3 同样配置只是改变验证方式 换成静态密钥( static-key ),是能连接成功的.只是因为一定要用 tls 验证方式,这个验证方式和翻墙也有关系的吗
fever
48 天前
@wws2023 #3
@Jamy #2 有附加 append
mightybruce
48 天前
改用 ssl-vpn 吧,openvpn 有一定阻挡概率的。
建议 softetether vpn , 这个比较稳定。
totoro52
48 天前
GFW 能百分之 99 识别出 openvpn 并且阻断握手,你最好别在尝试链接了, 秒封 IP 的,不要用 openvpn 这种古老的东西去翻墙了,如果不是翻墙就不要用国外机器
fever
48 天前
@totoro52 #7 不是翻墙 就是为了 把不同区域的服务器 打通 国内和国外
JensenQian
48 天前
@fever 在大墙眼里,这和爬墙没区别,谁知道你干啥
totoro52
48 天前
@fever #8 那也不要用 openvpn 替代 openvpn 的东西很多的, 这东西已经被 GFW 分析得彻彻底底的了,如果你还是想要用它,就像楼上所说的, 你可以套一个加密的代理去作为前置
shuimugan
48 天前
最近刚好在折腾这个,直连外面 2 周没啥问题,用 https://github.com/dockovpn/dockovpn 这个搭建的,如果是 docker compose 运行结合 https://github.com/dockovpn/dockovpn/issues/221 这个就搞定了,客户端也是 tls 。
有一说一 openvpn 真的老旧又落后,也就是为了直接在华硕的路由器上使用才选的,平时我都用 wireguard 。
shakeit
48 天前
这个问题好像遇到过,后来应该是改的配置
route-nopull
route 192.168.255.0 255.255.255.0 vpn_gateway
当时是为了访问某些不具备外网 IP 的机器,不过后来像楼上老哥一样改用 docker 部署了
Remember
48 天前
openvpn 没有任何价值了,无论是不是为了翻墙,都会被墙识别出来秒封。
busier
48 天前
在我们地区,手机联通卡,出门在外通过 OpenVPN 连接回家里电信宽带,连几次后,就会被阻断。阻断时,换联通卡+wg 就没问题,或者立马切回电信手机卡+openvpn 也没问题

可见即使在大陆内网,openvpn 也可能被阻断。
newlifeinsc
48 天前
把你 server 和 client 的版本列出来下呢。 我遇到过一个类似情况,用 linux 的 client 连上去后马上又 Connection reset, restarting 。 但 windows 的 client 就是 ok 的。后来最终排查到是 linux 的 client 版本过高,server 版本过低。client 已经不支持 server 用的加密方式了。
defunct9
47 天前
@fever 开 ssh ,让我上去看看
defunct9
47 天前
@fever “不是翻墙 就是为了 把不同区域的服务器 打通 国内和国外”。刚搞了一个,把阿里云的国内和日本打通,不用它的企业网。用 ipsec
ik
47 天前
没记错的话 openvpn 可以前置代理。 或者研究一下 xray 的"任意门"做端口转发, 可以实现的方式就很多了。
参考这个 https://www.40huo.cn/blog/wireguard-over-vless.html
YaD2x
47 天前
借楼问一个 openvpn 问题,困扰我多天了。服务端部署在阿里云,有个客户端在 aws , 现在 aws ping 阿里云服务端可通, 从阿里云 ping aws 的私网 ip 不通。尝试添加了各种路由都不通。aws 的 ip 是 172.31.38.233/20 vpn 服务端 ip 是 172.24.135.95/20 vip 是 net 10.8.0.1 peer 10.8.0.2/32 scope global tun0 我之前发过一条帖子,但是没人理我哈哈哈。https://www.v2ex.com/t/1025209#reply0
YaD2x
47 天前
@defunct9 必须要用这个 ipsec 吗 我想 aws 和阿里云的通信 应该怎么做呀

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1029240

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX