Ubuntu

AWS 實例上的 OpenVPN 中斷連接

  • June 6, 2016

摘要:我想在 EC2 實例( Ubuntu 16.04)上設置 OpenVPN 伺服器。重新啟動後無法配置其介面。

詳情

  • 圖像安裝正常,重啟正常
  • apt update ; apt get openvpn正確引入 OpenVPN
  • 從命令行啟動時,使用共享密鑰的最小測試設置有效(udp/1945正在偵聽)

在這個階段一切正常。

當重新啟動這台機器時,它的狀態檢查失敗

在此處輸入圖像描述

伺服器日誌顯示機器未能提升其網路介面:

(...)

[    6.624548] cloud-init[519]: Cloud-init v. 0.7.7 running 'init-local' at Mon, 06 Jun 2016 13:36:41 +0000. Up 6.36 seconds.
OK Started Initial cloud-init job (pre-networking).
OK Reached target Network (Pre).
        Starting Raise network interfaces...
OK Started ifup for tun0.
OK Found device /sys/subsystem/net/devices/tun0.
* A start job is running for Raise network interfaces (7s / 5min 1s)

(...)

* A start job is running for Raise network interfaces (30s / 5min 1s)
* A start job is running for Raise network interfaces (30s / 5min 30s)
FAILED Failed to start Raise network interfaces.
See 'systemctl status networking.service' for details.
DEPEND Dependency failed for Initial cloud... job (metadata service crawler).
OK Reached target Network.
        Starting OpenVPN service...
        Starting OpenBSD Secure Shell server...
(...)

Ubuntu 16.04 LTS ip-172-31-16-245 ttyS0

ip-172-31-16-245 login: 

EC2 實例配置其介面的具體方式是什麼?

硬體伺服器上的相同設置可以正常工作,所以我認為這一定是 EC2 特有的。

OpenVPN ( ) 的 systemd 服務文件/lib/systemd/system/openvpn@.service必須使用以下After=network.target network-online.target條目進行更新:

[Unit]
Description=OpenVPN connection to %i
PartOf=openvpn.service
ReloadPropagatedFrom=openvpn.service
Before=systemd-user-sessions.service
After=network.target network-online.target # This is needed
Documentation=man:openvpn(8)
Documentation=https://community.openvpn.net/openvpn/wiki/Openvpn23ManPage
Documentation=https://community.openvpn.net/openvpn/wiki/HOWTO

所有功勞歸於 sc250024 ,他在 AWS 論壇上發布了解決方案。

編輯:向Canonical送出了一個錯誤。至今沒有任何進展。

引用自:https://serverfault.com/questions/782237