6.4 PPP协议配置实验
6.4.1实验目的
- 加深对PPP协议工作过程的理解,掌握PPP协议的配置
- 掌握PPP两种认证协议的配置
6.4.2 背景描述
某公司为了满足业务需求,申请了专线接入,为了与ISP进行链路协商时验证身份,网络管理员需要在路由器上配置验证,来保障链路的安全通信。
6.4.3 实验设备
- RG-R1700系列路由器二台
- PC 一台,必须能够打开管理端网页,进行设备配置
- V.35电缆线一根
6.4.4 实验拓扑图
实验拓扑如图3-1所示

图3-1 PPP协议配置
6.4.5 实验步骤
在实验中,R1和R2通过V.35线连接,其中R1设置成DCE设备,只需在R1上配置时钟频率即可。
1. PAP认证
- 对路由器R1的配置
R1>en 14
Password:
R1#conf t
R1(config)#username R2 password R2 (在本地路由器上建立远程路由器的用户名和
密码)
R1(config)#int s1/2 (进入接口配置模式)
R1(config-if)#clock rate 64000 (设置时钟,使之成为DCE设备)
R1(config-if)#encapsulation ppp (封装PPP协议)
R1(config-if)#ppp authentication pap (用PAP进行验证)
R1(config-if)#ip address 10.1.1.1 255.255.255.0 (为接口配置IP)
R1(config-if)#no shut (激活端口)
R1(config-if)# R1(config-if)#ppp pap sent-username R1 password 0 R1 (在建立连接时,发送本地路由器的用户名和密码)
R1(config-if)#exit
R1(config)#exit
R1#
注意:这里发送的用户名和密码必须和在另一台机器上设置的用户名和密码一致。
实验结果:
1、show running-config
2、show s1/2
- 对路由器R2的配置
R2>en 14
Password:
R2#conf t
R2(config)#username R1 password R1
R2(config)#int s1/2
R2(config-if)#encapsulation ppp
R2(config-if)#ppp authentication pap
R2(config-if)#ip address 10.1.1.2 255.255.255.0
R2(config-if)#no shut
R2(config-if)# ppp pap sent-username R2 password 0 R2
%LINE PROTOCOL CHANGE: Interface serial 1/2, changed state to UP (此时经过设置好的PPP自动认证后链路建立)
R2(config-if)#exit
R2(config)#exit
R2#
实验结果:
1、show running-config
2、show s1/2
- 配置完后,可通过Ping命令检查配置是否成功。
实验结果:
ping 对端ip地址
试试看:
(4)用debug ppp authentication查看PPP链路的建立过程。
- 在R1中开启debug调试
R1#debug ppp authentication
- 把R2的S1/2口shutdown掉,再no shutdown激活
R2(config)#int s1/2
R2(config-if)#shut
R2(config-if)#
%LINK CHANGED: Interface serial 1/2, changed state to administratively down
%LINE PROTOCOL CHANGE: Interface serial 1/2, changed state to DOWN
R2(config-if)#
R2(config-if)#no shut
R2(config-if)#
%LINK CHANGED: Interface serial 1/2, changed state to up
%LINE PROTOCOL CHANGE: Interface serial 1/2, changed state to UP
R2 CON0 is now available
- 此时在R1上将会显示出PPP认证的过程信息,如下
PPP: serial1/2 authentication event enqueue ,message type = [RECV_PAP_REQUEST]
PPP: dispose authentication message [RECV_PAP_REQUEST](显示PAP请求/接受信息)
PPP: serial 1/2 PAP authenticating peer R2 (PAP认证对端设备为R2)
PPP: serial 1/2 Remote passed PAP authentication sending Auth-Ack to peer.(向对端发送带有密码的PAP请求认证数据,要求得到确认)
PPP: serial 1/2 PAP ACK received (收到PAP确认数据,包含有R2的通信密码)
PPP: serial 1/2 Passed PAP authentication with remote (向远端进行认证连接)
PPP: serial 1/2 lcp authentication OK! (链路控制连接建立完成)
PPP: ppp_clear_author(), protocol = TYPE_IPCP (网络层连接接口所承载
的协议是IP)
%LINE PROTOCOL CHANGE: Interface serial 1/2, changed state to UP
R1#
R1 CON0 is now available
2. CHAP认证
- 对路由器R1配置
R1(config)#username R2 password 0 rgr1700 (设置认证密码为rgr1700)
R1(config)#int s1/2
R1(config-if)#clock rate 64000
R1(config-if)#encapsulation ppp
R1(config-if)#ppp authentication chap (用CHAP进行认证)
R1(config-if)#ip address 10.1.1.1 255.255.255.0
R1(config-if)#no shut
R1(config-if)#ppp chap hostname R1
R1(config-if)#ppp chap password 0 rgr1700
R1(config-if)#exit
R1(config)#exit
R1#
实验结果:
1、show running-config
2、show s1/2
- 对路由器R2配置
R2(config)#username R1 password 0 rgr1700 (设置认证密码为rgr1700)
R2(config)#int s1/2
R2(config-if)#encapsulation ppp
R2(config-if)#ppp authentication chap
R2(config-if)#ip address 10.1.1.2 255.255.255.0
R2(config-if)#no shut
R2(config-if)#ppp chap hostname R2
R2(config-if)#ppp chap password 0 rgr1700 (设置认证密码为rgr1700)
R2(config-if)#exit
R2(config)#exit
R2#
实验结果:
1、show running-config
2、show s1/2
注意:用CHAP进行认证时,双方的密钥都必须相同。
说明:在配置R2的命令中,可以不添加ppp chap hostname R2 和ppp chap password 0 rgr1700,CHAP 认证过程仍然可以建立完成,这是锐捷产品的一个特性。
(3)配置完后,通过Ping命令检查配置是否成功。
实验结果:
Ping 对端ip地址
试试看:
(4)用debug ppp authentication查看PPP链路CHAP认证的建立过程。
1.在R1中开启debug调试
R1#debug ppp authentication
2.把R2的S1/2口shutdown掉,再no shutdown激活
3.观察R1窗口中的显示信息
PPP: serial 1/2 Using CHAP hostname R1.
PPP: serial 1/2 Send CHAP challenge id=18 to remote host
PPP: serial 1/2 authentication event enqueue ,message type = [RECV_CHAP_RESPONSE]
PPP: dispose authentication message [RECV_CHAP_RESPONSE]
PPP: serial 1/2 CHAP response id=18 ,received from R2
PPP: serial 1/2 Send CHAP success id=18 to remote
PPP: serial 1/2 remote router passed CHAP authentication.
PPP: serial 1/2 lcp authentication OK!
PPP: ppp_clear_author(), protocol = TYPE_IPCP
说明:如果在创建密码的时候,两个路由器上配置的认证密码不一样,或者配置有错误,那么PPP CHAP的LCP认证过程将会失败,在R1上将会有如下显示:
PPP: serial 1/2 Using CHAP hostname R1.
PPP: serial 1/2 Send CHAP challenge id=3 to remote host (3是进行建立认证连接的次数)
PPP: serial 1/2 authentication event enqueue ,message type = [RECV_CHAP_RESPONSE]
PPP: dispose authentication message [RECV_CHAP_RESPONSE]
PPP: serial 1/2 CHAP response id=3 ,received from R2
PPP: serial 1/2 Send CHAP failure to remote router (发送CHAP认证失败)
PPP: ppp_clear_author(), protocol = TYPE_LCP
PPP: ppp_clear_author(), protocol = TYPE_LCP
3. PAP和CHAP认证
可以在接口上同时使用PAP和CHAP认证。在链路协商阶段,请求使用第一个种方法;如果对方建议使用第二种方法,或拒绝使用第一种方法,那么会试图使用第二种方法。这种配置很有用,因为有远程设备只支持CHAP,而有些只支持PAP。实现这种配置的命令如下:
R1(config-if)#ppp authentication pap chap
不建议采用上述配置,因为这样将首先尝试以明文方式传输密码PAP,而不是更安全的CHAP。因此应采用下述配置;
R1(config-if)#ppp authentication chap pap
当配置完PPP协议认证后,可使用debug ppp event查看PPP协议动态信息。
也可使用debug ppp packet查看链路底层PPP协议协议包的显示信息如下
R2#debug ppp packet
PPP: serial 1/2 [S] LCP ECHOREQ id 183 len 12 magic 0x6f9f0c
PPP: [R] skb proto-type 0xc021,ppp-frame size 12 pdt_type=6
[len=12] 0a b7 00 0c 00 c0 98 fb 3f 01 65 47
PPP: [R] skb proto-type 0xc021,ppp-frame size 12 pdt_type=6
[len=12] 0a b7 00 0c 00 c0 98 fb 3f 01 65 47
PPP: ppp_skb_enqueue [R] pd_type= 6
[len=10] ff 03 c0 21 0a b7 00 0c 00 c0
PPP: serial 1/2 [R] LCP ECHOREP id 183 len 12 magic 0xc098fb
PPP: serial 1/2 received echo id 183, sent echo id 183, line protocol up
PPP: [R] skb proto-type 0xc021,ppp-frame size 12 pdt_type=6
[len=12] 09 b7 00 0c 00 c0 98 fb 3f 01 65 47
PPP: [R] skb proto-type 0xc021,ppp-frame size 12 pdt_type=6
[len=12] 09 b7 00 0c 00 c0 98 fb 3f 01 65 47
PPP: ppp_skb_enqueue [R] pd_type= 6
[len=10] ff 03 c0 21 09 b7 00 0c 00 c0
PPP: serial 1/2 [R] LCP ECHOREQ id 183 len 12 magic 0xc098fb
PPP: serial 1/2 [S] LCP ECHOREP id 183 len 12 magic 0x6f9f
PPP: serial 1/2 [S] LCP ECHOREQ id 184 len 12 magic 0x6f9f0c
PPP: [R] skb proto-type 0xc021,ppp-frame size 12 pdt_type=6
[len=12] 0a b8 00 0c 00 c0 98 fb 3f 01 65 47
不过此命令最好不要打开,因为可能会有很多不断的包数据显示,出现刷屏的后果,这时候你就不得不使用undebug all命令手动关掉调试引擎。
PPP还有一些LCP协商其他的选项的配置,如压缩、回叫、多链路。在本实验中就不再详细介绍,读者可以查看相关书籍进一步了解PPP协议的配置。









