实验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 认证的配置方法
Ø    实验拓扑


 实验步骤
在实验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 具有较好的安全性能


原文地址:https://www.cnblogs.com/zhongguiyao/p/8012390.html