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

相关推荐
天才奇男子5 小时前
HAProxy高级功能全解析
linux·运维·服务器·微服务·云原生
小李独爱秋6 小时前
“bootmgr is compressed”错误:根源、笔记本与台式机差异化解决方案深度指南
运维·stm32·单片机·嵌入式硬件·文件系统·电脑故障
学嵌入式的小杨同学6 小时前
【Linux 封神之路】信号编程全解析:从信号基础到 MP3 播放器实战(含核心 API 与避坑指南)
java·linux·c语言·开发语言·vscode·vim·ux
酥暮沐6 小时前
iscsi部署网络存储
linux·网络·存储·iscsi
❀͜͡傀儡师7 小时前
centos 7部署dns服务器
linux·服务器·centos·dns
Dying.Light7 小时前
Linux部署问题
linux·运维·服务器
S19017 小时前
Linux的常用指令
linux·运维·服务器
萤丰信息7 小时前
AI 筑基・生态共荣:智慧园区的价值重构与未来新途
大数据·运维·人工智能·科技·智慧城市·智慧园区
小义_7 小时前
【RH134知识点问答题】第7章 管理基本存储
linux·运维·服务器
运维小欣7 小时前
Agentic AI 与 Agentic Ops 驱动,智能运维迈向新高度
运维·人工智能