OpenVPN 无法通过配置文件作为服务启动

OpenVPN 无法通过配置文件作为服务启动

如果我从 CLI 运行 OpenVPN,它可以很好地与我的配置文件配合使用:

openvpn server.conf

但是如果我尝试将其作为服务启动,它可以正常启动,不会出错,但它不会加载我的 conf 文件,因为没有结果tun设备ifconfig

我已AUTOSTART设置all/etc/init.d/openvpn

在此处输入图片描述

但快速ifconfig显示它没有启动。我知道它没有加载我的配置文件,因为日志文件没有创建,但没有来自 OpenVPN 的错误。

在此处输入图片描述

这是在 Ubuntu 16.04.3 上全新安装的 OpenVPN。

编辑

根据下面的评论,我也尝试了多次systemctl,但只是出现错误:

在此处输入图片描述 在此处输入图片描述

我知道该配置文件有效,因为我可以从 CLI 运行它,openvpn server.conf而且它可以工作。

编辑2

日志:

Jan 11 14:31:37 cloud systemd[1]: [email protected]: Unit entered failed state.
Jan 11 14:31:37 cloud systemd[1]: [email protected]: Failed with result 'exit-code'.
Jan 11 16:06:07 cloud systemd[1]: Starting OpenVPN connection to server...
Jan 11 16:06:07 cloud ovpn-server[4726]: OpenVPN 2.3.10 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [PKCS11] [MH] [IPv6] built on Jun 22 2017
Jan 11 16:06:07 cloud ovpn-server[4726]: library versions: OpenSSL 1.0.2g  1 Mar 2016, LZO 2.08
Jan 11 16:06:07 cloud ovpn-server[4726]: daemon() failed or unsupported: Resource temporarily unavailable (errno=11)
Jan 11 16:06:07 cloud ovpn-server[4726]: Exiting due to fatal error
Jan 11 16:06:07 cloud systemd[1]: [email protected]: Control process exited, code=exited status=1
Jan 11 16:06:07 cloud systemd[1]: Failed to start OpenVPN connection to server.
Jan 11 16:06:07 cloud systemd[1]: [email protected]: Unit entered failed state.
Jan 11 16:06:07 cloud systemd[1]: [email protected]: Failed with result 'exit-code'.
Jan 12 09:55:35 cloud systemd[1]: Starting OpenVPN connection to server...
Jan 12 09:55:35 cloud ovpn-server[12133]: Current Parameter Settings:
Jan 12 09:55:35 cloud ovpn-server[12133]:   config = '/etc/openvpn/server.conf'
Jan 12 09:55:35 cloud ovpn-server[12133]:   mode = 1
Jan 12 09:55:35 cloud ovpn-server[12133]:   persist_config = DISABLED
Jan 12 09:55:35 cloud ovpn-server[12133]:   persist_mode = 1
Jan 12 09:55:35 cloud ovpn-server[12133]:   show_ciphers = DISABLED
Jan 12 09:55:35 cloud ovpn-server[12133]:   show_digests = DISABLED
Jan 12 09:55:35 cloud systemd[1]: [email protected]: Control process exited, code=exited status=1
Jan 12 09:55:35 cloud systemd[1]: Failed to start OpenVPN connection to server.
Jan 12 09:55:35 cloud systemd[1]: [email protected]: Unit entered failed state.
Jan 12 09:55:35 cloud systemd[1]: [email protected]: Failed with result 'exit-code'.

答案1

这个问题和另一篇发表在 Ask! Ubuntu 上的文章。 这使固定

我发现有效的方法是注释掉 /lib/systemd/system/ 中的 LimitNPROC 行[电子邮件保护]

答案2

当我尝试运行我的服务器配置时,我发现它无法重新分配相同的端口,因此我重新启动服务器并解决了该问题。

ubuntu@VPNSERVER:/etc/openvpn$ sudo openvpn server.conf
Fri May 28 18:09:18 2021 OpenVPN 2.4.4 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on Apr 27 2021
Fri May 28 18:09:18 2021 library versions: OpenSSL 1.1.1  11 Sep 2018, LZO 2.08
Fri May 28 18:09:18 2021 ECDH curve prime256v1 added
Fri May 28 18:09:18 2021 Outgoing Control Channel Encryption: Cipher 'AES-256-CTR' initialized with 256 bit key
Fri May 28 18:09:18 2021 Outgoing Control Channel Encryption: Using 256 bit message hash 'SHA256' for HMAC authentication
Fri May 28 18:09:18 2021 Incoming Control Channel Encryption: Cipher 'AES-256-CTR' initialized with 256 bit key
Fri May 28 18:09:18 2021 Incoming Control Channel Encryption: Using 256 bit message hash 'SHA256' for HMAC authentication
Fri May 28 18:09:18 2021 TUN/TAP device tun1 opened
Fri May 28 18:09:18 2021 TUN/TAP TX queue length set to 100
Fri May 28 18:09:18 2021 do_ifconfig, tt->did_ifconfig_ipv6_setup=0
Fri May 28 18:09:18 2021 /sbin/ip link set dev tun1 up mtu 1500
Fri May 28 18:09:18 2021 /sbin/ip addr add dev tun1 10.8.0.1/24 broadcast 10.8.0.255
Fri May 28 18:09:18 2021 Could not determine IPv4/IPv6 protocol. Using AF_INET
Fri May 28 18:09:18 2021 Socket Buffers: R=[212992->212992] S=[212992->212992]
# ===>>>>>  blow line was error that I found <<<<<<<===== #
# Fri May 28 18:09:18 2021 TCP/UDP: Socket bind failed on local address # [AF_INET][undef]:1122: Address already in use (errno=98)
Fri May 28 18:09:18 2021 Exiting due to fatal error
Fri May 28 18:09:18 2021 Closing TUN/TAP interface
Fri May 28 18:09:18 2021 /sbin/ip addr del dev tun1 10.8.0.1/24


   **ubuntu@VPNSERVER:/etc/openvpn$ sudo reboot**

在你的情况下,OPenVpn 状态和重启命令可能类似于

systemctl status [email protected]
 systemctl restart [email protected]

相关内容