我一直在尝试在我的 CentOS 7 VPS 上安装 OpenVPN 访问服务器。然而,我遇到了很多问题。
最初,我遵循这个 DigitalOcean 指南,但在我使用它时遇到问题后,我后来发现我的意思是安装访问服务器。我发现这个 DigitalOcean 指南针对CentOS 6.5,刚刚将其适配到CentOS 7。
我开始怀疑是否遵循两个不同指南的说明导致了我的问题。我可以通过命令行启动该服务,但无法通过 Web 界面启动它。
$ sudo systemctl status [email protected]
[email protected] - OpenVPN Robust And Highly Flexible Tunneling Application On server
Loaded: loaded (/usr/lib/systemd/system/[email protected]; enabled)
Active: active (running) since Thu 2015-03-05 08:12:53 EST; 3s ago
Process: 1738 ExecStart=/usr/sbin/openvpn --daemon --writepid /var/run/openvpn/%i.pid --cd /etc/openvpn/ --config %i.conf (code=exited, status=0/SUCCESS)
Main PID: 1745 (openvpn)
CGroup: /system.slice/system-openvpn.slice/[email protected]
└─1745 /usr/sbin/openvpn --daemon --writepid /var/run/openvpn/server.pid --cd /etc/openvpn/ --config server.conf
Mar 05 08:12:53 arguru systemd[1]: Failed to read PID from file /var/run/openvpn/server.pid: Invalid argument
Mar 05 08:12:53 arguru openvpn[1745]: GID set to nobody
Mar 05 08:12:53 arguru openvpn[1745]: UID set to nobody
Mar 05 08:12:53 arguru openvpn[1745]: UDPv4 link local (bound): [undef]
Mar 05 08:12:53 arguru openvpn[1745]: UDPv4 link remote: [undef]
Mar 05 08:12:53 arguru openvpn[1745]: MULTI: multi_init called, r=256 v=256
Mar 05 08:12:53 arguru openvpn[1745]: IFCONFIG POOL: base=10.8.0.4 size=62, ipv6=0
Mar 05 08:12:53 arguru openvpn[1745]: IFCONFIG POOL LIST
Mar 05 08:12:53 arguru openvpn[1745]: Initialization Sequence Completed
Mar 05 08:12:53 arguru systemd[1]: Started OpenVPN Robust And Highly Flexible Tunneling Application On server.
但是,我从网络面板收到此错误。
我尝试搜索多个不同的资源,有些人说问题是 Web 界面没有以 root 身份启动 VPN,这就是发生 ifconfig 错误的原因,而有关绑定失败的第二个错误仅在我启动 OpenVPN 时发生通过命令行。
我意识到我在设置此问题时可能犯了一些错误,但我想知道如何在不重新安装整个操作系统的情况下修复此问题(此 VPS 用于我自己的学习和实验)。任何帮助表示赞赏!
答案1
对于消息“地址已在使用中”,我认为这是因为 https 也在 TCP 端口 443 上监听。
答案2
使用 Amazon Linux 2016.03 运行这个包为了让服务器在rpm install
成功后运行,我需要:
sudo ln -s /sbin/ifconfig /usr/sbin/ifconfig
openvpnas
无法执行的原因ifconfig
是因为它正在尝试运行/usr/sbin/ifconfig
。符号链接修复了它。
答案3
我已经解决了这个问题,我只是这样解决:
[root@linux1 openvpn]# vim server.conf
## Notify the client that when the server restarts so it
## can automatically reconnect.
;explicit-exit-notify 1
[root@linux1 openvpn]# systemctl restart openvpn@server
[root@linux1 openvpn]# systemctl status openvpn@server
● [email protected] - OpenVPN Robust And Highly Flexible Tunneling Application On server
Loaded: loaded (/usr/lib/systemd/system/[email protected]; disabled; vendor preset: disabled)
Active: active (running) since Sun 2017-02-05 20:33:57 ICT; 13s ago
Process: 11837 ExecStart=/usr/sbin/openvpn --daemon --writepid /var/run/openvpn/%i.pid --cd /etc/openvpn/ --config %i.conf (code=exited, status=0/SUCCESS)
Main PID: 11838 (openvpn)
CGroup: /system.slice/system-openvpn.slice/[email protected]
└─11838 /usr/sbin/openvpn --daemon --writepid /var/run/openvpn/ser...
Feb 05 20:33:57 linux1 openvpn[11838]: /usr/sbin/ip link set dev tun0 up mt...00
Feb 05 20:33:57 linux1 systemd[1]: Started OpenVPN Robust And Highly Flexib...r.
Feb 05 20:33:57 linux1 openvpn[11838]: /usr/sbin/ip addr add dev tun0 local....2
Feb 05 20:33:57 linux1 openvpn[11838]: /usr/sbin/ip route add 10.8.0.0/24 v....2
Feb 05 20:33:57 linux1 openvpn[11838]: UDPv4 link local (bound): [undef]
Feb 05 20:33:57 linux1 openvpn[11838]: UDPv4 link remote: [undef]
Feb 05 20:33:57 linux1 openvpn[11838]: MULTI: multi_init called, r=256 v=256
Feb 05 20:33:57 linux1 openvpn[11838]: IFCONFIG POOL: base=10.8.0.4 size=62...=0
Feb 05 20:33:57 linux1 openvpn[11838]: IFCONFIG POOL LIST
Feb 05 20:33:57 linux1 openvpn[11838]: Initialization Sequence Completed
Hint: Some lines were ellipsized, use -l to show in full.