Linux 发行版中 OpenVPN 与 Tor 的问题

Linux 发行版中 OpenVPN 与 Tor 的问题

我正在尝试通过 Tor Socks Proxy 连接到 OpenVPN 服务器。

我已经编辑了 .ovpn 文件socks-proxy 127.0.0.1socks-proxy-retry添加了选项,但没有成功。

问题如下:一切顺利,我看到了Initialization Sequence Completed消息,但几秒钟后,openvpn 客户端尝试多次重新连接并给出错误 115 超时,

我目前正在使用 Ubuntu 16.04

以下是日志:

Sat Sep 17 16:38:08 2016 DEPRECATED OPTION: http-proxy-retry and socks-proxy-retry: In OpenVPN 2.4 proxy connection retries are handled like regular connections. Use connect-retry-max 1 to get a similar behavior as before.
Sat Sep 17 16:38:08 2016 OpenVPN 2.3_git x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [MH/PKTINFO] [IPv6] built on Sep 17 2016
Sat Sep 17 16:38:08 2016 library versions: OpenSSL 1.0.2g-fips  1 Mar 2016, LZO 2.08
Sat Sep 17 16:38:08 2016 WARNING: No server certificate verification method has been enabled.  See http://openvpn.net/howto.html#mitm for more info.
Sat Sep 17 16:38:08 2016 TCP/UDP: Preserving recently used remote address: [AF_INET]127.0.0.1:9050
Sat Sep 17 16:38:08 2016 Socket Buffers: R=[87380->87380] S=[16384->16384]
Sat Sep 17 16:38:08 2016 Attempting to establish TCP connection with [AF_INET]127.0.0.1:9050 [nonblock]
Sat Sep 17 16:38:08 2016 TCP connection established with [AF_INET]127.0.0.1:9050
Sat Sep 17 16:38:08 2016 TCP_CLIENT link local: (not bound)
Sat Sep 17 16:38:08 2016 TCP_CLIENT link remote: [AF_INET]127.0.0.1:9050
Sat Sep 17 16:38:09 2016 TLS: Initial packet from [AF_INET]127.0.0.1:9050, sid=8f81fa06 41348202
Sat Sep 17 16:38:10 2016 VERIFY OK: depth=0, CN=49njfbdc.com, O=m4jhl x3avvp9iijj, C=US
Sat Sep 17 16:38:12 2016 Control Channel: TLSv1, cipher TLSv1/SSLv3 DHE-RSA-AES256-SHA, 2048 bit RSA
Sat Sep 17 16:38:12 2016 [49njfbdc.com] Peer Connection Initiated with [AF_INET]127.0.0.1:9050
Sat Sep 17 16:38:13 2016 SENT CONTROL [49njfbdc.com]: 'PUSH_REQUEST' (status=1)
Sat Sep 17 16:38:14 2016 PUSH: Received control message: 'PUSH_REPLY,ping 3,ping-restart 10,ifconfig 10.211.1.73 10.211.1.74,dhcp-option DNS 10.211.254.254,dhcp-option DNS 8.8.8.8,route-gateway 10.211.1.74,redirect-gateway def1'
Sat Sep 17 16:38:14 2016 OPTIONS IMPORT: timers and/or timeouts modified
Sat Sep 17 16:38:14 2016 OPTIONS IMPORT: --ifconfig/up options modified
Sat Sep 17 16:38:14 2016 OPTIONS IMPORT: route options modified
Sat Sep 17 16:38:14 2016 OPTIONS IMPORT: route-related options modified
Sat Sep 17 16:38:14 2016 OPTIONS IMPORT: --ip-win32 and/or --dhcp-option options modified
Sat Sep 17 16:38:14 2016 Data Channel Encrypt: Cipher 'AES-128-CBC' initialized with 128 bit key
Sat Sep 17 16:38:14 2016 Data Channel Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Sat Sep 17 16:38:14 2016 Data Channel Decrypt: Cipher 'AES-128-CBC' initialized with 128 bit key
Sat Sep 17 16:38:14 2016 Data Channel Decrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Sat Sep 17 16:38:14 2016 ROUTE_GATEWAY 192.168.1.254/255.255.255.0 IFACE=*hidden* HWADDR=*hidden*
Sat Sep 17 16:38:14 2016 TUN/TAP device tun0 opened
Sat Sep 17 16:38:14 2016 TUN/TAP TX queue length set to 100
Sat Sep 17 16:38:14 2016 do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0
Sat Sep 17 16:38:14 2016 /sbin/ifconfig tun0 10.211.1.73 pointopoint 10.211.1.74 mtu 1500
Sat Sep 17 16:38:14 2016 /sbin/route add -net 127.0.0.1 netmask 255.255.255.255 gw 192.168.1.254
Sat Sep 17 16:38:14 2016 /sbin/route add -net 0.0.0.0 netmask 128.0.0.0 gw 10.211.1.74
Sat Sep 17 16:38:14 2016 /sbin/route add -net 128.0.0.0 netmask 128.0.0.0 gw 10.211.1.74
Sat Sep 17 16:38:14 2016 Initialization Sequence Completed
Sat Sep 17 16:38:24 2016 [49njfbdc.com] Inactivity timeout (--ping-restart), restarting
Sat Sep 17 16:38:24 2016 SIGUSR1[soft,ping-restart] received, process restarting
Sat Sep 17 16:38:24 2016 Restart pause, 5 second(s)
Sat Sep 17 16:38:29 2016 WARNING: No server certificate verification method has been enabled.  See http://openvpn.net/howto.html#mitm for more info.
Sat Sep 17 16:38:29 2016 TCP/UDP: Preserving recently used remote address: [AF_INET]127.0.0.1:9050
Sat Sep 17 16:38:29 2016 Socket Buffers: R=[87380->87380] S=[16384->16384]
Sat Sep 17 16:38:29 2016 Attempting to establish TCP connection with [AF_INET]127.0.0.1:9050 [nonblock]
Sat Sep 17 16:38:29 2016 TCP connection established with [AF_INET]127.0.0.1:9050
Sat Sep 17 16:38:34 2016 recv_socks_reply: TCP port read timeout expired: Operation now in progress (errno=115)
Sat Sep 17 16:38:34 2016 SIGUSR1[soft,init_instance] received, process restarting
Sat Sep 17 16:38:34 2016 Restart pause, 5 second(s)
^CSat Sep 17 16:38:36 2016 /sbin/route del -net 127.0.0.1 netmask 255.255.255.255
Sat Sep 17 16:38:36 2016 /sbin/route del -net 0.0.0.0 netmask 128.0.0.0
Sat Sep 17 16:38:36 2016 /sbin/route del -net 128.0.0.0 netmask 128.0.0.0
Sat Sep 17 16:38:36 2016 Closing TUN/TAP interface
Sat Sep 17 16:38:36 2016 /sbin/ifconfig tun0 0.0.0.0
Sat Sep 17 16:38:36 2016 SIGINT[hard,init_instance] received, process exiting

这是 .ovpn 文件:

socks-proxy 127.0.0.1 9150
socks-proxy-retry
###############################################################################
# OpenVPN 2.0 Sample Configuration File
# for PacketiX VPN / SoftEther VPN Server
# 
# !!! AUTO-GENERATED BY SOFTETHER VPN SERVER MANAGEMENT TOOL !!!
# 
# !!! YOU HAVE TO REVIEW IT BEFORE USE AND MODIFY IT AS NECESSARY !!!
# 
# This configuration file is auto-generated. You might use this config file
# in order to connect to the PacketiX VPN / SoftEther VPN Server.
# However, before you try it, you should review the descriptions of the file
# to determine the necessity to modify to suitable for your real environment.
# If necessary, you have to modify a little adequately on the file.
# For example, the IP address or the hostname as a destination VPN Server
# should be confirmed.
# 
# Note that to use OpenVPN 2.0, you have to put the certification file of
# the destination VPN Server on the OpenVPN Client computer when you use this
# config file. Please refer the below descriptions carefully.


###############################################################################
# Specify the type of the layer of the VPN connection.
# 
# To connect to the VPN Server as a "Remote-Access VPN Client PC",
#  specify 'dev tun'. (Layer-3 IP Routing Mode)
#
# To connect to the VPN Server as a bridging equipment of "Site-to-Site VPN",
#  specify 'dev tap'. (Layer-2 Ethernet Bridgine Mode)

dev tun


###############################################################################
# Specify the underlying protocol beyond the Internet.
# Note that this setting must be correspond with the listening setting on
# the VPN Server.
# 
# Specify either 'proto tcp' or 'proto udp'.

proto tcp


###############################################################################
# The destination hostname / IP address, and port number of
# the target VPN Server.
# 
# You have to specify as 'remote <HOSTNAME> <PORT>'. You can also
# specify the IP address instead of the hostname.
# 
# Note that the auto-generated below hostname are a "auto-detected
# IP address" of the VPN Server. You have to confirm the correctness
# beforehand.
# 
# When you want to connect to the VPN Server by using TCP protocol,
# the port number of the destination TCP port should be same as one of
# the available TCP listeners on the VPN Server.
# 
# When you use UDP protocol, the port number must same as the configuration
# setting of "OpenVPN Server Compatible Function" on the VPN Server.

remote 180.183.122.187 1639


###############################################################################
# The HTTP/HTTPS proxy setting.
# 
# Only if you have to use the Internet via a proxy, uncomment the below
# two lines and specify the proxy address and the port number.
# In the case of using proxy-authentication, refer the OpenVPN manual.

;http-proxy-retry
;http-proxy [proxy server] [proxy port]


###############################################################################
# The encryption and authentication algorithm.
# 
# Default setting is good. Modify it as you prefer.
# When you specify an unsupported algorithm, the error will occur.
# 
# The supported algorithms are as follows:
#  cipher: [NULL-CIPHER] NULL AES-128-CBC AES-192-CBC AES-256-CBC BF-CBC
#          CAST-CBC CAST5-CBC DES-CBC DES-EDE-CBC DES-EDE3-CBC DESX-CBC
#          RC2-40-CBC RC2-64-CBC RC2-CBC
#  auth:   SHA SHA1 MD5 MD4 RMD160

cipher AES-128-CBC
auth SHA1


###############################################################################
# Other parameters necessary to connect to the VPN Server.
# 
# It is not recommended to modify it unless you have a particular need.

resolv-retry infinite
nobind
persist-key
persist-tun
client
verb 3
#auth-user-pass


###############################################################################
# The certificate file of the destination VPN Server.
# 
# The CA certificate file is embedded in the inline format.
# You can replace this CA contents if necessary.
# Please note that if the server certificate is not a self-signed, you have to
# specify the signer's root certificate (CA) here.

答案1

使用其他使用 socks 的程序测试 socks 代理。如果它们可以工作,而 OpenVPN 不行,那么问题就出在你的 OpenVPN 配置上。你的日志条目看起来[*.opengw.net]有点可疑 - 那不是一个有效的主机名!你可能希望至少在此处发布部分配置文件,以便我们查看是否有任何可疑之处。(我使用 OpenVPN 已有大约 8 年了)。

示例:您通过 socks 代理 (proxychains?) 打开 telnet 连接。使用适当的端口号打开到示例中的主机地址的会话。协议是 TCP。如果 telnet 连接有效(您应该在提示符下看到“垃圾”字符),则表示 socks 代理工作正常。

如果 openvpn 无法连接,但 telnet 可以,那么您的 OVPN 文件中可能缺少 socks 代理的身份验证信息,或者 socks 版本/实现不兼容。

相关内容