6.4 PPP協(xié)議配置實驗
6.4.1實驗目的
- 加深對PPP協(xié)議工作過程的理解,掌握PPP協(xié)議的配置
- 掌握PPP兩種認證協(xié)議的配置
6.4.2 背景描述
某公司為了滿足業(yè)務需求,申請了專線接入,為了與ISP進行鏈路協(xié)商時驗證身份,網(wǎng)絡管理員需要在路由器上配置驗證,來保障鏈路的安全通信。
6.4.3 實驗設備
- RG-R1700系列路由器二臺
- PC 一臺,必須能夠打開管理端網(wǎng)頁,進行設備配置
- V.35電纜線一根
6.4.4 實驗拓撲圖
實驗拓撲如圖3-1所示
圖3-1 PPP協(xié)議配置
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協(xié)議)
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 (在建立連接時,發(fā)送本地路由器的用戶名和密碼)
R1(config-if)#exit
R1(config)#exit
R1#
注意:這里發(fā)送的用戶名和密碼必須和在另一臺機器上設置的用戶名和密碼一致。
實驗結(jié)果:
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 (此時經(jīng)過設置好的PPP自動認證后鏈路建立)
R2(config-if)#exit
R2(config)#exit
R2#
實驗結(jié)果:
1、show running-config
2、show s1/2
- 配置完后,可通過Ping命令檢查配置是否成功。
實驗結(jié)果:
ping 對端ip地址
試試看:
(4)用debug ppp authentication查看PPP鏈路的建立過程。
- 在R1中開啟debug調(diào)試
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.(向?qū)Χ税l(fā)送帶有密碼的PAP請求認證數(shù)據(jù),要求得到確認)
PPP: serial 1/2 PAP ACK received (收到PAP確認數(shù)據(jù),包含有R2的通信密碼)
PPP: serial 1/2 Passed PAP authentication with remote (向遠端進行認證連接)
PPP: serial 1/2 lcp authentication OK! (鏈路控制連接建立完成)
PPP: ppp_clear_author(), protocol = TYPE_IPCP (網(wǎng)絡層連接接口所承載
的協(xié)議是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#
實驗結(jié)果:
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#
實驗結(jié)果:
1、show running-config
2、show s1/2
注意:用CHAP進行認證時,雙方的密鑰都必須相同。
說明:在配置R2的命令中,可以不添加ppp chap hostname R2 和ppp chap password 0 rgr1700,CHAP 認證過程仍然可以建立完成,這是銳捷產(chǎn)品的一個特性。
(3)配置完后,通過Ping命令檢查配置是否成功。
實驗結(jié)果:
Ping 對端ip地址
試試看:
(4)用debug ppp authentication查看PPP鏈路CHAP認證的建立過程。
1.在R1中開啟debug調(diào)試
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
說明:如果在創(chuàng)建密碼的時候,兩個路由器上配置的認證密碼不一樣,或者配置有錯誤,那么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是進行建立認證連接的次數(shù))
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 (發(fā)送CHAP認證失敗)
PPP: ppp_clear_author(), protocol = TYPE_LCP
PPP: ppp_clear_author(), protocol = TYPE_LCP
3. PAP和CHAP認證
可以在接口上同時使用PAP和CHAP認證。在鏈路協(xié)商階段,請求使用第一個種方法;如果對方建議使用第二種方法,或拒絕使用第一種方法,那么會試圖使用第二種方法。這種配置很有用,因為有遠程設備只支持CHAP,而有些只支持PAP。實現(xiàn)這種配置的命令如下:
R1(config-if)#ppp authentication pap chap
不建議采用上述配置,因為這樣將首先嘗試以明文方式傳輸密碼PAP,而不是更安全的CHAP。因此應采用下述配置;
R1(config-if)#ppp authentication chap pap
當配置完PPP協(xié)議認證后,可使用debug ppp event查看PPP協(xié)議動態(tài)信息。
也可使用debug ppp packet查看鏈路底層PPP協(xié)議協(xié)議包的顯示信息如下
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
不過此命令最好不要打開,因為可能會有很多不斷的包數(shù)據(jù)顯示,出現(xiàn)刷屏的后果,這時候你就不得不使用undebug all命令手動關掉調(diào)試引擎。
PPP還有一些LCP協(xié)商其他的選項的配置,如壓縮、回叫、多鏈路。在本實驗中就不再詳細介紹,讀者可以查看相關書籍進一步了解PPP協(xié)議的配置。