Ubuntu20.04 搭建L2TP+IPsec环境

编程入门 行业动态 更新时间:2024-10-07 06:49:16

Ubuntu20.04 搭建L2TP+IPsec<a href=https://www.elefans.com/category/jswz/34/1771403.html style=环境"/>

Ubuntu20.04 搭建L2TP+IPsec环境

1 安装

安装l2tp和strongswan。

sudo apt install xl2tpd
sudo apt install strongswan

2 ipsec配置

1)编辑**/etc/ipsec.conf**

conn L2TP-IPSECauthby=secretauto=addkeyingtries=3ikelifetime=8hkeylife=1hkeyexchange=ikev2ike=chacha20poly1305-sha512-curve25519-prfsha512esp=chacha20poly1305-sha512,aes256gcm16-ecp384,aes256-sha256,aes256-sha1,3des-sha1# 连接类型 传输模式transport/隧道模式tunneltype=transport# 服务器公网地址left=10.25.X.X# 服务器子网网段leftsubnet=10.25.17.0/24[17/1701]# 客户端访问地址right=%any # right=10.25.16.0/24# rightsubnet=10.25.16.0/24[17/%any]dpddelay=30sdpdtimeout=150sdpdaction=clear

2)编辑**/etc/ipsec.secrets** , 设置ipsec的预共享秘钥

# This file holds shared secrets or RSA private keys for authentication.# RSA private key for this host, authenticating it to any other host
# which knows the public part.
: PSK "123456"

3 l2tp配置

编辑**/etc/xl2tpd/xl2tpd.conf**

[global]
ipsec saref = no
debug tunnel = no
debug avp = no
debug network = no
debug state = no
access control = no
rand source = dev
port = 1701
auth file = /etc/ppp/chap-secrets[lns default]
# 分配给客户端的私有网络地址
ip range = 192.168.100.100 - 192.168.100.254
# 服务器私有网络地址 绑定网卡的实际网络地址
local ip = 192.168.100.210
name = l2tp
pass peer = yes
refuse pap = yes
refuse chap = yes
require authentication = yes
ppp debug = no
# 指定PPP配置文件路径
pppoptfile = /etc/ppp/options.xl2tpd
length bit = yes

4 ppp配置

1) 编辑PPP配置文件(例如上文中的**/etc/ppp/options.xl2tpd**)。

require-mschap-v2
refuse-mschap
# DNS服务器地址
ms-dns 127.0.0.53
asyncmap 0
auth
crtscts
idle 1800
mtu 1410
mru 1410
hide-password
local
modem
lock
name l2tpd
connect-delay 5000
lcp-echo-interval 30
lcp-echo-failure 4

2)编辑**/etc/ppp/chap-secrets**,添加VPN访问用户密码

# Secrets for authentication using CHAP
# client        server  secret                  IP addresses
root * root *

5 重启服务

#重启服务

$sudo service xl2tpd restart
$sudo service ipsec restart

#确认服务状态

$sudo service xl2tpd status
$sudo service ipsec status

6 添加子网路由

当客户端可以连接到VPN服务器时,需要添加路由才可以访问私有网络中的其它机器。

# 添加访问192.168.100网段的路由
route add -net 192.168.100.0/24 netmask 255.255.255.0 gw 192.168.100.1

更多推荐

Ubuntu20.04 搭建L2TP+IPsec环境

本文发布于:2023-12-04 17:47:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1661731.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:环境   IPsec   L2TP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!