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

相关推荐
简单点了1 天前
全栈编程基础知识7
运维·服务器·网络
眷蓝天1 天前
Docker 镜像瘦身:从 GB 到 MB 的优化实践
运维·docker·容器
实心儿儿1 天前
Linux —— 进程控制 - mini shell
linux·运维·服务器
程序员黄老师1 天前
Windows文件移动到Linux上的坑
linux·运维·服务器
shizhan_cloud1 天前
自动化部署Kubernetes集群
运维·kubernetes
mounter6251 天前
【内核前沿】Linux IPC 迎来大变局?POSIX 消息队列增强、io_uring IPC 与 Bus1 十年回归
linux·运维·服务器·kernel·ipc·io_uring
不怕犯错,就怕不做1 天前
Linux-Sensor驱动移植与调试(转载)
linux·驱动开发·嵌入式硬件
wzl202612131 天前
企业微信定时群发技术实现与实操指南(原生接口+工具落地)
java·运维·前端·企业微信
island13141 天前
最详细VMware Workstation 17 上安装 Ubuntu 系统
linux·数据库·ubuntu
2401_895521341 天前
Linux下安装Redis
linux·运维·redis