HDLC 和PPP 的应用
HDLC 和PPP
广域网中经常会用串行链路来提供远距离的数据传输,高级数据链路控制HDLC(High-Level Data Link Control)和点对点协议PPP(Point to Point Protocol)两种典型的串口封装协议
串行链路普遍用于广域网中。串行链路中定义了两种数据传输方式:异步(字节为单位)和同步(帧)
HDLC 是高级数据链路控制,是一种面向比特的链路层协议,有三种类型的帧:
信息帧、监控帧、无编号帧
<Huawei>sy
[Huawei]undo info-center enable
Info: Information center is disabled.
[Huawei]dis inter brief
Interface PHY Protocol InUti OutUti inErrors outErrors
GigabitEthernet0/0/0 down down 0% 0% 0 0
GigabitEthernet0/0/1 down down 0% 0% 0 0
GigabitEthernet0/0/2 down down 0% 0% 0 0
NULL0 up up(s) 0% 0% 0 0
Serial4/0/0 up up 0% 0% 0 0
Serial4/0/1 down down 0% 0% 0 0
[Huawei]
[Huawei]
[Huawei]inter se4/0/0
##查看默认协议为ppp
[Huawei-Serial4/0/0]di th
[V200R003C00]
#
interface Serial4/0/0
link-protocol ppp
#修改成hdlc
[Huawei-Serial4/0/0]link-protocol hdlc
Warning: The encapsulation protocol of the link will be changed. Continue? [Y/N]
:y
[Huawei-Serial4/0/0]di th
[V200R003C00]
#
interface Serial4/0/0
link-protocol hdlc
#
return
##配置端口ip
[Huawei-Serial4/0/0]ip address 10.1.1.1 30
[Huawei-Serial4/0/0]di ip inter brief
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 unassigned down down
GigabitEthernet0/0/1 unassigned down down
GigabitEthernet0/0/2 unassigned down down
NULL0 unassigned up up(s)
Serial4/0/0 10.1.1.1/30 up down
Serial4/0/1 unassigned down down
##
第二台路由器
[Huawei]undo info-center enable
Info: Information center is disabled.
[Huawei]inter se 4/0/0
[Huawei-Serial4/0/0]di th
[V200R003C00]
#
interface Serial4/0/0
link-protocol ppp
#
return
[Huawei-Serial4/0/0]di inter brief
InUti/OutUti: input utility/output utility
Interface PHY Protocol InUti OutUti inErrors outErrors
GigabitEthernet0/0/0 down down 0% 0% 0 0
GigabitEthernet0/0/1 down down 0% 0% 0 0
GigabitEthernet0/0/2 down down 0% 0% 0 0
NULL0 up up(s) 0% 0% 0 0
Serial4/0/0 up down 0% 0% 0 0
Serial4/0/1 down down 0% 0% 0 0
[Huawei-Serial4/0/0]di th
[V200R003C00]
#
interface Serial4/0/0
link-protocol ppp
#
return
[Huawei-Serial4/0/0]link-protocol hdlc
Warning: The encapsulation protocol of the link will be changed. Continue? [Y/N]
:y
[Huawei-Serial4/0/0]di th
[V200R003C00]
#
interface Serial4/0/0
link-protocol hdlc
#
return
[Huawei-Serial4/0/0]di inter brief
Interface PHY Protocol InUti OutUti inErrors outErrors
GigabitEthernet0/0/0 down down 0% 0% 0 0
GigabitEthernet0/0/1 down down 0% 0% 0 0
GigabitEthernet0/0/2 down down 0% 0% 0 0
NULL0 up up(s) 0% 0% 0 0
Serial4/0/0 up up 0% 0% 0 0
Serial4/0/1 down down 0% 0% 0 0
[Huawei-Serial4/0/0]
[Huawei-Serial4/0/0]ip add 10.1.1.2 30
[Huawei]dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 7 Routes : 7
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.1.1.0/30 Direct 0 0 D 10.1.1.2 Serial4/0/0
10.1.1.2/32 Direct 0 0 D 127.0.0.1 Serial4/0/0
10.1.1.3/32 Direct 0 0 D 127.0.0.1 Serial4/0/0
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
[Huawei]
[Huawei]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 7 Routes : 7
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.1.1.0/30 Direct 0 0 D 10.1.1.1 Serial4/0/0
10.1.1.1/32 Direct 0 0 D 127.0.0.1 Serial4/0/0
10.1.1.3/32 Direct 0 0 D 127.0.0.1 Serial4/0/0
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
##测试连通性
[Huawei]ping 10.1.1.2
PING 10.1.1.2: 56 data bytes, press CTRL_C to break
Reply from 10.1.1.2: bytes=56 Sequence=1 ttl=255 time=430 ms
Reply from 10.1.1.2: bytes=56 Sequence=2 ttl=255 time=20 ms
Reply from 10.1.1.2: bytes=56 Sequence=3 ttl=255 time=20 ms
Reply from 10.1.1.2: bytes=56 Sequence=4 ttl=255 time=10 ms
Reply from 10.1.1.2: bytes=56 Sequence=5 ttl=255 time=20 ms
--- 10.1.1.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 10/100/430 ms
[Huawei]
#另一种方式用回环接口公用一个ip地址
[R1]inter lo
[R1]inter LoopBack 0
[R1-LoopBack0]ip add 10.1.1.1 32
[R1-LoopBack0]di th
[V200R003C00]
interface LoopBack0
ip address 10.1.1.1 255.255.255.255
return
[R1-LoopBack0]q
[R1]inter se1/0/0 link-protocol hdlc
[R1-Serial1/0/0]ip add unnumbered interface LoopBack 0
[R1]ip route-static 10.1.1.1 24 Serial 1/0/0
[R1]dis ip routing-table
10.1.1.0/24 Static 60 0 D 10.1.1.1 Serial1/0/0
10.1.1.1/32 Direct 0 0 D 127.0.0.1 LoopBack0
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
[R1]
###配置第二台路由器
Enter system view, return user view with Ctrl+Z.
[R2]inter lo 0
[R2-LoopBack0]ip add 10.1.1.2 32
[R2-LoopBack0]inter se 1/0/0
[R2-Serial1/0/0]di th
[V200R003C00]
#
interface Serial1/0/0
link-protocol ppp
#
return
[R2-Serial1/0/0]link-protocol hdlc
[R2-Serial1/0/0]ip add unnumbered interface LoopBack 0
##配置静态路由
[R2]ip route-static 10.1.1.0 24 Serial 1/0/0
[R2]dis ip routing-table
10.1.1.0/24 Static 60 0 D 10.1.1.2 Serial1/0/0
10.1.1.2/32 Direct 0 0 D 127.0.0.1 LoopBack0
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
##验证结果
[R2]ping 10.1.1.1
PING 10.1.1.1: 56 data bytes, press CTRL_C to break
Reply from 10.1.1.1: bytes=56 Sequence=1 ttl=255 time=40 ms
Reply from 10.1.1.1: bytes=56 Sequence=2 ttl=255 time=30 ms
Reply from 10.1.1.1: bytes=56 Sequence=3 ttl=255 time=30 ms
##查看接口地址
[R2]di ip inter brief
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 unassigned down down
GigabitEthernet0/0/1 unassigned down down
GigabitEthernet0/0/2 unassigned down down
LoopBack0 10.1.1.2/32 up up(s)
NULL0 unassigned up up(s)
Serial1/0/0 10.1.1.2/32 up up
Serial1/0/1 unassigned down down
[R2]
PPP 协议是一种点到点链路层协议,主要用于在全双工的同异步链路上进行点到点的数据传输
PPP 可以动态的学习到对方的路由,因此不用再配置静态路由
ppp协议有点
1. PPP 支持同步传输又支持异步传输
2.PPP 协议具有很好的扩展性
3.PPP 提供了LCP协议,用于各种链路层参数的协商
4.PPP 提供了各种NCP协议,用户各网络层参数的协商
5.PPP 提供了认证协议CHAP,更好的保证了网络的安全性
6.无重传机制,网络开销小,速度快
PPP包含两个组件:链路控制协议LCP和网络层控制协议NCP。
PPP 认证模式 PAP 和CHAP
PAP 认证的工作原理较为简单。PAP认证协议为两次握手认证协议,密码以明文方式在链路上发送
LCP协商完成后,认证方要求被认证方使用PAP进行认证
被认证方式将配置的用户名和密码信息使用Authenticate-Request报文以明文方式发送给认证方
认证方收到被认证方发送的用户名和密码信息之后,根据本地配置的用户名和密码数据库检查用户名和密码信息是否匹配,
如果匹配,则返回Authenticate-Ack报文,表示认证成功。否则,返回Authenticate-Nak报文,表示认证失败
CHAP 认证过程和PAP方式差不多,不过需要三次报文交互和信息加密传输,安全性提高
配置实例
##R1路由器
[R1]di cu
sysname R1
undo info-center enable
interface Serial1/0/0
link-protocol ppp
ip address unnumbered interface LoopBack0
interface Serial1/0/1
link-protocol ppp
interface LoopBack0
ip address 10.1.1.1 255.255.255.255
##R2路由器
sysname R2
drop illegal-mac alarm
undo info-center enable
local-user admin service-type http
firewall zone Local
priority 15
interface Serial1/0/0
link-protocol ppp
ip address unnumbered interface LoopBack0
interface Serial1/0/1
link-protocol ppp
interface NULL0
interface LoopBack0
ip address 10.2.2.2 255.255.255.255
PPP 可以动态的学习到对方的路由,因此不用再配置静态路由
##配置认证方式
默认情况下可以认证也可以不认证,如果认证有两种方式pap 和chap
###调用与来认证pap
##开启域的认证 认证方是R1
[R1]inter se 1/0/0
[R1-Serial1/0/0]ppp authentication-mode pap domain sam
###重启下端口确认端口是down的
[R1-Serial1/0/0]di ip inter br
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 unassigned down down
GigabitEthernet0/0/1 unassigned down down
GigabitEthernet0/0/2 unassigned down down
LoopBack0 1.1.1.1/32 up up(s)
NULL0 unassigned up up(s)
Serial1/0/0 1.1.1.1/32 up up
Serial1/0/1 unassigned down down
[R1-Serial1/0/0]shut
[R1-Serial1/0/0]undo shut
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 unassigned down down
GigabitEthernet0/0/1 unassigned down down
GigabitEthernet0/0/2 unassigned down down
LoopBack0 1.1.1.1/32 up up(s)
NULL0 unassigned up up(s)
Serial1/0/0 1.1.1.1/32 up down
Serial1/0/1 unassigned down down
[R1-Serial1/0/0]
###在R2 上操作创建一个用户名和密码
[R2-Serial1/0/0]ppp pap local-user huawei password simple huawei
##在R1上操作配置aaa 数据库
[R1-Serial1/0/0]aaa
[R1-aaa]auth
##配置认证模板
[R1-aaa]authentication-scheme huawei
Info: Create a new authentication scheme.
##配置认证模式是本地local
[R1-aaa-authen-huawei]authentication-mode local
[R1-aaa-authen-huawei]q
##创建一个domain
[R1-aaa]domain SAM
Info: Success to create a new domain.
##在domain 中调用认证模板
[R1-aaa-domain-sam]auth
[R1-aaa-domain-sam]authentication-scheme huawei
###创建一个本地用户
[R1]aaa
[R1-aaa]local-user huawei password cipher huawei
Info: Add a new user.
##服务类型是ppp
[R1-aaa]local-user huawei service-type ppp
[R1-aaa]
[R1]dis ip inter br
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 3
The number of interface that is DOWN in Physical is 4
The number of interface that is UP in Protocol is 3
The number of interface that is DOWN in Protocol is 4
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 unassigned down down
GigabitEthernet0/0/1 unassigned down down
GigabitEthernet0/0/2 unassigned down down
LoopBack0 1.1.1.1/32 up up(s)
NULL0 unassigned up up(s)
Serial1/0/0 1.1.1.1/32 up up
Serial1/0/1 unassigned down down
[R1]
###chap 认证模式 认证方为R1
<Huawei>sy
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R1
##设置ip地址
[R1]inter lo 0
[R1-LoopBack0]ip add 1.1.1.1 32
[R1-LoopBack0]inter se 1/0/0
[R1-Serial1/0/0]ip add unn inter lo 0
[R1-Serial1/0/0]
##设置认证方
[R1-Serial1/0/0]ppp authentication-mode chap domain sam
###进入数据库设置授权模式
[R1-Serial1/0/0]aaa
[R1-aaa]auth
[R1-aaa]authentication-scheme huawei
Info: Create a new authentication scheme.
[R1-aaa-authen-huawei]authentication-mode local
[R1-aaa-authen-huawei]q
##将授权模式加入域sam
[R1-aaa]domain sam
Info: Success to create a new domain.
[R1-aaa-domain-sam]authentication-scheme huawei
[R1-aaa-domain-sam]q
###设置本地用户名和密码
[R1-aaa]local-user huawei password cipher huawei
Info: Add a new user.
[R1-aaa]local-user huawei service-type ppp
[R1-aaa]
###在R2 上设置
<R2>sy
[R2-Serial1/0/0]ppp chap user huawei
[R2-Serial1/0/0]ppp chap password cipher huawei
[R2-Serial1/0/0]
##测试联通性
[R2-Serial1/0/0]ping 1.1.1.1
PING 1.1.1.1: 56 data bytes, press CTRL_C to break
Reply from 1.1.1.1: bytes=56 Sequence=1 ttl=255 time=130 ms
Reply from 1.1.1.1: bytes=56 Sequence=2 ttl=255 time=10 ms
Reply from 1.1.1.1: bytes=56 Sequence=3 ttl=255 time=30 ms
Reply from 1.1.1.1: bytes=56 Sequence=4 ttl=255 time=20 ms
Reply from 1.1.1.1: bytes=56 Sequence=5 ttl=255 time=20 ms
--- 1.1.1.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 10/42/130 ms
[R2-Serial1/0/0]
上一篇: 搭建Magento电子商务网站
下一篇: pytorch入坑指南
推荐阅读
-
HDLC 和PPP 的应用
-
查找和定位Android应用的按钮点击事件的代码位置基于Xposed Hook实现
-
JFreeChart展示柱状图和折线图的组合 博客分类: 应用 jfreechartajaxJavaScript
-
Neo4j 图数据库高级应用系列 / 服务器扩展指南 APOC(6.6):节点和关系的相互转换
-
详解JRE和JDK的区别 博客分类: Java JDKJava应用服务器企业应用浏览器
-
适用于Android应用的RxJava 2:RxBinding和RxLifecycle
-
python的while循环和for循环的应用区别
-
Java总结05 Java集合体系.最高集合接口Collection和其迭代器/一般集合接口List和其迭代器/增强版For循环的应用
-
js和原生应用常用的数据交互方式
-
android之视频播放系统VideoView和自定义VideoView控件的应用 VideoAndroid自定义控件Android视频视频