实验拓扑
R1 配置
R1 充当LNS
配置
sysname r1
l2tp enable //开启L2tp
ip pool h //配置L2tp 分配的地址
network 172.16.0.0 mask 255.255.255.0
aaa //配置认证用户
local-user test password cipher test
local-user test service-type ppp
interface Virtual-Template0 //创建虚拟接口模板
ppp authentication-mode chap //认证模式chap
remote address pool h //为客户端分配地址池中地址
ip address 172.16.0.1 255.255.255.0 //本地地址
interface GigabitEthernet0/0/0
ip address 12.0.0.1 255.255.255.0
interface LoopBack0
ip address 1.1.1.1 255.255.255.255
l2tp-group 1
undo tunnel authentication //关闭隧道认证
allow l2tp virtual-template 0 //# 配置LNS绑定虚拟接口模板。
ip route-static 0.0.0.0 0.0.0.0 12.0.0.2
ip route-static 3.3.3.3 255.255.255.255 172.16.0.254 //配置去往R3 子网的路由
ip route-static 4.4.4.4 255.255.255.255 172.16.0.253 //配置去往R4 子网的路由
R2 配置
R2 配置
sysname r2
interface GigabitEthernet0/0/0
ip address 12.0.0.2 255.255.255.0
interface GigabitEthernet0/0/1
ip address 23.0.0.2 255.255.255.0
interface GigabitEthernet0/0/2
ip address 24.0.0.2 255.255.255.0
R3 配置
sysname r3
interface Virtual-Template0
ppp chap user test
ppp chap password cipher test
ip address ppp-negotiate //ip地址自动协商 协商候获取到地址 172.16.0.254
# ip address 172.16.0.2 24 //手动指定
l2tp-auto-client enable // 触发自拨号建立L2TP隧道
interface GigabitEthernet0/0/1
ip address 23.0.0.3 255.255.255.0
interface LoopBack0
ip address 3.3.3.3 255.255.255.255
l2tp enable
//创建一个L2TP组并配置用户名称为huawei的用户与LNS建立L2TP连接。
l2tp-group 1
undo tunnel authentication
tunnel name test //创建接口名称
start l2tp ip 12.0.0.1 fullusername test
ip route-static 0.0.0.0 0.0.0.0 23.0.0.2
ip route-static 1.1.1.1 255.255.255.255 172.16.0.1 //配置到R1 后子网的路由走l2tp
ip route-static 4.4.4.4 255.255.255.255 172.16.0.1 //配置到R4 子网的地址经过R1 中转
R4
sysname r4
l2tp enable
interface Virtual-Template0
ppp chap user test
ppp chap password cipher test
ip address ppp-negotiate
l2tp-auto-client enable
interface GigabitEthernet0/0/2
ip address 24.0.0.4 255.255.255.0
interface LoopBack0
ip address 4.4.4.4 255.255.255.255
l2tp-group 1
undo tunnel authentication
start l2tp ip 12.0.0.1 fullusername test
ip route-static 0.0.0.0 0.0.0.0 24.0.0.2
ip route-static 1.1.1.1 255.255.255.255 172.16.0.1
ip route-static 3.3.3.3 255.255.255.255 172.16.0.1
R3上测试
总结:
L2TP 实现分支间互访主要在于分之间配置静态路由,将去网目的网段的流量映入进L2TP隧道,由总部中转.