如何在路由器上配置L2TP并测试成功

网络拓扑:

 

注:这里的命令是在锐捷设备上实现的。路由器的型号为:rsr20-4

内网(192.168.10.0---------F0/1-R1-S2/0------S2/0-R2-F0/1-----------外网(192.168.20.0

IP地址规划:

R1(模拟L2TP服务器):

F0/1:192.168.10.1

S2/0:192.168.33.1

R2(模拟L2TP客户端):

S2/0:192.168.33.2

F0/1:192.168.20.1

如何配置:

1.配置L2TP服务器(R1

hostname r1

username test password test //配置对端口路由器(R2)用于验证的用户名与密码

username abc password 123 //外网用户拨入时的用户名与密码

ip access-list standard 10  //配置要进行nat转换的流量

10 permit 192.168.10.0 0.0.0.255

ip local pool *** 192.168.1.100 192.168.1.110

//配置用户拨入所需的地址池名为***

vpdn enable //开启vpdn功能

vpdn-group l2tp //创建名为l2tpvpdn

accept-dialin //允许拨号

protocol l2tp //配置协议为l2tp

virtual-template 1 //引用虚模板1,绑定下面创建的虚模板

interface Serial 2/0 //配置串口(外网)ip

 ip nat outside

 ip address 192.168.33.1 255.255.255.0

 clock rate 64000

interface FastEthernet 0/1 //配置以太网(内网)ip

 ip nat inside

 ip address 192.168.10.1 255.255.255.0

interface Virtual-Template 1 //创建并配置虚模板1

 ppp authentication chap //配置认证协议为chap

 ip nat inside //参与nat

 ip unnumbered FastEthernet 0/1 //关联内网接口(连接到内网的接口)

 peer default ip address pool ***

//绑定用户拨入内网的地址池,上面创建的***地址池

ip nat inside source list 10 interface Serial 2/0  //配置nat端口转换

2.配置L2TP客户端(R2)

hostname r2

l2tp-class l2tp //创建拨号模板,名为l2tp

pseudowire-class ***-l2tp //创建虚线路,名为***-l2tp

 encapsulation l2tpv2 //封装为l2tpv2协议

 protocol l2tpv2 l2tp //配置协议为l2tpv2,引用上面定义好的虚模板l2tp

 ip local interface FastEthernet 0/1

//关联外网接口,来自这个接口的用户可以拨入

ip access-list standard 10 //配置nat转换的流量

 10 permit 192.168.20.0 0.0.0.255

interface Serial 2/0 //配置串口ip

 ip nat outside

 ip address 192.168.33.2 255.255.255.0

interface FastEthernet 0/1 //配置以太网接口ip

 ip nat inside

 ip address 192.168.20.1 255.255.255.0

interface Virtual-ppp 1 //创建虚拟ppp接口

 pseudowire 192.168.33.1 11 encapsulation l2tpv2 pw-class ***-l2tp

//pseudowire是“虚线路”的意思,这条命令的意思为:配置对方L2TP服务器(R1)的地址为192.168.33.1 ,封装的协议为L2TPV2,绑定上面创建的虚链路***-l2tp

 ppp chap hostname test

 //发送用户名test,必须为L2TP服务器(R1)中配置好的用户名

 ppp chap password test //发送密码,必须为L2TP服务器(R1)中配置好的密码

 ip nat outside //参与NAT

 ip mtu 1460

 ip address negotiate //IP地址商议获取

ip nat inside source list 10 interface Serial 2/0 //配置nat端口转换

测试

1.       将一台主机接到R2F0/1

2.       在网上邻居那里创建一个×××拨号连接

修改后重启电脑才能生效。

重启后双击刚刚创建好的×××连接,输入用户名和密码,注意这里的用户名为密码必须为L2TP服务器中创建的,如上面创建的username abc password 123 . 不能输入这个:username test password test,因为这个是LNSLAS之间用的,不能作为PC拨入的用户名和密码!!!

拨入成功后PC会自动获取LNS中地址池的IP

桌面的×××连接会变亮:

排错

1.

是连到L2TP服务器,而不是连到客户端路由器!

L2TP服务器的地址没写对。

2.

连接到的服务器为192.168.33.1,添写的用户名和密码不对,不是username test password test!这个是设备之间用的,L2TP服务器没有创建给PC的用户名和密码!!!