找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 18412|回复: 9

[其它] 使用 RouterOS 建立基于 L2TP over IPsec 的 VPN 服务

[复制链接]
发表于 2018-1-6 02:43:34 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

×
前言
自从苹果于今年 6 月 15 日发布了最新的 IOS 10 以及 macOS Sierra 10.12 操作系统,于第一时间尝鲜,经过一段时间试用,新系统表现良好,但是其中一个小细节让人无法忍受。那就是取消了对 PPTP 的支持!不过想想也是,PPTP 在功能,加密等方面均已被时代淘汰,停止支持也在情理之中。尤其在我朝 伟大的墙 的围追堵截下,PPTP 这等协议已经形同虚设。好在苹果在新系统中保留了 L2TP 协议支持,好吧,请出我牛逼的 RouterOS !整 …
关于 L2TP
L2TP ,全称 Layer 2 Tunneling Protocol ,从字面上看,这玩意工作在 2 层。通过封装和扩展 PPP 协议实现 VPN 隧道的功能。但是 L2TP 不会对隧道内的数据进行加密,所以 L2TP 一般和 IPsec 共同使用,先由 L2TP 封装 2 层数据,再由 IPsec 封装 IP 数据包共同提供服务。
开整
这里是图,请脑补,另外这里的环境如果没说都是 routeros v6.12
启动 L2TP 服务
因为会和 IPsec 共同使用,所以此处默认配置文件不需要选择加密
1
2
/interface l2tp-server server \
set enabled=yes default-profile=default
配置 IPsec
secret 参数是您的预共享秘钥,enc-algorithm 参数请选择您设备支持的加密方式,不知道就别改,可选参数为 3des,aes-128,aes-192,aes-256
1
2
3
4
5
6
7
8
9
/ip ipsec peer \
add address=0.0.0.0/0 auth-method=pre-shared-key dh-group=modp1024 \
disabled=no dpd-interval=2 dpd-maximum-failures=5 enc-algorithm=3des \
exchange-mode=main-l2tp generate-policy=port-override hash-algorithm=sha1 \
lifetime=1d nat-traversal=yes port=500 secret=123 send-initial-contact=yes

/ip ipsec proposal \
set default enc-algorithms=3des auth-algorithms=sha1 disabled=no \
lifetime=30m pfs-group=modp1024
创建地址池和账号
1
2
3
4
5
6
7
8
/ip pool add \
name=vpn-pool range=192.168.99.2-192.168.99.100

/ppp profile \
set default local-address=192.168.99.1 remote-address=vpn-pool

/ppp secret \
add name=xiaobao password=12354
防火墙规则
1
2
3
/ip firewall filter \
add chain=input protocol=udp port=1701,500,4500
add chain=input protocol=ipsec-esp
连接
在您的 IOS/Mac/Win 设备上创建 L2TP over IPsec VPN 并填入账号密码和预共享秘钥即可。

routeros
 楼主| 发表于 2018-1-6 02:43:57 | 显示全部楼层
routeros
回复

使用道具 举报

发表于 2018-1-7 00:02:25 | 显示全部楼层
多线L2TP不走默认由,不知道还要加什么设置?想让L2TP走在一条固定IP上。
routeros
回复

使用道具 举报

发表于 2018-1-7 23:16:35 | 显示全部楼层
我爱肉饼 发表于 2018-1-7 00:02
多线L2TP不走默认由,不知道还要加什么设置?想让L2TP走在一条固定IP上。

在路由表對l2tp-client指定pppoe-out

2018-01-07 23-09-30 的螢幕擷圖.png

2018-01-07 23-12-56 的螢幕擷圖.png
routeros
回复

使用道具 举报

 楼主| 发表于 2018-1-8 22:11:33 | 显示全部楼层
我爱肉饼 发表于 2018-1-7 00:02
多线L2TP不走默认由,不知道还要加什么设置?想让L2TP走在一条固定IP上。

很多种办法
routeros
回复

使用道具 举报

发表于 2018-1-9 21:09:20 | 显示全部楼层
cspm333 发表于 2018-1-7 23:16
在路由表對l2tp-client指定pppoe-out

我没表达清楚,是说远程这端拨入想通过固定IP过去,不想用服务端动态IP还要解析,服务端有条固定IP

点评

不理解你說的什是撥入想通過固定IP過去?你是控制client還是server,您說的固定ip是vpn-client的地址,還是vpn-server的地址,還是公網地址?  发表于 2018-1-9 23:42
routeros
回复

使用道具 举报

发表于 2018-1-9 21:09:45 | 显示全部楼层

我没表达清楚,是说远程这端拨入想通过固定IP过去,不想用服务端动态IP还要解析,服务端有条固定IP
routeros
回复

使用道具 举报

发表于 2018-1-17 19:25:41 | 显示全部楼层
我爱肉饼 发表于 2018-1-9 21:09
我没表达清楚,是说远程这端拨入想通过固定IP过去,不想用服务端动态IP还要解析,服务端有条固定IP

vpn-server的地址想走固定IP出去
routeros
回复

使用道具 举报

发表于 2018-1-17 19:26:42 | 显示全部楼层
sihanlin 发表于 2018-1-6 02:43
https://www.ichegg.org/2016/08/12/%E4%BD%BF%E7%94%A8-RouterOS-%E5%BB%BA%E7%AB%8B%E5%9F%BA%E4%BA%8E-L ...

vpn-server的地址想走固定IP出去
routeros
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|小黑屋|软路由 ( 渝ICP备15001194号-1|渝公网安备 50011602500124号 )

GMT+8, 2024-4-25 15:27 , Processed in 0.071406 second(s), 6 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表