實驗18:HDLC和PPP

 

實驗15-1:HDLC 和PPP 封裝

Ø     實驗目的
經過本實驗,讀者能夠掌握以下技能:
(1) 串行鏈路上的封裝概念
(2) HDLC 封裝
(3) PPP 封裝

Ø     實驗拓撲

安全

 

 實驗步驟
n    步驟1:在R1 和R2 路由器上配置IP 地址、保證直連鏈路的連通性
R1(config)#int s1/0
R1(config-if)#ip address 192.168.12.1 255.255.255.0
R1(config-if)#no shutdown

R2(config)#int s1/0
R2(config-if)#clock rate 64000
R2(config-if)#ip address 192.168.12.2 255.255.255.0
R2(config-if)#no shutdown

R1#show int s1/0
Serial1/0 is up, line protocol is up
  Hardware is M4T
  Internet address is 192.168.12.1/24
  MTU 1500 bytes, BW 1544 Kbit, DLY 20000 usec,
  reliability 255/255, txload 1/255, rxload 1/255
  Encapsulation HDLC, crc 16, loopback not set      //該接口的默認封裝爲HDLC 封裝


n     步驟2:改變串行鏈路兩端的接口封裝爲PPP 封裝
R1(config)#int s1/0
R1(config-if)#encapsulation ppp
R2(config)#int s1/0
R2(config-if)#encapsulation ppp


R1#show int s1/0
Serial1/0 is up, line protocol is up
  Hardware is M4T
  Internet address is 192.168.12.1/24
  MTU 1500 bytes, BW 1544 Kbit, DLY 20000 usec,
     reliability 255/255, txload 1/255, rxload 1/255
  Encapsulation PPP, LCP Open                   //該接口的封裝爲PPP 封裝
  Open: IPCP, CDPCP, crc 16, loopback not set     //網絡層支持IP 和CDP 協議


Ø     實驗調試
n    測試R1 和R2 之間串行鏈路的連通性
R1#ping 192.168.12.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.12.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/36/68 ms
若是鏈路的兩端封裝相同,則ping 測試應該正常

n    鏈路兩端封裝不一樣協議
R1(config)#int s1/0
R1(config-if)#encapsulation ppp
R2(config)#int s1/0
R2(config-if)#encapsulation hdlc

R1#show int s1/0
Serial1/0 is up, line protocol is down
(此處省略)
//兩端封裝不匹配,致使鏈路故障

【提示】顯示串行接口時,常見如下幾種狀態:
Serial1/0 is up, line protocol is up
//鏈路正常
Serial1/0 is administratively down, line protocol is down
//沒有打開該接口,執行「no shutdown」能夠打開接口
Serial1/0 is up, line protocol is down
//物理層正常,數據鏈路層有問題,一般是沒有配置時鐘、兩端封裝不匹配、PPP 認證錯誤
Serial1/0 is down, line protocol is down
//物理層故障,一般是連線問題



實驗15-2:PPP認證
PAP 認證
Ø     實驗目的
經過本實驗,讀者能夠掌握PAP 認證的配置方法
Ø     實驗拓撲


網絡

 

 

 實驗步驟
在實驗9-1 基礎上繼續本實驗。首先配置路由器R1(遠程路由器,被認證方)在路由器R2(中心路由器,認證方)取得驗證:
n    兩端路由器上的串口採用PPP 封裝,用「encapsulation」命令:
R1(config)#int s1/0
R1(config-if)#encapsulation ppp
R1(config-if)#ppp authentication pap
n    在遠程路由器R1 上,配置在中心路由器上登陸的用戶名和密碼,使用「ppp pap
sent-username 用戶名 password 密碼」命令:
R1(config-if)#ppp pap sent-username R1 password 123456
n    在中心路由器上的串口採用PPP 封裝,用「encapsulation」命令:
R2(config)#int s1/0
R2(config-if)#encapsulation ppp
n    在中心路由器上,配置PAP 驗證,使用「ppp authentication pap」命令:
R2(config-if)#ppp authentication pap
n    中心路由器上爲遠程路由器設置用戶名和密碼,使用「username 用戶名 password 密碼」命令:
R2(config)#username R1 password 123456
以上的步驟只是配置了R1(遠程路由器)在R2(中心路由器)取得驗證,即單向驗證。
然而在實際應用中一般是採用雙向驗證,即:R2 要驗證R1,而R1 也要驗證R2。咱們要採用相似的步驟進行配置R1 對R2 進行驗證,這時R1 爲中心路由器,R2 爲遠程路由器了:
n    在中心路由器R1 上,配置PAP 驗證,使用「ppp authentication pap」命令:
R1(config-if)#ppp authentication pap
n    在中心路由器R1 上爲遠程路由器R2 設置用戶名和密碼,使用「username 用戶名password 密碼」命令:
R1(config)#username R2 password 654321
n    在遠程路由器R2 上,配置以什麼用戶和密碼在遠程路由器上登陸,使用「ppp pap
sent-username 用戶名 password 密碼」命令:
R2(config-if)#ppp pap sent-username R2 password 654321

【提示】在ISDN 撥號上網時,卻一般只是電信對用戶進行驗證(要根據用戶名來收費),用戶不能對電信進行驗證,即驗證是單向的。

Ø     實驗調試
使用「debug ppp authentication」命令能夠查看ppp 認證過程。
R1#debug ppp authentication
PPP authentication debugging is on
//以上打開ppp 認證調試
R1(config)#int s1/0
R1(config-if)#shutdown
R1(config-if)#no shutdown

//因爲PAP 認證是在鏈路創建後進行一次,把接口關閉從新打開以便觀察認證過程

*Mar  1 00:40:14.411: %LINK-3-UPDOWN: Interface Serial1/0, changed state to up
*Mar  1 00:40:14.415: Se1/0 PPP: Using default call direction
*Mar  1 00:40:14.419: Se1/0 PPP: Treating connection as a dedicated line
*Mar  1 00:40:14.423: Se1/0 PPP: Session handle[B200001D] Session id[36]
*Mar  1 00:40:14.427: Se1/0 PPP: Authorization required
*Mar  1 00:40:14.499: Se1/0 PAP: Using hostname from interface PAP
*Mar  1 00:40:14.499: Se1/0 PAP: Using password from interface PAP
*Mar  1 00:40:14.503: Se1/0 PAP: O AUTH-REQ id 23 len 14 from "R1"
*Mar  1 00:40:14.531: Se1/0 PAP: I AUTH-REQ id 23 len 14 from "R2"
*Mar  1 00:40:14.535: Se1/0 PAP: Authenticating peer R2
*Mar  1 00:40:14.543: Se1/0 PPP: Sent PAP LOGIN Request
*Mar  1 00:40:14.551: Se1/0 PPP: Received LOGIN Response PASS
*Mar  1 00:40:14.555: Se1/0 PAP: I AUTH-ACK id 23 len 5
*Mar  1 00:40:14.559: Se1/0 PPP: Sent LCP AUTHOR Request
*Mar  1 00:40:14.563: Se1/0 PPP: Sent IPCP AUTHOR Request
*Mar  1 00:40:14.571: Se1/0 LCP: Received AAA AUTHOR Response PASS
*Mar  1 00:40:14.575: Se1/0 IPCP: Received AAA AUTHOR Response PASS
*Mar  1 00:40:14.579: Se1/0 PAP: O AUTH-ACK id 23 len 5
*Mar  1 00:40:14.587: Se1/0 PPP: Sent CDPCP AUTHOR Request
*Mar  1 00:40:14.599: Se1/0 CDPCP: Received AAA AUTHOR Response PASS
*Mar  1 00:40:14.699: Se1/0 PPP: Sent IPCP AUTHOR Request
//以上是認證成功的例子

*Mar  1 00:46:22.659: Se1/0 PPP: Authorization required
*Mar  1 00:46:22.707: Se1/0 PAP: Using hostname from interface PAP
*Mar  1 00:46:22.707: Se1/0 PAP: Using password from interface PAP
*Mar  1 00:46:22.711: Se1/0 PAP: O AUTH-REQ id 30 len 14 from "R1"
*Mar  1 00:46:22.767: Se1/0 PAP: I AUTH-REQ id 30 len 14 from "R2"
*Mar  1 00:46:22.771: Se1/0 PAP: Authenticating peer R2
*Mar  1 00:46:22.775: Se1/0 PAP: I AUTH-ACK id 30 len 5
*Mar  1 00:46:22.779: Se1/0 PPP: Sent PAP LOGIN Request
*Mar  1 00:46:22.783: Se1/0 PPP: Received LOGIN Response FAIL
*Mar  1 00:46:22.787: Se1/0 PAP: O AUTH-NAK id 30 len 26 msg is "Authentication failed"

//以上是認證失敗的例子,例如密碼錯誤等


CHAP 認證
Ø     實驗目的
經過本實驗,讀者能夠掌握CHAP 認證的配置方法
Ø    實驗拓撲


oop

 

 實驗步驟
在實驗9-2 基礎上繼續本實驗。
n    步驟1 : 使用「username 用戶名 password 密碼」 命令爲對方配置用戶名和密碼,須要注意的是兩方的密碼要相同:
R1(config)#username R2 password liming
R2(config)#username R1 password liming
n    步驟2 : 路由器的兩端串口採用PPP 封裝,並採用配置CHAP 驗證:
R1(config)#int s1/0
R1(config-if)#encapsulation ppp
R1(config-if)#ppp authentication chap
R2(config)#int s1/0
R2(config-if)#encapsulation ppp
R2(config-if)#ppp authentication chap
上面是CHAP 驗證的最簡單配置,也是實際應用中最經常使用的配置方式。配置時要求用戶名爲對方路由器名,而雙方密碼必須一致。緣由是:因爲CHAP 默認使用本地路由器的名字作爲創建PPP 鏈接時的識別符。路由器在收到對方發送過來的詢問消息後,將本地路由器的名字做爲身份標識發送給對方;而在收到對方發過來的身份標識以後,默認使用本地驗證方法,即在配置文件中尋找,看看有沒有用戶身份標識和密碼;若是有,計算加密值,結果正確則驗證經過;不然驗證失敗,鏈接沒法創建。
【提示】在配置驗證時也能夠選擇同時使用PAP 和CHAP,如:
R2(config-if)#ppp authentication chap pap 或
R2(config-if)#ppp authentication pap chap
若是同時使用兩種驗證方式,那麼在鏈路協商階段將先用第一種驗證方式進行驗證。若是對方建議使用第二種驗證方式或者只是簡單拒絕使用第一種方式,那麼將採用第二種方式。

【實驗小結】
本章介紹了串行鏈路上經常使用的兩種封裝方法:HDLC 和PPP,前者只在Cisco 設備間使用,後者能夠用於不一樣廠商的設備間。PPP 和HDLC 相比有較多的功能:支持多網絡層協議、支持認證、支持多鏈路捆綁、支持回撥和壓縮等。PPP 的認證有兩種方式:PAP 和CHAP,CHAP比起PAP 具備較好的安全性能


性能

相關文章
相關標籤/搜索