1. 程式人生 > >##實驗 2-1 HDLC 和 PPP 配置

##實驗 2-1 HDLC 和 PPP 配置

##實驗 2-1 HDLC 和 PPP 配置
學習目標
 掌握HDLC的基本配置方法
 掌握DCE時鐘波特率的配置方法
 掌握PPP的基本配置方法
 掌握PPP鏈路的PAP認證的配置方法
 掌握PPP鏈路的CHAP認證的配置方法
在這裡插入圖片描述
場景
您是公司的網路管理員。公司總部有一臺路由器R2,R1和R3分別是其他兩
個分部的路由器。現在您需要將總部網路和分部網路通過廣域網連線起來。在廣域網鏈路上嘗試使用HDLC和PPP協議,並在使用PPP協議時配置了不同的認證方式保證安全。
步驟一. 實驗環境準備
如果本任務中您使用的是空配置裝置,需要從步驟1開始,然後跳過步驟2。
如果使用的裝置包含上一個實驗的配置,請直接從步驟2開始。
system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R1
system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R2
system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R3
步驟二. 清除裝置上原有的配置
刪除預設靜態路由的配置並關閉指定的乙太網介面。刪除無關的VLAN配置。
[R1]undo ip route-static 0.0.0.0 0
[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]shutdown
[R3]undo ip route-static 0.0.0.0 0
[R3]interface GigabitEthernet 0/0/2
[R3-GigabitEthernet0/0/2]shutdown
[S1]undo interface Vlanif 3
[S1]undo interface Vlanif 5
[S1]undo vlan batch 3 5 to 7
Warning: The configurations of the VLAN will be deleted. Continue?[Y/N]:y
Info: This operation may take a few seconds. Please wait for a moment…done.
[S1]interface GigabitEthernet 0/0/1
[S1-GigabitEthernet0/0/1]undo port default vlan
[S1-GigabitEthernet0/0/1]quit
[S1]undo ospf 1
[S2]undo interface Vlanif 5
[S2]undo interface Vlanif 7
[S2]undo vlan batch 3 to 5 7
Warning: The configurations of the VLAN will be deleted. Continue?[Y/N]:y
Info: This operation may take a few seconds. Please wait for a moment…done.
[S2]interface GigabitEthernet 0/0/3
[S2-GigabitEthernet0/0/3]undo port default vlan
[S2-GigabitEthernet0/0/3]quit
[S2]undo ospf 1
[S3]undo interface Vlanif 1
[S4]undo interface Vlanif 1
步驟三. 為 R1、R2 和 R3 的序列介面配置 IP 地址
[R1]interface Serial 1/0/0
[R1-Serial1/0/0]ip address 10.0.12.1 24
[R2]interface Serial 1/0/0
[R2-Serial1/0/0]ip address 10.0.12.2 24
[R2-Serial1/0/0]quit
[R2]interface Serial 2/0/0
[R2-Serial2/0/0]ip address 10.0.23.2 24
[R3]interface Serial 2/0/0
[R3-Serial2/0/0]ip address 10.0.23.3 24
步驟四. 在序列介面上啟用 HDLC 協議
[R1]interface Serial 1/0/0
[R1-Serial1/0/0]link-protocol hdlc
Warning: The encapsulation protocol of the link will be changed. Continue? [Y/N]:y
[R2]interface Serial 1/0/0
[R2-Serial1/0/0]link-protocol hdlc
Warning: The encapsulation protocol of the link will be changed. Continue? [Y/N]:y
[R2-Serial1/0/0]quit
[R2]interface Serial 2/0/0
[R2-Serial2/0/0]link-protocol hdlc
Warning: The encapsulation protocol of the link will be changed. Continue? [Y/N]:y
[R3]interface Serial 2/0/0
[R3-Serial2/0/0]link-protocol hdlc
Warning: The encapsulation protocol of the link will be changed. Continue? [Y/N]:y
配置完成後,檢視序列介面的狀態。以R1上的顯示資訊為例。
[R1]display interface Serial1/0/0
確認該介面的物理狀態和協議狀態均已UP後,檢測直連鏈路的連通性。
ping 10.0.12.1
步驟五. 配置 RIPv2
在三臺路由器上都啟用RIPv2路由協議,併發布各自的直連路由。
[R1]rip
[R1-rip-1]version 2
[R1-rip-1]network 10.0.0.0
[R2]rip
[R2-rip-1]version 2
[R2-rip-1]network 10.0.0.0
[R3]rip
[R3-rip-1]version 2
[R3-rip-1]network 10.0.0.0
配置完成後,檢查裝置是否通過RIPv2協議學習到了相應的路由。
display ip routing-table
步驟六. 管理串列埠連線
檢視序列介面連線的線纜的型別、介面狀態和時鐘頻率,並修改時鐘頻率。
display interface Serial1/0/0
回顯資訊表明R1的S1/0/0介面連線的是DCE線纜,時鐘頻率是64000bit/s。
DCE裝置可以控制時鐘頻率和頻寬。
將R1和R2間鏈路的時鐘頻率修改為128000bit/s。這一操作需在DCE裝置
R1上執行。
[R1]interface Serial 1/0/0
[R1-Serial1/0/0]baudrate 128000
配置完成後,檢視序列介面的狀態確認時鐘頻率已修改。
display interface Serial1/0/0
步驟七. 修改序列介面的封裝型別為 PPP
在R1和R2以及R2和R3間修改序列介面使用PPP封裝。鏈路兩端必須配置相
同的封裝型別,否則介面狀態會出現“Down”的情況。
[R1]interface Serial 1/0/0
[R1-Serial1/0/0]link-protocol ppp
Warning: The encapsulation protocol of the link will be changed. Continue? [Y/N]:y
[R2]interface Serial 1/0/0
[R2-Serial1/0/0]link-protocol ppp
Warning: The encapsulation protocol of the link will be changed. Continue? [Y/N]:y
[R2-Serial1/0/0]quit
[R2]interface Serial 2/0/0
[R2-Serial2/0/0]link-protocol ppp
Warning: The encapsulation protocol of the link will be changed. Continue? [Y/N]:y
[R3]interface Serial 2/0/0
[R3-Serial2/0/0]link-protocol ppp
Warning: The encapsulation protocol of the link will be changed. Continue? [Y/N]:y
配置完成後,檢測鏈路連通性。
ping 10.0.12.1
ping 10.0.23.3
如果無法Ping通,請檢視介面狀態,觀察協議狀態是否正常。
display interface Serial1/0/0
步驟八. 檢查路由表項的變化
PPP配置完成後,路由器之間會建立資料鏈路層的連線。本地路由器會向遠
端路由器傳送一條主機路由,路由資訊中包含本地介面的IP地址,掩碼為32位。
以R2為例,可以檢視到R1和R3傳送的主機路由。
[R2]display ip routing-table
可以看出,路由表中已經包含通往R1和R3的路由。回顧下這兩條路由的由
來和功能,回答下面兩個問題:
如果配置的是HDLC封裝,路由表中還會有這兩條路由嗎?
如果R1和R2上的S1/0/0介面IP地址不在同一網段,它們之間還能夠通過
HDLC或PPP實現通訊嗎?
步驟九. 在 R1 和 R2 間的 PPP 鏈路啟用 PAP 認證功能。
配置PAP認證功能,並將R1配置為PAP認證方。
[R1]interface Serial 1/0/0
[R1-Serial1/0/0]ppp authentication-mode pap
[R1-Serial1/0/0]quit
[R1]aaa
[R1-aaa]local-user huawei password cipher huawei123
info: A new user added
[R1-aaa]local-user huawei service-type ppp
將R2配置為PAP被認證方。
[R2]interface Serial 1/0/0
[R2-Serial1/0/0]ppp pap local-user huawei password cipher huawei123
配置完成後,檢測R1和R2間的連通性,並可以通過debug功能觀察PAP認
證報文的互動。
debugging ppp pap packet
terminal debugging
display debugging
PPP PAP packets debugging switch is on
system-view
[R1]interface Serial 1/0/0
[R1-Serial1/0/0]shutdown
[R1-Serial1/0/0]undo shutdown
步驟十. 在 R2 和 R3 間的 PPP 鏈路啟用 CHAP 認證功能
將R3配置為CHAP的認證方。
[R3]interface Serial 2/0/0
[R3-Serial2/0/0]ppp authentication-mode chap
[R3-Serial2/0/0]quit
[R3]aaa
[R3-aaa]local-user huawei password cipher huawei123
info: A new user added
[R3-aaa]local-user huawei service-type ppp
[R3-aaa]quit
[R3]interface Serial 2/0/0
[R3-Serial2/0/0]shutdown
[R3-Serial2/0/0]undo shutdown
注意,此時R3上會有如下提示:
Mar 10 2016 15:06:00+00:00 R3 %%01PPP/4/PEERNOCHAP(l)[5]:On the interface
Serial2/0/0, authentication failed and PPP link was closed because CHAP was
disabled on the peer.
[R3-Serial2/0/0]
Mar 10 2016 15:06:00+00:00 R3 %%01PPP/4/RESULTERR(l)[6]:On the interface
Serial2/0/0, LCP negotiation failed because the result cannot be accepted.
回顯資訊中灰色陰影標註的部分表明與對端認證時失敗。
將R2配置為CHAP的被認證方。
[R2]interface Serial 2/0/0
[R2-Serial2/0/0]ppp chap user huawei
[R2-Serial2/0/0]ppp chap password cipher huawei123
配置完成後,介面變為Up狀態。執行ping命令測試連通性。
ping 10.0.23.3
步驟十一. 使用debug 命令檢視 R2 和 R3 之間使用CHAP建立PPP
連線的協商過程
檢視R2與R3建立PPP連線時的協商情況,為了看到完整的協商過程,需要
先關閉R2的S2/0/0介面,然後啟動debug命令,再開啟介面,即可看到完整協
商過程。
首先關閉R2的物理介面。
[R2]interface Serial 2/0/0
[R2-Serial2/0/0]shutdown
執行debugging ppp chap
執行debugging ppp chap all和terminal debugging命令,檢視debug
資訊。
[R2-Serial2/0/0]return
debugging ppp chap all
terminal debugging
Info: Current terminal debugging is on.
display debugging
開啟R2的物理介面,發起認證。
system-view
Enter system view, return user view with Ctrl+Z.
[R2]interface Serial 2/0/0
[R2-Serial2/0/0]undo shutdown
附加練習:分析並驗證
為什麼PPP中CHAP認證比PAP認證的安全性更高?
配置檔案
[R1]display current-configuration
[V200R007C00SPC600]

sysname R1

aaa
authentication-scheme default
authorization-scheme default
accounting-scheme default
domain default
domain default_admin
local-user admin password cipher % % =i~>Xp&aY+*2cEVcS-A23Uwe%

%
local-user admin service-type http
local-user huawei password cipher % % B:%I)Io0H8)[%SB[idM3C/!#% %
local-user huawei service-type ppp

interface Serial1/0/0
link-protocol ppp
ppp authentication-mode pap
ip address 10.0.12.1 255.255.255.0
baudrate 128000

rip 1
version 2
network 10.0.0.0

user-interface con 0
authentication-mode password
set authentication password
cipher % % dD#}P<HzJ;Xs%X>hOkm!,.+Iq61QKK6tI}cc-;k_oC.+L,% %
user-interface vty 0 4

return
[R2]display current-configuration
[V200R007C00SPC600]

sysname R2

interface Serial1/0/0
link-protocol ppp
ppp pap local-user huawei password cipher % % u[hr6d<[email protected]>T7xr1< . i v .iv% %$
ip address 10.0.12.2 255.255.255.0

interface Serial2/0/0
link-protocol ppp
ppp chap user huawei
ppp chap password cipher % % e{5h)gh"/Uz0mUC%vEx3 4 &lt; m 4&lt;m% %$
ip address 10.0.23.2 255.255.255.0

rip 1
version 2
network 10.0.0.0

user-interface con 0
authentication-mode password
set authentication password
cipher % % |nRPL^hr2IXi7LHDID!/,.%.8%h;3:,hXO2dk#ikaWI.(,% %
user-interface vty 0 4

return
[R3]display current-configuration
[V200R007C00SPC600]

sysname R3

aaa
authentication-scheme default
authorization-scheme default
accounting-scheme default
domain default
domain default_admin
local-user admin password cipher % % =i~>Xp&aY+2cEVcS-A23Uwe% %
local-user admin service-type http
local-user huawei password cipher % % fZsyUk1=O=>:L4’ytgR~D
Im% %
local-user huawei service-type ppp

interface Serial2/0/0
link-protocol ppp
ppp authentication-mode chap
ip address 10.0.23.3 255.255.255.0

rip 1
version 2
network 10.0.0.0

user-interface con 0
authentication-mode password
set authentication password
cipher % % W|KaTeX parse error: Expected 'EOF', got '}' at position 5: )M5D}̲[email protected]^gK\;>QR,.*…%$
user-interface vty 0 4

return