L2TP-VPN锐捷官方理论笔记

L2TP VPN锐捷官方理论笔记

概述

​ L2TP是对Point-to-Point Protocol(PPP)的一种扩展,它依靠利用PPP实现用户身份验证和传输数据。与PPTP不用的是,L2TP使用UDP作为控制消息与数据消息的传输协议。

​ L2TP也是实现VPN的一种重要和有效的方法。VPN使得网络用户访问公司内部网更方便与安全,无论是拨号用户还是其他网络接入方式的用户都可以通过VPN轻松到达这个目的。

锐捷支持两种模式的L2TP隧道:

​ 本地客户端发起的L2TP通道。在这种情况下,路由器充当L2TP客户端并主动发起协商与远程L2TP服务器建立隧道。

​ 远程客户端发起的L2TP通道。在这种情况下,路由器接受来自远程L2TP客户端的连接请求并协商建立隧道。

​ 本地客户端发起模式和远程客户端发起模式,这其实就是客户端和服务器的关系。本地客户端发起模式负责发起L2TP会话并配置会话的一些参数,远程客户端发起模式负责接受L2TP会话并配置会话的一些参数。

本地客户端发起

创建并配置L2TP-class接口(可选);

创建并配置Pseudowire-class接口(可选);

创建并配置Virtual-ppp接口(必须);

创建并配置L2TP-class

​ 对于实现本地客户端发起的L2TP隧道这一步骤是可选的。可以通过它来设置L2TP控制的相关参数,设置包括:

​ 设置L2TP-class单元

​ 设置L2TP控制连接的时间参数

​ 设置L2TP控制连接验证参数

设置L2TP-class单元

1
2
GW1(config)#l2tp-class ?
WORD L2tp-class name

点击并拖拽以移动

​ 这里创建的L2TP-class可以被Pseudowire-class按其名称引用。

设置L2TP控制连接的时间参数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
GW1(config-l2tp-class)#?
l2tp-class configuration commands:
authentication Authenticate the L2TP control connection
do To run exec commands in config mode
end Exit from configure mode
exit Exit from l2tp-class configuration mode
hello Set HELLO message interval
help Description of the interactive help system
hostname Local hostname for control connection authentication
no Negate a command or set its defaults
password Password for control connection authentication, AVP hiding
receive-window Receive window size for the control connection
//设置控制连接的接受窗口大小,系统默认值为8
retransmit Control message retransmission parameters
//设置控制连接重传参数,系统默认为2
show Show running system information
timeout Control connection timeout parameters
//设置控制连接可花费的最长时间,默认120

GW1(config-l2tp-class)#

点击并拖拽以移动

设置L2TP控制连接验证参数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
GW1(config-l2tp-class)#?
l2tp-class configuration commands:
authentication Authenticate the L2TP control connection
//要求进行通道身份验证
do To run exec commands in config mode
end Exit from configure mode
exit Exit from l2tp-class configuration mode
hello Set HELLO message interval
help Description of the interactive help system
hostname Local hostname for control connection authentication
//使用控制连接的本地主机名
no Negate a command or set its defaults
password Password for control connection authentication, AVP hiding
//设置通道口令
receive-window Receive window size for the control connection
retransmit Control message retransmission parameters
show Show running system information
timeout Control connection timeout parameters

GW1(config-l2tp-class)#

点击并拖拽以移动

​ 锐捷默认不要求进行通道验证,并且默认使用路由器的名称作为本地主机名。如果要求通道验证,那么两端必须使用相同的通道口令。host-name是用户设置的本地主机名,pass-words是用于通道验证的口令。

创建并配置Pseudowire-class

​ 对于实现本地客户端发起的L2TP隧道这一步骤是可选的。可以通过它来设置L2TP控制的相关参数,设置包括:

​ 设置Pseudowire-class单元

​ 设置L2TP数据传输封装模式

​ 设置L2TP数据传输IP参数

​ 设置L2TP控制连接参数

设置Pseudowire-class单元

1
2
GW1(config)#pseudowire-class ?
WORD Pseudowire-class name

点击并拖拽以移动

​ 这里创建的Pseudowire-class可以被Interface Virttal-ppp接口的Peudowire规则引用。

设置L2TP数据传输封装模式

1
2
3
4
5
6
7
8
9
GW1(config-pw-class)#?
pseudowire-class configuration commands:
do To run exec commands in config mode
encapsulation Data encapsulation method //设置数据传输封装模式
end Exit from configure mode
exit Exit from Pseudowire-class configuration mode
help Description of the interactive help system
no Negate a command or set its defaults
show Show running system information

点击并拖拽以移动

​ 一旦L2TP通道的数据传输封装模式被设定便不能再更改,如果用户需要在Peudowire-class接口上设置L2TP数据传输参数就必须首先设置L2TP数据传输封装模式。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
GW1(config-pw-class)#encapsulation l2tpv2 
GW1(config-pw-class)#?
pseudowire-class configuration commands:
do To run exec commands in config mode
encapsulation Data encapsulation method
end Exit from configure mode
exit Exit from Pseudowire-class configuration mode
help Description of the interactive help system
ip Specify IP parameters
//在这里设置各种传输IP参数,分片、TTL、通道接口等
no Negate a command or set its defaults
protocol Signalling protocol to use
show Show running system information

GW1(config-pw-class)#

点击并拖拽以移动

设置L2TP控制连接参数

1
2
3
4
5
6
7
8
9
GW1(config-pw-class)#protocol ?
l2tpv2 Use L2TPv2 signalling

GW1(config-pw-class)#protocol l2tpv2 ?
WORD L2tp-class name
<cr>

GW1(config-pw-class)#protocol l2tpv2 l2tp-class-name
//与之前创建的l2tp-class相联系

点击并拖拽以移动

创建并配置Vitrual-ppp接口

​ 对于实现本地客户端发起的L2TP隧道,这一步骤是必须的,它将创建一个指定的L2TP会话。设置Virtual-ppp接口包括:

​ 设置Virtual-ppp接口

​ 设置IP地址

​ 设置身份验证参数

​ 设置Pseudowire规则

设置Virtual-ppp接口

1
2
3
4
5
GW1(config)#int virtual-ppp ?
<1-1200> Virtual-ppp port number

GW1(config)#int virtual-ppp 1
GW1(config-if-Virtual-ppp 1)#

点击并拖拽以移动

设置Pseudowire规则

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
GW1(config-if-Virtual-ppp 1)#pseudowire ?
A.B.C.D IP address of peer
hostname Hostname

GW1(config-if-Virtual-ppp 1)#pseudowire 172.16.0.2 ?
<1-4294967295> Enter VC ID value
//全局标号

GW1(config-if-Virtual-ppp 1)#pseudowire 172.16.0.2 1 ?
encapsulation Data encapsulation method
pw-class Pseudowire-class to use for encapsulation and protocol
configuration

GW1(config-if-Virtual-ppp 1)#pseudowire 172.16.0.2 1 pw-class ?
WORD Pseudowire-class name
//引用Pseudowire-class

GW1(config-if-Virtual-ppp 1)#pseudowire 172.16.0.2 1 pw-class l2tp

点击并拖拽以移动

​ 一旦在Virtual-ppp接口上设置了Pseudowire规则,Virtual-ppp接口就会自动尝试与指定的LNS建立L2TP会话,如果尝试失败,Virtual-ppp会在10秒后再次尝试建立L2TP会话。

远程客户端发起

​ 配置本地地址池(可选)

​ 配置用户信息(可选)

​ 配置VPDN全局参数(必须)

​ 配置Virtual-template接口(必须)

​ 配置Vpdn-group(必须)

配置本地地址池

​ 对于远程客户端发起的L2TP隧道,这一步骤是可选的。作为LNS,为了接受远程客户端发起的L2TP连接,如果远程客户端没有设置在VPN内使用的IP地址就需要为其分配IP地址。一般情况下,是从一个设定的地址池内将空闲的IP地址分配给客户端。

1
2
3
4
5
6
7
8
9
10
11
12
R2(config)#ip local pool ?   
WORD Pool name. "default" is the default pool name.

R2(config)#ip local pool l2tp ?
A.B.C.D Low ip-address

R2(config)#ip local pool l2tp 172.16.0.1 172.16.0.254 ?
<cr>

R2(config)#ip local pool l2tp 172.16.0.1 172.16.0.254
% Invalid address range!
R2(config)#

点击并拖拽以移动

配置用户信息

​ 对于实现远程客户端发起的L2TP隧道,这一步骤是可选的。配置用户信息,是为了试图对远程L2TP接入本地的客户端进行用户身份验证。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
R2(config)#username ?
WORD User name

R2(config)#username Test@123 ?
login Set user login mode
nopassword No password is required for the user to log in
online Set user online amount at the same time
password Specify the password for the user
permission Grant permission on files or dirs
privilege Set user privilege level
reject Reject some user behavior
secret Specify the secret for the user
<cr>

R2(config)#username Test@123 password ?
0 Specifies an UNENCRYPTED password will follow
7 Specifies a HIDDEN password will follow
LINE The UNENCRYPTED (cleartext) user password

R2(config)#username Test@123 password 0 ?
LINE The UNENCRYPTED (cleartext) user password

R2(config)#username Test@123 password 0 Test@123
R2(config)#

点击并拖拽以移动

​ 其中user-name是允许拨入的用户名称,password是用户对应的口令。路由器在本地维护一个允许访问的(拨入)用户的名称与对应口令的数据库。

配置VPDN全局参数

​ 对于实现远程客户端发起的L2TP隧道,这一步骤是必须的。它将设置VPDN的全局工作参数。设置VPDN参数包括:

​ 启用/禁用VPDN功能

​ 设置VPDN源地址

​ 设置VPDN最大会话数

启用/禁用VPDN

​ 如果用户要求路由器接受远端客户端L2TP接入并建立L2TP隧道与会话,那么就必须在路由器上启用VPDN功能。

1
R2(config)#vpdn enable

点击并拖拽以移动

设置VPDN源地址

​ 使用VPDN,在设置了VPDN源地址后远程客户端设置的隧道目的地址必须与之一致才能正常建立L2TP隧道。在默认情况下,系统不会检查接受到的隧道建立请求中的目的地址是否为某一特定值。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
R2(config)#vpdn ?
authorize Configure VPDN authorization options
congestion_avoidanc Start congestion avoidanc
domain-delimiter Configure VPDN domain delimiter, prefix/suffix
enable Enable VPDN
ignore_source Ignore source ip address
limit_rate Limit vpdn create rate
send Send message
session-limit Maximum simultaneous VPDN sessions
source-ip Source IP address

R2(config)#vpdn source-ip ?
A.B.C.D Source IP address

R2(config)#vpdn source-ip 172.16.0.2 ?
<cr>

R2(config)#vpdn source-ip 172.16.0.2
R2(config)#

点击并拖拽以移动

设置VPDN最大会话数

​ 设置VPDN最大会话数,超过最大值的接入请求将被拒绝。

1
2
3
4
5
R2(config)#vpdn session-limit ?
<1-300> Number of sessions

R2(config)#vpdn session-limit 100
R2(config)#

点击并拖拽以移动

配置Virtual-template接口

​ 对于实现远程客户端发起的L2TP隧道,这一步骤是必须的。它将成为绑定并负载L2TP会话Virtual-access接口的模板。配置Virtual-template包括:

​ 设置Virtual-template接口(必须)

​ 设置本地IP地址(必须)

​ 设置身份验证模式(可选)

​ 设置对端IP地址(可选)

设置Virtual-template

1
2
3
4
5
6
7
8
R2(config)#int virtual-template ?
<1-1200> Virtual-template port number

R2(config)#int virtual-template 1 ?
<cr>

R2(config)#int virtual-template 1
R2(config-if-Virtual-Template 1)#

点击并拖拽以移动

​ 创建的Virtual-template将作为绑定并负载L2TP会话的Virtual-access接口的配置模板

配置VDPN-group

​ 对于实现远程客户端发起的L2TP隧道,这一步骤是必须的。它将设定VPDN-group工作参数。配置VPDN-group包括:

​ 设置VPDN-group(必须)

​ 设置隧道模式(必须)

​ 设置使用的虚模板(必须)

​ 设置对端名称(可选)

​ 设置本地名称(可选)

​ 设置VPDN-group源地址(可选)

​ 设置L2TP控制连接参数(可选)

设置VPDN-group
1
2
3
4
5
6
7
8
R2(config)#vpdn-group ?
WORD VPDN Group name

R2(config)#vpdn-group l2tp ?
<cr>

R2(config)#vpdn-group l2tp
R2(config-vpdn)#

点击并拖拽以移动

​ 创建的VPDN-group单元将允许对应的客户端接入并建立隧道。

设置隧道模式
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
R2(config-vpdn)#?             
vpdn-group configuration commands:
accept-dialin VPDN accept-dialin group configuration //允许接受远程客户端拨入
domain VPN domain string
end Exit from configure mode
exit Exit from vpdn-group configuration mode
force-local-chap Force a CHAP challenge to be instigated locally
force-local-lcp Force a local lcp negotiation
help Description of the interactive help system
ip IP settings for tunnel
lcp LCP specific commands
local Local information, like name
no Negate a command or set its defaults
show Show running system information
source-ip Set Source IP address
terminate-from Terminate tunnel from remote peer
vpn VPN ID/VRF name

R2(config-vpdn)#acc
R2(config-vpdn)#accept-dialin
R2(config-vpdn-acc-in)#

点击并拖拽以移动

设置隧道协议

​ 在设置隧道协议之前,必须首先设定隧道模式。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
R2(config-vpdn-acc-in)#?        
VPDN group accept-dialin configuration commands:
end Exit from configure mode
exit Exit from vpdn-group-acc-in configuration mode
help Description of the interactive help system
no Negate a command or set its defaults
protocol Tunneling protocol to be used //设置协议
show Show running system information

R2(config-vpdn-acc-in)#protocol ?
any Use any protocol
l2tp Use L2TP
pptp Use PPTP

R2(config-vpdn-acc-in)#protocol l2
R2(config-vpdn-acc-in)#protocol l2tp ?
<cr>

R2(config-vpdn-acc-in)#protocol l2tp

点击并拖拽以移动

设置使用的虚模板

​ 在设置隧道协议之前,必须首先设定隧道模式。

1
2
3
4
5
R2(config-vpdn-acc-in)#virtual-template ?
<1-1200> Virtual Template interface number

R2(config-vpdn-acc-in)#virtual-template 1
R2(config-vpdn-acc-in)#

点击并拖拽以移动

设置对端名称

​ 如果设定了对端名称,那么该VPDN-group将只对主机名称与之匹配的远程客户端有效。默认可以为任意远程客户端提供VPDN服务

1
2
3
4
5
6
7
8
R2(config-vpdn)#terminate-from ?
hostname Terminate tunnel from remote hostname

R2(config-vpdn)#terminate-from hos
R2(config-vpdn)#terminate-from hostname ?
WORD Remote name string

R2(config-vpdn)#terminate-from hostname

点击并拖拽以移动

设置本地名称
1
2
3
4
5
6
7
8
9
R2(config-vpdn)#local ?  
name Local name used for group authentication

R2(config-vpdn)#local nam
R2(config-vpdn)#local name ?
WORD Local name string

R2(config-vpdn)#local name Test@123
R2(config-vpdn)#

点击并拖拽以移动

设置VPDN-group源地址

​ 设置VPDN-group源地址,远程客户端发送的隧道建立请求中的目的地址必须与之匹配,对应的VPDN-group才会被应用。

1
2
3
4
5
6
7
8
R2(config-vpdn)#source-ip ?
A.B.C.D IP destination

R2(config-vpdn)#source-ip 172.16.0.2 ?
<cr>

R2(config-vpdn)#source-ip 172.16.0.2
R2(config-vpdn)#

点击并拖拽以移动

设置L2TP控制连接参数

启用通道验证

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
R2(config-vpdn)#l2tp ?
ip IP specific commands
tunnel L2TP tunnel commands

R2(config-vpdn)#l2tp tu
R2(config-vpdn)#l2tp tunnel ?
authentication Authenticate tunnel
avp-hidden-compatible Compatible hidden avp parse
clear Clear timeout session
force_ipsec Force incoming l2tp tunnel be established through
ipsec tunnel
hello Hello packet interval
none-rfc-compatible None rfc compatible
password Tunnel password for authentication and/or AVP
hiding
receive-window Receive window size for control channel
retransmit Control packet retransmission parameters
timeout Tunnel timeout values
zxkeepalive-compatible Compatible ZX SCCRQ keepalive

R2(config-vpdn)#l2tp tunnel au
R2(config-vpdn)#l2tp tunnel authentication ?
<cr>

R2(config-vpdn)#l2tp tunnel authentication
R2(config-vpdn)#

点击并拖拽以移动

设置通道口令

1
2
3
4
5
R2(config-vpdn)#l2tp tunnel password ?
WORD Tunnel password string

R2(config-vpdn)#l2tp tunnel password Test@123
R2(config-vpdn)#

点击并拖拽以移动

设置强制加密

1
R2(config-vpdn)#l2tp tunnel force_ipsec 

点击并拖拽以移动

强制加密后,只有加密后才能通过VPDN通道。