搭建脚本

1. 
wget --no-check-certificate https://raw.githubusercontent.com/teddysun/across/master/l2tp.sh
chmod +x l2tp.sh
sudo ./l2tp.sh
2. 
wget https://git.io/vpnsetup -O vpnsetup.sh

重启服务

ubuntu@ip-172-31-29-17:~$ sudo systemctl restart ipsec.service
ubuntu@ip-172-31-29-17:~$ sudo service xl2tpd restart
ubuntu@ip-172-31-29-17:~$ 
ubuntu@ip-172-31-29-17:~$ sudo systemctl status ipsec.service

查看 udp 端口监听状态


[ubuntu@ip-172-31-29-17:~$ netstat -nupl
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
udp        0      0 127.0.0.1:4500          0.0.0.0:*                           -               
udp        0      0 172.31.29.17:4500       0.0.0.0:*                           -               
udp        0      0 0.0.0.0:4500            0.0.0.0:*                           -               
udp        0      0 127.0.0.1:500           0.0.0.0:*                           -               
udp        0      0 172.31.29.17:500        0.0.0.0:*                           -               
udp        0      0 0.0.0.0:500             0.0.0.0:*                           -               
udp        0      0 0.0.0.0:68              0.0.0.0:*                           -               
udp        0      0 0.0.0.0:1701            0.0.0.0:*                           -               
udp6       0      0 :::4500                 :::*                                -               
udp6       0      0 ::1:500                 :::*                                -               
udp6       0      0 :::500                  :::*                                -     
# 查看连接日志
[ubuntu@ip-172-31-29-17:~$ tail -f /var/log/syslog
Dec  8 10:09:39 ip-172-31-29-17 pppd[3436]: pppd 2.4.7 started by root, uid 0
Dec  8 10:09:39 ip-172-31-29-17 pppd[3436]: Using interface ppp0
Dec  8 10:09:39 ip-172-31-29-17 pppd[3436]: Connect: ppp0 <--> /dev/pts/1
Dec  8 10:09:43 ip-172-31-29-17 charon: 09[KNL] 192.168.42.1 appeared on ppp0
Dec  8 10:09:43 ip-172-31-29-17 charon: 02[KNL] 192.168.42.1 disappeared from ppp0
Dec  8 10:09:43 ip-172-31-29-17 charon: 15[KNL] 192.168.42.1 appeared on ppp0
Dec  8 10:09:43 ip-172-31-29-17 charon: 16[KNL] interface ppp0 activated
Dec  8 10:09:43 ip-172-31-29-17 pppd[3436]: Cannot determine ethernet address for proxy ARP
Dec  8 10:09:43 ip-172-31-29-17 pppd[3436]: local  IP address 192.168.42.1
Dec  8 10:09:43 ip-172-31-29-17 pppd[3436]: remote IP address 192.168.42.10
Dec  8 10:09:56 ip-172-31-29-17 pppd[3436]: LCP terminated by peer (User request)
Dec  8 10:09:56 ip-172-31-29-17 pppd[3436]: Connect time 0.3 minutes.
Dec  8 10:09:56 ip-172-31-29-17 pppd[3436]: Sent 276380 bytes, received 59270 bytes.