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 小时前
Ubuntu Linux Cursor 安装与使用一
linux·运维·ubuntu
艾伦_耶格宇2 小时前
【ACP】阿里云云计算高级运维工程师--ACP
运维·阿里云·云计算
一位摩羯座DBA3 小时前
Redhat&Centos挂载镜像
linux·运维·centos
学习3人组3 小时前
CentOS配置网络
linux·网络·centos
计算机毕设定制辅导-无忧学长3 小时前
西门子 PLC 与 Modbus 集成:S7-1500 RTU/TCP 配置指南(一)
服务器·数据库·tcp/ip
weixin_307779133 小时前
Hive集群之间迁移的Linux Shell脚本
大数据·linux·hive·bash·迁移学习
漫步企鹅4 小时前
【蓝牙】Linux Qt4查看已经配对的蓝牙信息
linux·qt·蓝牙·配对
cui_win4 小时前
【网络】Linux 内核优化实战 - net.core.flow_limit_table_len
linux·运维·网络
梦在深巷、4 小时前
MySQL/MariaDB数据库主从复制之基于二进制日志的方式
linux·数据库·mysql·mariadb
风清再凯4 小时前
自动化工具ansible,以及playbook剧本
运维·自动化·ansible