Alibaba Cloud Linux 上安装 L2TP
安装L2TP
sudo yum install -y xl2tpd ppp
配置 xl2tpd.conf
sudo vi /etc/xl2tpd/xl2tpd.conf
添加以下内容:
[global]
listen-addr = 0.0.0.0
[lns default]
ip range = 192.168.42.100-192.168.42.200
local ip = 192.168.42.1
require chap = yes
refuse pap = yes
require authentication = yes
name = LinuxVPNserver
ppp debug = yes
pppoptfile = /etc/ppp/options.xl2tpd
length bit = yes
配置options.xl2tpd
sudo vi /etc/ppp/options.xl2tpd
添加以下内容:
require-mschap-v2
ipcp-accept-local
ipcp-accept-remote
ms-dns 8.8.8.8
ms-dns 8.8.4.4
noccp
auth
#crtscts # 客户端连接不上可注销 或 modem 替代
idle 1800
mtu 1410
mru 1410
nodefaultroute
debug
lock
proxyarp
connect-delay 5000
如果以上还不能连接 请配置下面
require-mschap-v2 # 强制MSCHAPv2认证
refuse-eap
noccp
noauth
mtu 1410
mru 1410
添加用户认证
sudo vi /etc/ppp/chap-secrets
添加用户格式如下:
# Secrets for authentication using CHAP
# client server secret IP addresses
username * password *
添加IP转发
sudo vi /etc/sysctl.conf
添加以下内容
net.ipv4.ip_forward = 1
生效
sudo sysctl -p
启动服务并设置开机自启
sudo systemctl start xl2tpd #启动
sudo systemctl enable xl2tpd #设置开机启动
sudo systemctl restart xl2tpd # 重启
查看日志
journalctl -u xl2tpd -f