我正在尝试在我的 openvpn 客户端上使用多个远程服务器。
基本上,我希望 openvpn 尝试第一个(即 fqdn),如果它无法连接,那么它应该转到第二个(即 ip 地址)。
从日志中我看到它只是不断尝试第一个而不会转到第二个......
我需要设置什么选项才能让它进入第二个吗?
到目前为止,我所设置的只是两条“远程”线路(例如):
remote my.fqdn.com 4000
remote 11.11.11.11 4000
为了进行测试,我特意将第一个远程行设置为一个不存在的域,希望它会失败并转到第二个“远程”条目,但这并没有发生
remote siuhsudf.sdfiuhsdfui.com 4000
remote 11.11.11.11 4000
这是一些日志。可以看出,它不会跳到第二个远程条目,只是继续重试不存在的远程服务器
Thu May 24 19:39:59 2018 us=429138 RESOLVE: Cannot resolve host address: siuhsudf.sdfiuhsdfui.com: Name or service not known
Thu May 24 19:39:59 2018 us=429208 Data Channel MTU parms [ L:1559 D:1450 EF:59 EB:12 ET:0 EL:3 ]
Thu May 24 19:39:59 2018 us=429263 Local Options String: 'V4,dev-type tun,link-mtu 1559,tun-mtu 1500,proto TCPv4_CLIENT,cipher AES-256-CBC,auth SHA1,keysize 256,key-method 2,tls-client'
Thu May 24 19:39:59 2018 us=429280 Expected Remote Options String: 'V4,dev-type tun,link-mtu 1559,tun-mtu 1500,proto TCPv4_SERVER,cipher AES-256-CBC,auth SHA1,keysize 256,key-method 2,tls-server'
Thu May 24 19:39:59 2018 us=429336 Local Options hash (VER=V4): '5cb3f8dc'
Thu May 24 19:39:59 2018 us=429358 Expected Remote Options hash (VER=V4): '898ae6c6'
Thu May 24 19:39:59 2018 us=429890 NOTE: chroot will be delayed because of --client, --pull, or --up-delay
Thu May 24 19:39:59 2018 us=429926 NOTE: UID/GID downgrade will be delayed because of --client, --pull, or --up-delay
Thu May 24 19:39:59 2018 us=449187 RESOLVE: Cannot resolve host address: siuhsudf.sdfiuhsdfui.com: Name or service not known
Thu May 24 19:39:59 2018 us=449444 TCP/UDP: Closing socket
Thu May 24 19:39:59 2018 us=449522 SIGTERM[soft,init_instance] received, process exiting
这是我的完整配置,供参考
##############################################
# client-side OpenVPN config file
# for connecting to multi-client server.
#
# This configuration can be used by multiple
# clients, however each client should have
# its own cert and key files.
##############################################
# Specify that we are a client and that we
# will be pulling certain config file directives
# from the server.
client
# CLIENT ACCEPTS SERVER OPTIONS
# The client should accept options pushed
# by the server
pull
# The hostname/IP and port of the server.
# You can have multiple remote entries
# to load balance between the servers.
remote siuhsudf.sdfiuhsdfui.com 4000
remote 11.11.11.11 4000
# Are we connecting to a TCP or
# UDP server? Use the same setting as
# on the server.
proto tcp-client
# Keep trying indefinitely to resolve the
# host name of the OpenVPN server. Very useful
# on machines which are not permanently connected
# to the internet such as laptops.
resolv-retry infinite
# Most clients don't need to bind to
# a specific local port number.
# nobind => do not bind
# #nobind => bind
#nobind
# It's a good idea to reduce the OpenVPN
# daemon's privileges after initialization.
user nobody
group nogroup
# After initialization, OpenVPN can only
# access a directory
# The directory can be empty
# OpenVPN process limitation
chroot /etc/openvpn/
# The persist options will try to avoid
# accessing certain resources on restart
# that may no longer be accessible because
# of the privilege downgrade.
persist-tun
#################################################
# Encryption
#################################################
# SSL/TLS root certificate (ca), certificate
# (cert), and private key (key). Each client
# and the server must have their own cert and
# key file. The server and all clients will
# use the same ca file.
#
# See the "easy-rsa" directory for a series
# of scripts for generating RSA certificates
# and private keys. Remember to use
# a unique Common Name for the server
# and each of the client certificates.
#
# Any X509 key management system can be used.
# OpenVPN can also use a PKCS #12 formatted key file
# (see "pkcs12" directive in man page).
# CA Public Key
ca /root/ca.crt
# Local certificate
cert /root/cert.crt
# Local key
key /root/cert.key
tls-client
# Select a cryptographic cipher.
# This config item must be copied to
# the client config file as well.
# Note that 2.4 client/server will automatically
# negotiate AES-256-GCM in TLS mode.
# See also the ncp-cipher option in the manpage
cipher AES-256-CBC
# For compression compatible with older clients use comp-lzo
# If you enable it here, you must also
# enable it in the client config file.
#comp-lzo
#################################################
# Network
#################################################
# Use the same setting as you are using on
# the server.
# On most systems, the VPN will not function
# unless you partially or fully disable
# the firewall for the TUN/TAP interface.
dev myvpn
dev-type tun
#################################################
# Logging
#################################################
# Output a short status file showing
# current connections, truncated
# and rewritten every minute.
status /var/logs//openvpn//myvpn-status.log 20
# By default, log messages will go to the syslog (or
# on Windows, if running as a service, they will go to
# the "\Program Files\OpenVPN\log" directory).
# Use log or log-append to override this default.
# "log" will truncate the log file on OpenVPN startup,
# while "log-append" will append to it. Use one
# or the other (but not both).
log /var/logs//openvpn//myvpn.log
# Set the appropriate level of log
# file verbosity.
#
# 0 is silent, except for fatal errors
# 4 is reasonable for general usage
# 5 and 6 can help to debug connection problems
# 9 is extremely verbose
verb 3
remap-usr1 SIGTERM
connect-retry-max 2
single-session
tls-exit
答案1
用户“ordex”在这里对此进行了“回答”:https://community.openvpn.net/openvpn/ticket/1069
您正在将 SIGUSR1 重新映射到 SIGTERM:
重新映射-usr1 SIGTERM
SIGUSR1 通常会被发送来中断当前上下文/会话并转到下一个可用会话。通过告诉 openvpn 使用 SIGTERM,您基本上会重置所有内容并从头开始。
然而,在我的特定情况下,如果我从客户端删除它(以及我使用它的原因)是,如果我的 openvpn 服务器无法访问,连接就会在客户端进程列表中“堆积”。