mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bak
curl -O http://mirrors.aliyun.com/repo/Centos-7.repo
mv Centos-7.repo /etc/yum.repos.d/CentOS-Base.repo
yum clean all
yum makecache
yum install -y epel-release
yum install NetworkManager-l2tp
con-name填 连接名称,ifname后的名称为 网卡名称 。文件生成为/etc/NetworkManager/system-connections/connectionName
nmcli connection add con-name connectionName type vpn vpn-type org.freedesktop.NetworkManager.l2tp ifname enp0s3
在生成的文件中的[vpn]下修改为如下形式。gateway填VPN的IP,ipsec-psk填ipsec密码,user填账号名。
[vpn]
gateway=IP
ipsec-psk=psk
password-flags=2
user=userName
service-type=org.freedesktop.NetworkManager.l2tp
/etc/init.d/network restart
输入命令后输入密码连接l2tp
nmcli con up connectionName --ask