神码公司关于路由器CHAP认证的配置命令

发布时间:2011-11-01 10:39:05   来源:文档文库   
字号:

双向认证:
RouterA配置:

RouterA#config
RoeterA_config#username RouterB_CHAP password 0 digital
//配置路由器验证数据库中有一个用户名为RouterB_CHAP,密码为digital的用户
RoeterA_config#aaa authentication ppp default local
//配置从本地认证
RouterA_config#interface serial 2/0
RouterA_config_s2/0#encapsulation ppp
//配置s2/0端口的封装类型为PPP协议
RouterA_config_s2/0#ppp authentication chap
//配置PPP协议的验证方式为CHAP验证
RouterA_config_s2/0#ppp chap hostname RouterA_CHAP
//配置CHAP验证时,从此端口发送给对方进行验证的用户名RouterA_CHAP
RouterA_config_s2/0#ppp chap password digital
//配置本地chap验证的匹配口令为digital
RouterA_config_s2/0#ip address 192.168.2.1 255.255.255.0
//配置此端口的IP地址为192.168.2.1,掩码为255.255.255.0


RouterB配置:

RouterB#config
RoeterB_config#username RouterA_CHAP password digital
//配置路由器验证数据库中有一个用户名为RouterA_CHAP,密码为digital的用户
RoeterA_config#aaa authentication ppp default local
//配置从本地认证
RouterB_config#interface serial 1/0
RouterA_config_s1/0#encapsulation ppp
//配置s2/0端口的封装类型为PPP协议
RouterB_config_s1/0#ppp authentication chap
//配置PPP协议的验证方式为CHAP验证
RouterB_config_s1/0#ppp chap hostname RouterB_CHAP digital
//配置CHAP验证时,从此端口发送给对方进行验证的用户名:RouterB_CHAP
RouterA_config_s2/0#ppp chap password digital
//配置本地chap验证的匹配口令为digital
RouterB_config_s1/0#ip address 192.168.2.2 255.255.255.0
//配置此端口的IP地址为192.168.2.2,掩码为255.255.255.0
RouterB_config_s1/0#physical-layer speed 64000
//配置此端口的内部时钟速率,因为它是模拟DCE设备,因此必须提供时钟频率

单向认证:
RouterA配置:

RouterA#config
RouterA_config#interface serial 2/0
RouterA_config_s2/0#encapsulation ppp
//配置s2/0端口的封装类型为PPP协议
RouterA_config_s2/0#ppp chap hostname RouterA_CHAP
//配置CHAP验证时,从此端口发送给对方进行验证的用户名:RouterA_CHAP
RouterA_config_s2/0#ppp chap password digital
//配置本地chap验证的匹配口令为digital
RouterA_config_s2/0#ppp chap password digital
RouterA_config_s2/0#ip address 192.168.2.1 255.255.255.0
//配置此端口的IP地址为192.168.2.1,掩码为255.255.255.0


RouterB配置:

RouterB#config
RoeterB_config#username RouterA_CHAP password digital
//配置路由器验证数据库中有一个用户名为RouterA_CHAP,密码为digital的用户
RoeterA_config#aaa authentication ppp default local
//配置从本地认证
RouterB_config#interface serial 1/0
RouterA_config_s1/0#encapsulation ppp
//配置s2/0端口的封装类型为PPP协议
RouterB_config_s1/0#ppp authentication chap
//配置PPP协议的验证方式为CHAP验证
RouterB_config_s1/0#ip address 192.168.2.2 255.255.255.0
//配置此端口的IP地址为192.168.2.2,掩码为255.255.255.0
RouterB_config_s1/0#physical-layer speed 64000
//配置此端口的内部时钟速率,因为它是模拟DCE设备,因此必须提供时钟频率


不认证:
RouterA配置:

RouterA#config
RouterA_config#interface serial 2/0
RouterA_config_s2/0#encapsulation ppp
//配置s2/0端口的封装类型为PPP协议
RouterA_config_s2/0#ip address 192.168.2.1 255.255.255.0
//配置此端口的IP地址为192.168.2.1,掩码为255.255.255.0


RouterB配置:

RouterB#config
RouterB_config#interface serial 1/0
RouterA_config_s1/0#encapsulation ppp
//配置s2/0端口的封装类型为PPP协议
RouterB_config_s1/0#ip address 192.168.2.2 255.255.255.0
//配置此端口的IP地址为192.168.2.2,掩码为255.255.255.0
RouterB_config_s1/0#physical-layer speed 64000
//配置此端口的内部时钟速率,因为它是模拟DCE设备,因此必须提供时钟频率

网上另一篇关于PAP/CHAP的文章

PPP中的papchap认证

写在前面:今天看了victoryan兄弟的chap认证实验,想起来以前帮忙同学解决了一个关于papchap认证的问题,现在就把ppp中的papchap认证做一个总结。

 

实验等级:Aassistant

实验拓扑:

实验说明:PPP中的认证方式有papchap两种,这两种认证既可以单独使用也可以结合使用。并且既可以进行单向认证也可以进行双向认证。

pap是通过验证远端的用户名和密码是否匹配来进行验证

chap则是发送一个挑战包,然后远端通过自己的数据库的用户名和密码利用md5进行计算后返还一个数值,然后在发送方验证这个数值是否和自己计算出来的数值是否一致进行验证

基本配置:

R1

!

hostname R1----------------------------------------------------------设置主机名为“R1

!

interface Serial1/0

ip address 1.1.1.1 255.255.255.0

encapsulation ppp-------------------------------------------------设置封装为ppp

R2

hostname R2

!

interface Serial1/0

ip address 1.1.1.2 255.255.255.0

encapsulation ppp

通过上面的配置,在没有启用任何认证的情况下,链路是通的。

配置步骤:

1.       在两台路由器上进行pap认证:

如果我们进行单项认证的话配置应该如下

R1为认证的服务器端,需要建立本地口令数据库,并且开始pap认证。

R1(config)#username R2 password gairuhe------------------------建立本地口令数据库

R1(config)#int s1/0

R1(config-if)#ppp authentication pap--------------------------------要求进行PAP认证

在这样的配置下,我们可以看到链路已经down了:

R1(config-if)#

*Aug 23 16:45:12.639: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1/0, changed state to down

R2为认证的客户端,需要发送用户名和密码来匹配服务器端的口令数据库

此时我们在R2上加上如下的配置:

R2(config)#int s1/0

R2(config-if)#ppp pap sent-username R2 password gairuhe------发送用户名和密码

R2(config-if)#

*Aug 23 16:47:48.635: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1/0, changed state to up

此时链路已经起来,我们仅在R1上做了认证,而在R2上没有进行认证。这就是pap的单向认证。

Pap的双向认证:

Pap的双向认证其实就是将两端同时都配置为认证服务器端和认证客户端。在上面实验的基础上,我们只要将R2配置成服务器端,将R1配置成客户端即可。

R2(config)#username R1 password gairuhe

R2(config)#int s1/0

R2(config-if)#ppp authentication pap

R2(config-if)#

*Aug 23 16:52:29.843: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1/0, changed state to down

R1(config-if)#int s1/0

R1(config-if)#ppp pap sen

R1(config-if)#ppp pap sent-username R1 password gairuhe

R1(config-if)#

*Aug 23 16:53:08.343: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1/0, changed state to up

2.在上面实验的基础上,将R1改为chap认证,而R2不变。

打开debug ppp authentication信息。在R1上进行如下的改变

R1(config-if)#no ppp authentication pap

R1(config-if)#no ppp pap sent-username R1 password gairuhe

R1(config-if)#ppp authentication chap

我们发现,链路状态并没有改变,而且也没有任何的debug信息产生。这就是说明了在链路已经建立起来后,是无需进行再次的认证的。

我们把R1的是s1/0shut down 后在no shut down,看看情况

R1(config-if)#shut

R1(config-if)#no shut

R1#

*Aug 23 17:00:19.663: Se1/0 PPP: Authorization required

此时发现链路已经断开,并且要求需要PPP的认证

3.在两台路由器上进行chap认证

首先将R2pap认证关闭

R2(config-if)#no ppp authen pap

R2(config-if)#no ppp pap sent-username R2 password gairuhe

我们通过debug信息看到

R1#

*Aug 23 17:07:24.031: Se1/0 PPP: Authorization required

*Aug 23 17:07:24.063: Se1/0 CHAP: O CHALLENGE id 42 len 23 from "R1"

*Aug 23 17:07:24.095: Se1/0 CHAP: I RESPONSE id 42 len 23 from "R2"

*Aug 23 17:07:24.099: Se1/0 PPP: Sent CHAP LOGIN Request

*Aug 23 17:07:24.103: Se1/0 PPP: Received LOGIN Response FAIL

*Aug 23 17:07:24.107: Se1/0 CHAP: O FAILURE id 42 len 25 msg is "Authentication failed"

我们看到chap认证是通过发送一个challenge信息来进行认证。在R2上启用chap认证

R2(config)#int s1/0

R2(config-if)#ppp authentication chap

R2(config)#

*Aug 23 17:11:41.839: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1/0, changed state to up

这个时候链路就已经通了。

4.两种认证同时启用

使用的命令为:

R2(config-if)#ppp authentication chap pap 或者

R2(config-if)#ppp authentication pap chap

如果同时启用了两种验证协议,则在配置中指定的第一种验证方式在链路协商过程中将被请求。如果另一端设备建议使用第二种验证方法,或者第一种验证方法没有通过,那么两台设备之间就开始尝试第二种验证方法。

这两个认证同时启用是只需要一种认证通过即可建立起链路通信。

 

 

总结:

pap是通过发送用户名和密码进行匹配,我们就必须使用sent-username  ** password **这条命令,并且这个用户名和密码可以通过抓包软件抓到,是明文传输的

chap的认证过程(单向认证,R2为服务器端,R1为客户端)

R2首先发一个挑战包给R1,包的内容包括:01(标识符,表示挑战分组)+ID(序列号)+随机数+自己的用户名(R2
R1接收到这个包后,将挑战包的用户名(R2),随机数,ID和本地数据库的密码gairuhe进行计算,得出MD5的值,然后发送给R2
这个回应的分组包括:02(回应标识符)+ID(和R2的一样)+hashMD5的计算值)+自己的用户名(R1
R2收到后,通过ID找到它发送的挑战包,然后把ID,随机数,以及密码(通过本地数据库查找R1对应的密码)进行计算,得出MD5的值
然后验证

 

因此chap的安全性高于pap

华为PAP/CHAP的配置步骤

=============

华为的考试中100%回出现类似的实验题,只要注意用户名和密码,就没有问题:)

1. 配置需求

路由器Quidway1Quidway2之间用接口Serial0互连,要求路由器Quidway1(验证方)以PAP方式验证路由器Quidway2(被验证方)。

2. 配置步骤

(1) 配置路由器Quidway1(验证方)

!在本地数据库中添加一个名 quidway2,验证密码为hello的用户。

Quidway(config)# user quidway2 password 0 hello

!配置本端启用PAP验证方式

Quidway(config)# interface serial 0

Quidway(config-if-serial0)# ppp authentication pap

(2) 配置路由器Quidway2(被验证方)

!配置本端以用户名为quidway2、密码为hello被对端进行验证。

Quidway(config)# interface serial 0

Quidway(config-if-serial0)# ppp pap sent-username quidway2 password 0 hello

1.5.2 CHAP验证举例

1. 配置需求

路由器Quidway1(验证方)以CHAP方式验证路由器Quidway2(被验证方)。

2. 配置步骤

(1) 配置路由器Quidway1(验证方)

!在本地数据库中添加一个名为quidway2,验证密码为hello的用户。

Quidway(config)# user quidway2 password 0 hello

!设置本端用户名为quidway1

Quidway(config)# interface serial 0

Quidway(config-if-serial0)# ppp chap host quidway1

!配置本端启用CHAP验证方式

Quidway(config-if-serial0)# ppp authentication chap

(2) 配置路由器Quidway2(被验证方)

!在本地数据库中添加一个名为quidway1,验证密码为hello的用户。

Quidway(config)# user quidway1 password 0 hello

!设置本端用户名为quidway2

Quidway(config)# interface serial 0

Quidway(config-if-serial0)# ppp chap host quidway2

本文来源:https://www.2haoxitong.net/k/doc/f291b0dea58da0116c1749c7.html

《神码公司关于路由器CHAP认证的配置命令.doc》
将本文的Word文档下载到电脑,方便收藏和打印
推荐度:
点击下载文档

文档为doc格式