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

相关推荐
Archy_Wang_14 分钟前
基于BaGet 构建NuGet私有库并实现类库打包到NuGet私有库
运维·jenkins
小狗爱吃黄桃罐头7 分钟前
正点原子【第四期】Linux之驱动开发学习笔记-10.1 Linux 内核定时器实验
linux·驱动开发·学习
初听于你8 分钟前
运维高级故障排除与恢复-SysRq
运维·服务器·安全
RPA机器人就用八爪鱼39 分钟前
RPA自动化程序:企业数字化转型的智能引擎
运维·自动化·rpa
Kang强1 小时前
tcpdump 抓到 icmp 包,但是抓不到 tcp 包??
linux
demodashi6661 小时前
Linux下ag搜索命令详解
linux·运维·windows
無识1 小时前
Linux-第四章web服务
linux·运维·服务器
一叶知秋yyds1 小时前
Centos 安装 Docker教程
linux·docker·centos
fie88891 小时前
在CentOS 7上集成cJSON库的方法
linux·运维·centos
带土12 小时前
5. Unix/Linux 系统常用类型别名清单
linux·unix