Ubuntu24.04部署L2TP

需要安装的包

bash 复制代码
apt-get install xl2tpd

配置

修改:/etc/xl2tpd/xl2tpd.conf

bash 复制代码
[global]
auth file = /etc/ppp/chap-secrets
[lns default]
; 分配给客户端的ip地址段
ip range = 192.168.24.100-192.168.24.200
; 本机ppp端ip地址
local ip = 192.168.24.1
require chap = yes
refuse pap = yes
require authentication = yes
name = Linuxvpnserver
ppp debug = yes
pppoptfile = /etc/ppp/options.xl2tpd
length bit = yes

更改DNS:/etc/ppp/options

bash 复制代码
ms-dns 192.168.7.1

修改/etc/ppp/chap-secrets

增加拨号用户和密码,一行一个,一行有4个字段分别是,第一列是用户名,第二列是server即为options.xl2tp中的name,参数*代表所有,第三列是密码,第四列是允许的IP(*为全部允许),用tab分隔

bash 复制代码
# Secrets for authentication using CHAP
# client	server	secret			IP addresses
root	*	root123	*

路由转发配置iptables

bash 复制代码
iptables -t nat -A POSTROUTING -s 192.168.24.0/24 -j SNAT --to-source 192.168.7.207
iptables -t nat -A POSTROUTING -o ens33 -j MASQUERADE

sudo iptables -t nat -L -n
iptables -t nat -D POSTROUTING 1
# iptables持久化
sudo apt-get install iptables-persistent

编辑/etc/sysctl.conf

bash 复制代码
net.ipv4.ip_forward = 1

运行命令生效

复制代码
sysctl -p

路由器添加端口转发 1701、4500、500

相关推荐
Web极客码32 分钟前
什么是WHMCS?
服务器·whmcs
goyeer1 小时前
【ITIL4】- 服务价值体系
大数据·运维·信息化·自动运维·itil
精益数智小屋1 小时前
设备维护方案核心功能拆解:一套好的设备维护方案如何解决设备突发故障
大数据·运维·网络·数据库·人工智能·面试·自动化
SWAGGY..1 小时前
Linux系统编程:(一)基础指令详解
linux·运维·服务器
Agent产品评测局1 小时前
设备运维自动化预警系统,从0到1落地实操方法:2026企业级架构与智能体选型全指南
运维·人工智能·ai·chatgpt·架构·自动化
一池秋_1 小时前
etc/sudo.conf is owned by uid 10258, should be 0解决
linux·运维·服务器
dingdingfish1 小时前
TLPI 第19 章 练习:Monitoring File Events
linux·inotify·tlpi·exercise
Bert.Cai1 小时前
Linux basename命令详解
linux·运维·服务器
源远流长jerry1 小时前
Linux 本机网络通信机制深度解析:Loopback 设备原理
linux·运维·服务器·网络·tcp/ip·nginx·负载均衡
一只小bit2 小时前
Docker 镜像制作:包含自定义镜像及常用命令
运维·docker·容器