Networking

VPN 在 3 分 30 秒後斷開連接

  • April 30, 2020

我已經使用https://github.com/hwdsl2/setup-ipsec-vpn中的腳本設置了一個 vpn 伺服器。

我正在從我的 Mac 連接到我在 Ubuntu 伺服器上執行的個人 vpn。

它會在 3 分 30 秒後斷開連接。

這是我從 Mac vpn 客戶端日誌中看到的內容:

tail -100f /var/log/ppp.log

Mon Apr 27 13:34:51 2020 : L2TP received StopCCN
Mon Apr 27 13:34:51 2020 : L2TP hangup
Mon Apr 27 13:34:51 2020 : ipcp: down
Mon Apr 27 13:34:51 2020 : Connection terminated.
Mon Apr 27 13:34:51 2020 : L2TP clearing port-mapping for en0
Mon Apr 27 13:34:51 2020 : Connect time 2.6 minutes.
Mon Apr 27 13:34:51 2020 : Sent 1028457 bytes, received 5762343 bytes.
Mon Apr 27 13:34:51 2020 : L2TP disconnecting...
Mon Apr 27 13:34:51 2020 : L2TP sent CDN
Mon Apr 27 13:34:51 2020 : L2TP sent StopCCN
Mon Apr 27 13:34:51 2020 : L2TP disconnected

這是我在伺服器端看到的:

tail -f /var/log/auth.log

Apr 27 10:34:20 ip-172-31-40-152 pluto[3459]: "l2tp-psk"[2] 149.0.138.78 #1: IKEv1 DPD action - clearing connection kind CK_INSTANCE
Apr 27 10:34:20 ip-172-31-40-152 pluto[3459]: "l2tp-psk" #2: deleting state (STATE_QUICK_R2) aged 120.084s and sending notification
Apr 27 10:34:20 ip-172-31-40-152 pluto[3459]: "l2tp-psk" #2: ESP traffic information: in=1MB out=6MB
Apr 27 10:34:20 ip-172-31-40-152 pluto[3459]: "l2tp-psk" #1: deleting state (STATE_MAIN_R3) aged 121.125s and sending notification
Apr 27 10:34:20 ip-172-31-40-152 pluto[3459]: "l2tp-psk"[2] 149.0.138.78: deleting connection "l2tp-psk"[2] 149.0.138.78 instance with peer 149.0.138.78 {isakmp=#0/ipsec=#0}


tail -f /var/log/syslog

Apr 27 10:52:03 ip-172-31-40-152 xl2tpd[3043]: Maximum retries exceeded for tunnel 39830.  Closing.
Apr 27 10:52:03 ip-172-31-40-152 pppd[4266]: Modem hangup
Apr 27 10:52:03 ip-172-31-40-152 systemd-networkd[700]: ppp0: Link DOWN
Apr 27 10:52:03 ip-172-31-40-152 pppd[4266]: Connect time 3.6 minutes.
Apr 27 10:52:03 ip-172-31-40-152 systemd-networkd[700]: ppp0: Lost carrier
Apr 27 10:52:03 ip-172-31-40-152 pppd[4266]: Sent 94682 bytes, received 107101 bytes.
Apr 27 10:52:03 ip-172-31-40-152 systemd-timesyncd[526]: Network configuration changed, trying to establish connection.
Apr 27 10:52:03 ip-172-31-40-152 xl2tpd[3043]: Terminating pppd: sending TERM signal to pid 4266
Apr 27 10:52:03 ip-172-31-40-152 xl2tpd[3043]: Connection 24 closed to 149.0.138.78, port 59243 (Timeout)
Apr 27 10:52:03 ip-172-31-40-152 pppd[4266]: Connection terminated.
Apr 27 10:52:03 ip-172-31-40-152 pppd[4266]: Exit.
Apr 27 10:52:03 ip-172-31-40-152 systemd-timesyncd[526]: Synchronized to time server 91.189.91.157:123 (ntp.ubuntu.com).

伺服器在 AWS 上執行。我嘗試更改伺服器 IP 地址,從圖像重新創建伺服器。但他們沒有工作。

(!)我以前連接VPN伺服器沒有麻煩。更換ISP後,我開始遇到這個問題。ISP 支持人員對此問題一無所知。

設置可能有什麼問題?

在嘗試了一些配置更改後/etc/ipsec.conf,我發現增加 dpdtimeout 解決了我的問題:

我將dpdtimeout值從 120 更新為 1200。

dpdtimeout=1200

現在,我不再與 VPN 伺服器斷開連接。

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