1.ppp基础配置
注:做完案例记得保存,案例是层层递进的!
以下案例做分析
注意事项
1.路由器配置如下:将2SA拖到上端
2.连线选择serial,否则最后ping不通
RT-BJ配置如下
<Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]sysname RT-BJ [RT-BJ]display interface Serial 4/0/0 Serial4/0/0 current state : UP Line protocol current state : UP Last line protocol up time : 2023-09-12 17:21:38 UTC-08:00 Description:HUAWEI, AR Series, Serial4/0/0 Interface Route Port,The Maximum Transmit Unit is 1500, Hold timer is 10(sec) Internet protocol processing : disabled Link layer protocol is PPP LCP opened Last physical up time : 2023-09-12 17:21:36 UTC-08:00 Last physical down time : 2023-09-12 17:21:31 UTC-08:00 Current system time: 2023-09-12 17:22:48-08:00 Physical layer is synchronous, Virtualbaudrate is 64000 bps Interface is DTE, Cable type is V11, Clock mode is TC Last 300 seconds input rate 1 bytes/sec 8 bits/sec 0 packets/sec Last 300 seconds output rate 0 bytes/sec 0 bits/sec 0 packets/sec Input: 14 packets, 460 bytes Broadcast: 0, Multicast: 0 Errors: 0, Runts: 0 Giants: 0, CRC: 0 Alignments: 0, Overruns: 0 Dribbles: 0, Aborts: 0 No Buffers: 0, Frame Error: 0 这里按任意键可以退出
这里提取出的关键信息
ip地址
disabled
链路协议
Link layer protocol is PPP
LCP,IPCP状态
LCP opened, IPCP 无
Interface is DTE, Cable type is V11, Clock mode is TC
该接口是数据终端设备端(DTE)
使用 V11 电缆进行物理连接
以 Transmit Clock(TC)模式工作。
链路协议 ppp
LCP状态 opened
IPCP状态 无
物理链路类型 V11
IP地址 disabled
#配置串口Serial 4/0/0串行链路采用ppp [RT-BJ]interface Serial 4/0/0 [RT-BJ-Serial4/0/0]link-protocol ppp #配置串口ip地址 [RT-BJ-Serial4/0/0]ip address 192.168.90.2 255.255.255.0 [RT-BJ-Serial4/0/0]qu #查看所有串口信息 [RT-BJ]display ip interface brief *down: administratively down ^down: standby (l): loopback (s): spoofing The number of interface that is UP in Physical is 2 The number of interface that is DOWN in Physical is 4 The number of interface that is UP in Protocol is 2 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 NULL0 unassigned up up(s) Serial4/0/0 192.168.90.2/24 up up Serial4/0/1 unassigned down down #查看串口状态 [RT-BJ]display interface Serial 4/0/0 Serial4/0/0 current state : UP Line protocol current state : UP Last line protocol up time : 2023-09-12 17:21:38 UTC-08:00 Description:HUAWEI, AR Series, Serial4/0/0 Interface Route Port,The Maximum Transmit Unit is 1500, Hold timer is 10(sec) Internet Address is 192.168.90.2/24 Link layer protocol is PPP LCP opened, IPCP stopped Last physical up time : 2023-09-12 17:21:36 UTC-08:00 Last physical down time : 2023-09-12 17:21:31 UTC-08:00 Current system time: 2023-09-12 17:33:06-08:00 Physical layer is synchronous, Virtualbaudrate is 64000 bps Interface is DTE, Cable type is V11, Clock mode is TC Last 300 seconds input rate 7 bytes/sec 56 bits/sec 0 packets/sec Last 300 seconds output rate 2 bytes/sec 16 bits/sec 0 packets/sec Input: 152 packets, 4848 bytes Broadcast: 0, Multicast: 0 Errors: 0, Runts: 0 Giants: 0, CRC: 0 Alignments: 0, Overruns: 0 Dribbles: 0, Aborts: 0 No Buffers: 0, Frame Error: 0 ---- More ---- #显示串口当前配置信息 [RT-BJ]display current-configuration interface serial 4/0/0 [V200R003C00] # interface Serial4/0/0 link-protocol ppp ip address 192.168.90.2 255.255.255.0 # return [RT-BJ]
这里提取出的关键信息
ip地址
ip address 192.168.90.2 255.255.255.0
链路协议
link-protocol ppp
LCP,IPCP状态
LCP opened, IPCP stopped
Interface is DTE, Cable type is V11, Clock mode is TC
该接口是数据终端设备端(DTE)
使用 V11 电缆进行物理连接
以 Transmit Clock(TC)模式工作。
链路协议 ppp
LCP状态 opened
IPCP状态 stoped
物理链路类型 V11
IP地址 192.168.90.2 255.255.255.0
配置RT-SZ,和RT-BJ相似,这里不做说明
<Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]sysname RT-SZ [RT-SZ]display interface Serial 4/0/0 Serial4/0/0 current state : UP Line protocol current state : UP Last line protocol up time : 2023-09-12 17:21:38 UTC-08:00 Description:HUAWEI, AR Series, Serial4/0/0 Interface Route Port,The Maximum Transmit Unit is 1500, Hold timer is 10(sec) Internet protocol processing : disabled Link layer protocol is PPP LCP opened Last physical up time : 2023-09-12 17:21:35 UTC-08:00 Last physical down time : 2023-09-12 17:21:33 UTC-08:00 Current system time: 2023-09-12 17:37:13-08:00 Physical layer is synchronous, Virtualbaudrate is 64000 bps Interface is DTE, Cable type is V11, Clock mode is TC Last 300 seconds input rate 7 bytes/sec 56 bits/sec 0 packets/sec Last 300 seconds output rate 2 bytes/sec 16 bits/sec 0 packets/sec Input: 214 packets, 6912 bytes Broadcast: 0, Multicast: 0 Errors: 0, Runts: 0 Giants: 0, CRC: 0 Alignments: 0, Overruns: 0 Dribbles: 0, Aborts: 0 No Buffers: 0, Frame Error: 0 [RT-SZ]interface [RT-SZ]interface Serial 4/0/0 [RT-SZ-Serial4/0/0]link-protocol ppp [RT-SZ-Serial4/0/0]ip address 192.168.90.3 255.255.255.0 [RT-SZ-Serial4/0/0] Sep 12 2023 17:38:05-08:00 RT-SZ %%01IFNET/4/LINK_STATE(l)[0]:The line protocol PPP IPCP on the interface Serial4/0/0 has entered the UP state. [RT-SZ-Serial4/0/0]qu [RT-SZ]display ip interface brief *down: administratively down ^down: standby (l): loopback (s): spoofing The number of interface that is UP in Physical is 2 The number of interface that is DOWN in Physical is 4 The number of interface that is UP in Protocol is 2 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 NULL0 unassigned up up(s) Serial4/0/0 192.168.90.3/24 up up Serial4/0/1 unassigned down down [RT-SZ]display interface Serial 4/0/0 Serial4/0/0 current state : UP Line protocol current state : UP Last line protocol up time : 2023-09-12 17:38:05 UTC-08:00 Description:HUAWEI, AR Series, Serial4/0/0 Interface Route Port,The Maximum Transmit Unit is 1500, Hold timer is 10(sec) Internet Address is 192.168.90.3/24 Link layer protocol is PPP LCP opened, IPCP opened Last physical up time : 2023-09-12 17:21:35 UTC-08:00 Last physical down time : 2023-09-12 17:21:33 UTC-08:00 Current system time: 2023-09-12 17:38:45-08:00 Physical layer is synchronous, Virtualbaudrate is 64000 bps Interface is DTE, Cable type is V11, Clock mode is TC Last 300 seconds input rate 7 bytes/sec 56 bits/sec 0 packets/sec Last 300 seconds output rate 2 bytes/sec 16 bits/sec 0 packets/sec Input: 235 packets, 7590 bytes Broadcast: 0, Multicast: 0 Errors: 0, Runts: 0 Giants: 0, CRC: 0 Alignments: 0, Overruns: 0 Dribbles: 0, Aborts: 0 No Buffers: 0, Frame Error: 0 [RT-SZ]display current-configuration interface serial 4/0/0 [V200R003C00] # interface Serial4/0/0 link-protocol ppp ip address 192.168.90.3 255.255.255.0 # return #到这里IPCP状态为 :opened
关闭串口
[RT-SZ]interface Serial 4/0/0 [RT-SZ-Serial4/0/0]shutdown Sep 12 2023 17:42:32-08:00 RT-SZ %%01PPP/4/PHYSICALDOWN(l)[1]:On the interface S erial4/0/0, PPP link was closed because the status of the physical layer was Dow n. [RT-SZ-Serial4/0/0] [RT-SZ-Serial4/0/0] Sep 12 2023 17:42:32-08:00 RT-SZ %%01IFNET/4/LINK_STATE(l)[2]:The line protocol PPP on the interface Serial4/0/0 has entered the DOWN state. [RT-SZ-Serial4/0/0] Sep 12 2023 17:42:32-08:00 RT-SZ %%01IFNET/4/LINK_STATE(l)[3]:The line protocol PPP IPCP on the interface Serial4/0/0 has entered the DOWN state. [RT-SZ-Serial4/0/0] Sep 12 2023 17:42:32-08:00 RT-SZ %%01IFPDT/4/IF_STATE(l)[4]:Interface Serial4/0/ 0 has turned into DOWN state. [RT-SZ-Serial4/0/0]display interface Serial 4/0/0 Serial4/0/0 current state : Administratively DOWN Line protocol current state : DOWN Description:HUAWEI, AR Series, Serial4/0/0 Interface Route Port,The Maximum Transmit Unit is 1500, Hold timer is 10(sec) Internet Address is 192.168.90.3/24 Link layer protocol is PPP LCP initial Last physical up time : 2023-09-12 17:21:35 UTC-08:00 Last physical down time : 2023-09-12 17:42:32 UTC-08:00 Current system time: 2023-09-12 17:42:44-08:00 Physical layer is synchronous, Virtualbaudrate is 64000 bps Interface is DTE, Cable type is V11, Clock mode is TC Last 300 seconds input rate 6 bytes/sec 48 bits/sec 0 packets/sec Last 300 seconds output rate 2 bytes/sec 16 bits/sec 0 packets/sec Input: 282 packets, 9090 bytes Broadcast: 0, Multicast: 0 Errors: 0, Runts: 0 Giants: 0, CRC: 0 Alignments: 0, Overruns: 0 Dribbles: 0, Aborts: 0 No Buffers: 0, Frame Error: 0 ---- More ----
重新开启串口
[RT-SZ-Serial4/0/0]undo shutdown [RT-SZ-Serial4/0/0]disp Sep 12 2023 19:07:42-08:00 RT-SZ %%01IFPDT/4/IF_STATE(l)[5]:Interface Serial4/0/ 0 has turned into UP state. [RT-SZ-Serial4/0/0]display Sep 12 2023 19:07:45-08:00 RT-SZ %%01IFNET/4/LINK_STATE(l)[6]:The line protocol PPP on the interface Serial4/0/0 has entered the UP state. [RT-SZ-Serial4/0/0]display Sep 12 2023 19:07:45-08:00 RT-SZ %%01IFNET/4/LINK_STATE(l)[7]:The line protocol PPP IPCP on the interface Serial4/0/0 has entered the UP state. [RT-SZ-Serial4/0/0]display interface Serial 4/0/0 Serial4/0/0 current state : UP Line protocol current state : UP Last line protocol up time : 2023-09-12 19:07:45 UTC-08:00 Description:HUAWEI, AR Series, Serial4/0/0 Interface Route Port,The Maximum Transmit Unit is 1500, Hold timer is 10(sec) Internet Address is 192.168.90.3/24 Link layer protocol is PPP LCP opened, IPCP opened Last physical up time : 2023-09-12 19:07:42 UTC-08:00 Last physical down time : 2023-09-12 19:06:39 UTC-08:00 Current system time: 2023-09-12 19:07:59-08:00 Physical layer is synchronous, Virtualbaudrate is 64000 bps Interface is DTE, Cable type is V11, Clock mode is TC Last 300 seconds input rate 6 bytes/sec 48 bits/sec 0 packets/sec Last 300 seconds output rate 2 bytes/sec 16 bits/sec 0 packets/sec Input: 108 packets, 3502 bytes Broadcast: 0, Multicast: 0 Errors: 0, Runts: 0 Giants: 0, CRC: 0 Alignments: 0, Overruns: 0 Dribbles: 0, Aborts: 0 No Buffers: 0, Frame Error: 0
LCP, IPCP的状态
1.没有与对端路由器进行连接时,LCP状态是opened,IPCP状态是无
2.与对端连接,但对端没有配置ppp链路协议时,LCP状态是opened,IPCP状态为stoped
3.当对端配置了ppp链路协议,LCP状态是opened,IPCP的状态是opened
4.如果关闭串口,则LCP状态为:LCP initial
这里在ping对端路由器,则可以ping通
[RT-SZ-Serial4/0/0]ping 192.168.90.2 PING 192.168.90.2: 56 data bytes, press CTRL_C to break Reply from 192.168.90.2: bytes=56 Sequence=1 ttl=255 time=10 ms Reply from 192.168.90.2: bytes=56 Sequence=2 ttl=255 time=20 ms Reply from 192.168.90.2: bytes=56 Sequence=3 ttl=255 time=20 ms Reply from 192.168.90.2: bytes=56 Sequence=4 ttl=255 time=20 ms Reply from 192.168.90.2: bytes=56 Sequence=5 ttl=255 time=20 ms --- 192.168.90.2 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 10/18/20 ms [RT-BJ]ping 192.168.90.3 PING 192.168.90.3: 56 data bytes, press CTRL_C to break Reply from 192.168.90.3: bytes=56 Sequence=1 ttl=255 time=80 ms Reply from 192.168.90.3: bytes=56 Sequence=2 ttl=255 time=40 ms Reply from 192.168.90.3: bytes=56 Sequence=3 ttl=255 time=30 ms Reply from 192.168.90.3: bytes=56 Sequence=4 ttl=255 time=40 ms Reply from 192.168.90.3: bytes=56 Sequence=5 ttl=255 time=30 ms --- 192.168.90.3 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 30/44/80 ms
2.pap鉴别配置
依然是之前的配置
<Huawei>sys Enter system view, return user view with Ctrl+Z. #配置串口Serial 4/0/0采用PAP鉴定 [Huawei]interface Serial 4/0/0 [Huawei-Serial4/0/0]ppp authentication-mode pap [Huawei-Serial4/0/0]qu [Huawei]sysname RT-BT #将RT-BJ配置为PAP验证方,aaa是对网络安全的一种管理方式 [RT-BT]AAA #显示aaa当前本地用户 [RT-BT-aaa]display local-user ---------------------------------------------------------------------------- User-name State AuthMask AdminLevel ---------------------------------------------------------------------------- admin A H - ---------------------------------------------------------------------------- Total 1 user(s) #配置被验证方使用的用户名和密码 #用户名为office,密码为12345678,用户名和密码保存在本地 [RT-BT-aaa]local-user myoffice-pap password cipher 12345678 Info: Add a new user. [RT-BT-aaa]local-user myoffice-pap service-type ppp #显示aaa当前本地用户 [RT-BT-aaa]display local-user ---------------------------------------------------------------------------- User-name State AuthMask AdminLevel ---------------------------------------------------------------------------- admin A H - myoffice-pap A P - ---------------------------------------------------------------------------- Total 2 user(s) [RT-BT-aaa]qu #关闭串口Serial 4/0/0 ,再重新打开,使链路重新协商 [RT-BT]interface Serial 4/0/0 [RT-BT-Serial4/0/0]shutdown Sep 12 2023 22:10:06-08:00 RT-BT %%01PPP/4/PHYSICALDOWN(l)[0]:On the interface S erial4/0/0, PPP link was closed because the status of the physical layer was Dow n. [RT-BT-Serial4/0/0] [RT-BT-Serial4/0/0] Sep 12 2023 22:10:06-08:00 RT-BT %%01IFNET/4/LINK_STATE(l)[1]:The line protocol PPP on the interface Serial4/0/0 has entered the DOWN state. [RT-BT-Serial4/0/0] Sep 12 2023 22:10:06-08:00 RT-BT %%01IFPDT/4/IF_STATE(l)[2]:Interface Serial4/0/ 0 has turned into DOWN state. [RT-BT-Serial4/0/0]undo shutdown [RT-BT-Serial4/0/0]qu [RT-BT] Sep 12 2023 22:10:18-08:00 RT-BT %%01IFPDT/4/IF_STATE(l)[3]:Interface Serial4/0/ 0 has turned into UP state. [RT-BT]displa Sep 12 2023 22:10:21-08:00 RT-BT %%01PPP/4/PEERNOPAP(l)[4]:On the interface Seri al4/0/0, authentication failed and PPP link was closed because PAP was disabled on the peer. [RT-BT]displa Sep 12 2023 22:10:21-08:00 RT-BT %%01PPP/4/RESULTERR(l)[5]:On the interface Seri al4/0/0, LCP negotiation failed because the result cannot be accepted. #查看串口状态 [RT-BT]display interface Serial 4/0/0 Serial4/0/0 current state : UP Line protocol current state : DOWN Description:HUAWEI, AR Series, Serial4/0/0 Interface Route Port,The Maximum Transmit Unit is 1500, Hold timer is 10(sec) Internet protocol processing : disabled Link layer protocol is PPP LCP closed Last physical up time : 2023-09-12 22:10:18 UTC-08:00 Last physical down time : 2023-09-12 22:10:06 UTC-08:00 Current system time: 2023-09-12 22:10:33-08:00 Physical layer is synchronous, Virtualbaudrate is 64000 bps Interface is DTE, Cable type is V11, Clock mode is TC Last 300 seconds input rate 7 bytes/sec 56 bits/sec 0 packets/sec Last 300 seconds output rate 2 bytes/sec 16 bits/sec 0 packets/sec Input: 219 packets, 7104 bytes Broadcast: 0, Multicast: 0 Errors: 0, Runts: 0 Giants: 0, CRC: 0 Alignments: 0, Overruns: 0 Dribbles: 0, Aborts: 0 No Buffers: 0, Frame Error: 0 ---- More ----
此时RT-BJ 与 RT-SZ互ping不通
因为PAP 是一种用于身份验证的协议,它要求在建立连接时进行用户名和密码的验证。如果只有一个路由器配置了 PAP,而另一个路由器未配置或不支持 PAP 认证,那么当两个路由器之间尝试建立连接时,可能会遇到身份验证失败的问题,从而导致无法正常通信。
[RT-SZ]ping 192.168.90.2 PING 192.168.90.2: 56 data bytes, press CTRL_C to break Request time out Request time out Request time out Request time out Request time out --- 192.168.90.2 ping statistics --- 5 packet(s) transmitted 0 packet(s) received 100.00% packet loss [RT-BT]ping 192.168.90.3 PING 192.168.90.3: 56 data bytes, press CTRL_C to break Request time out Request time out Request time out Request time out Request time out --- 192.168.90.3 ping statistics --- 5 packet(s) transmitted 0 packet(s) received 100.00% packet loss
将RT-SZ配置为PAP被验证方
#配置PAP认证功能 #配置本端被对端验证时,本端发送的用户名和密码 #验证方和被验证方用户名密码需一致 [RT-SZ]interface Serial 4/0/0 [RT-SZ-Serial4/0/0]ppp pap local-user myoffice-pap password cipher 12345678 #关闭串口Serial 4/0/0 再重新打开,使链路重新协商 [RT-SZ-Serial4/0/0]shutdown /0 has turned into DOWN state. [RT-SZ-Serial4/0/0] [RT-SZ-Serial4/0/0]undo shutdown [RT-SZ-Serial4/0/0]qu [RT-SZ] [RT-SZ]display interface Serial 4/0/0 Serial4/0/0 current state : UP Line protocol current state : UP Last line protocol up time : 2023-09-12 23:58:27 UTC-08:00 Description:HUAWEI, AR Series, Serial4/0/0 Interface Route Port,The Maximum Transmit Unit is 1500, Hold timer is 10(sec) Internet Address is 192.168.90.3/24 Link layer protocol is PPP LCP opened, IPCP opened Last physical up time : 2023-09-12 23:58:25 UTC-08:00 Last physical down time : 2023-09-12 23:58:19 UTC-08:00 Current system time: 2023-09-13 00:01:22-08:00 Physical layer is synchronous, Virtualbaudrate is 64000 bps Interface is DTE, Cable type is V11, Clock mode is TC Last 300 seconds input rate 8 bytes/sec 64 bits/sec 0 packets/sec Last 300 seconds output rate 4 bytes/sec 32 bits/sec 0 packets/sec Input: 146 packets, 5944 bytes Broadcast: 0, Multicast: 0 Errors: 0, Runts: 0 Giants: 0, CRC: 0 Alignments: 0, Overruns: 0 Dribbles: 0, Aborts: 0 No Buffers: 0, Frame Error: 0 ---- More ----
将RT-SZ配置为PAP被验证方后,RT-BJ
[RT-BJ]display interface Serial 4/0/0 Serial4/0/0 current state : UP Line protocol current state : UP Last line protocol up time : 2023-09-12 23:58:27 UTC-08:00 Description:HUAWEI, AR Series, Serial4/0/0 Interface Route Port,The Maximum Transmit Unit is 1500, Hold timer is 10(sec) Internet Address is 192.168.90.2/24 Link layer protocol is PPP LCP opened, IPCP opened Last physical up time : 2023-09-12 23:58:21 UTC-08:00 Last physical down time : 2023-09-12 23:58:20 UTC-08:00 Current system time: 2023-09-13 00:04:12-08:00 Physical layer is synchronous, Virtualbaudrate is 64000 bps Interface is DTE, Cable type is V11, Clock mode is TC Last 300 seconds input rate 6 bytes/sec 48 bits/sec 0 packets/sec Last 300 seconds output rate 2 bytes/sec 16 bits/sec 0 packets/sec Input: 185 packets, 7146 bytes Broadcast: 0, Multicast: 0 Errors: 0, Runts: 0 Giants: 0, CRC: 0 Alignments: 0, Overruns: 0 Dribbles: 0, Aborts: 0 No Buffers: 0, Frame Error: 0 ---- More ----
现在互ping一下,则可以ping通了
[RT-SZ]ping 192.168.90.2 PING 192.168.90.2: 56 data bytes, press CTRL_C to break Reply from 192.168.90.2: bytes=56 Sequence=1 ttl=255 time=10 ms Reply from 192.168.90.2: bytes=56 Sequence=2 ttl=255 time=20 ms Reply from 192.168.90.2: bytes=56 Sequence=3 ttl=255 time=10 ms Reply from 192.168.90.2: bytes=56 Sequence=4 ttl=255 time=20 ms Reply from 192.168.90.2: bytes=56 Sequence=5 ttl=255 time=20 ms --- 192.168.90.2 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 10/16/20 ms [RT-BJ]ping 192.168.90.3 PING 192.168.90.3: 56 data bytes, press CTRL_C to break Reply from 192.168.90.3: bytes=56 Sequence=1 ttl=255 time=30 ms Reply from 192.168.90.3: bytes=56 Sequence=2 ttl=255 time=20 ms Reply from 192.168.90.3: bytes=56 Sequence=3 ttl=255 time=20 ms Reply from 192.168.90.3: bytes=56 Sequence=4 ttl=255 time=20 ms Reply from 192.168.90.3: bytes=56 Sequence=5 ttl=255 time=20 ms --- 192.168.90.3 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 20/22/30 ms
数据抓包
开启路由器RT-BJ串口Serial 4/0/0/的数据抓包,链路类型选择 “PPP”。为了抓取PAP数据包,需要先关闭(使用命令shutdown)路由器 的串口Serial 4/0/0,再重新打开(使用命令undo shutdown)该串口,使链路重新协商。可以抓到3个特殊的包
- LCP 配置请求(Configure Request):该数据包由 PPP 客户端发送,用于提出 PPP 配置请求,请求 PPP 服务器协商链路参数。
- LCP 配置回应(Configure Ack):该数据包由 PPP 服务器发送,用于确认接收到客户端的 LCP 配置请求,并回复自己的 PPP 配置信息。
- LCP 终止请求(Terminate Request):该数据包由 PPP 客户端发送,用于主动终止 PPP 会话。
3.CHAP鉴别配置
注:在完成ppp的基础上进行实验
将RT-BJ配置为CHAP验证方
[RT-BJ]interface Serial 4/0/0 [RT-BJ-Serial4/0/0]link-protocol ppp [RT-BJ-Serial4/0/0]ip add 192.168.90.2 255.255.255.0 [RT-BJ-Serial4/0/0]q [RT-BJ] #配置串口采用CHAP认证功能 [RT-BJ]in Serial 4/0/0 [RT-BJ-Serial4/0/0]ppp authentication-mode chap #配置本端用户名为rb-bj,密码为niceday [RT-BJ-Serial4/0/0]ppp chap user rt-bj [RT-BJ-Serial4/0/0]ppp chap password cipher niceday [RT-BJ-Serial4/0/0]q #将RT-BJ配置为验证方 [RT-BJ]aaa #显示aaa当前本地用户 [RT-BJ-aaa]display local-user ---------------------------------------------------------------------------- User-name State AuthMask AdminLevel ---------------------------------------------------------------------------- admin A H - ---------------------------------------------------------------------------- Total 1 user(s) #配置验证方使用的用户名和密码,用户名为myoffice-chap,密码为12345678 #用户名和密码储存在本地 [RT-BJ-aaa]local-user myoffice-chap password cipher 12345678 Info: Add a new user. [RT-BJ-aaa]local-user myoffice-chap service-type ppp #显示当前本地用户 [RT-BJ-aaa]display local-user ---------------------------------------------------------------------------- User-name State AuthMask AdminLevel ---------------------------------------------------------------------------- admin A H - myoffice-chap A P - ---------------------------------------------------------------------------- Total 2 user(s) [RT-BJ-aaa]qu #关闭串口,再重新打开,使链路重新协商 [RT-BJ]interface Serial 4/0/0 [RT-BJ-Serial4/0/0]shutdown Sep 13 2023 10:23:31-08:00 RT-BJ %%01PPP/4/PHYSICALDOWN(l)[0]:On the interface S erial4/0/0, PPP link was closed because the status of the physical layer was Dow n. [RT-BJ-Serial4/0/0] [RT-BJ-Serial4/0/0] Sep 13 2023 10:23:31-08:00 RT-BJ %%01IFNET/4/LINK_STATE(l)[1]:The line protocol PPP on the interface Serial4/0/0 has entered the DOWN state. [RT-BJ-Serial4/0/0] Sep 13 2023 10:23:31-08:00 RT-BJ %%01IFNET/4/LINK_STATE(l)[2]:The line protocol PPP IPCP on the interface Serial4/0/0 has entered the DOWN state. [RT-BJ-Serial4/0/0] Sep 13 2023 10:23:31-08:00 RT-BJ %%01IFPDT/4/IF_STATE(l)[3]:Interface Serial4/0/ 0 has turned into DOWN state. [RT-BJ-Serial4/0/0]undo shutdown [RT-BJ-Serial4/0/0]qu [RT-BJ] Sep 13 2023 10:23:39-08:00 RT-BJ %%01IFPDT/4/IF_STATE(l)[4]:Interface Serial4/0/ 0 has turned into UP state. [RT-BJ] Sep 13 2023 10:23:42-08:00 RT-BJ %%01PPP/4/PEERNOCHAP(l)[5]:On the interface Ser ial4/0/0, authentication failed and PPP link was closed because CHAP was disable d on the peer. [RT-BJ] Sep 13 2023 10:23:42-08:00 RT-BJ %%01PPP/4/RESULTERR(l)[6]:On the interface Seri al4/0/0, LCP negotiation failed because the result cannot be accepted. [RT-BJ-Serial4/0/0]display interface Serial 4/0/0 Serial4/0/0 current state : UP Line protocol current state : DOWN Description:HUAWEI, AR Series, Serial4/0/0 Interface Route Port,The Maximum Transmit Unit is 1500, Hold timer is 10(sec) Internet Address is 192.168.90.2/24 Link layer protocol is PPP LCP closed Last physical up time : 2023-09-13 10:23:39 UTC-08:00 Last physical down time : 2023-09-13 10:23:31 UTC-08:00 Current system time: 2023-09-13 10:26:24-08:00 Physical layer is synchronous, Virtualbaudrate is 64000 bps Interface is DTE, Cable type is V11, Clock mode is TC Last 300 seconds input rate 6 bytes/sec 48 bits/sec 0 packets/sec Last 300 seconds output rate 2 bytes/sec 16 bits/sec 0 packets/sec Input: 234 packets, 7564 bytes Broadcast: 0, Multicast: 0 Errors: 0, Runts: 0 Giants: 0, CRC: 0 Alignments: 0, Overruns: 0 Dribbles: 0, Aborts: 0 No Buffers: 0, Frame Error: 0 Sep 13 2023 10:26:42-08:00 RT-BJ %%01PPP/4/PEERNOCHAP(l)[17]:On the interface Se rial4/0/0, authentication failed and PPP link was closed because CHAP was disabl ed on the peer. Sep 13 2023 10:26:42-08:00 RT-BJ %%01PPP/4/RESULTERR(l)[18]:On the interface Ser ial4/0/0, LCP negotiation failed because the result cannot be accepted.
在使用 CHAP(Challenge-Handshake Authentication Protocol)进行身份验证时,要实现双向认证,即客户端和服务器之间都需要相互配置 CHAP。所以现在两端是互ping不通的
[RT-BJ-Serial4/0/0]ping 192.168.90.3 PING 192.168.90.3: 56 data bytes, press CTRL_C to break Request time out Request time out Sep 13 2023 10:27:42-08:00 RT-BJ %%01PPP/4/PEERNOCHAP(l)[21]:On the interface Se rial4/0/0, authentication failed and PPP link was closed because CHAP was disabl ed on the peer. [RT-BJ-Serial4/0/0] Sep 13 2023 10:27:42-08:00 RT-BJ %%01PPP/4/RESULTERR(l)[22]:On the interface Ser ial4/0/0, LCP negotiation failed because the result cannot be accepted. [RT-BJ-Serial4/0/0] Request time out Request time out Request time out <RT-SZ>ping 192.168.90.2 PING 192.168.90.2: 56 data bytes, press CTRL_C to break Request time out Request time out Request time out Request time out Request time out --- 192.168.90.2 ping statistics --- 5 packet(s) transmitted 0 packet(s) received 100.00% packet loss
现在将RT-SZ也配置为CHAP被验证方
[RT-SZ]interface Serial 4/0/0 #配置本端被对端验证时,本端发送的用户名和密码、 #用户名和密码需与验证方一致 [RT-SZ-Serial4/0/0]ppp chap user myoffice-chap [RT-SZ-Serial4/0/0]ppp chap password cipher 12345678 [RT-SZ-Serial4/0/0]shutdown Sep 13 2023 10:34:21-08:00 RT-SZ %%01PPP/4/PHYSICALDOWN(l)[12]:On the interface Serial4/0/0, PPP link was closed because the status of the physical layer was Do wn. [RT-SZ-Serial4/0/0] Sep 13 2023 10:34:21-08:00 RT-SZ %%01IFPDT/4/IF_STATE(l)[15]:Interface Serial4/0 /0 has turned into DOWN state. [RT-SZ-Serial4/0/0]display interface Serial 4/0/0 Serial4/0/0 current state : Administratively DOWN Line protocol current state : DOWN Description:HUAWEI, AR Series, Serial4/0/0 Interface Route Port,The Maximum Transmit Unit is 1500, Hold timer is 10(sec) Internet Address is 192.168.90.3/24 Link layer protocol is PPP LCP initial Last physical up time : 2023-09-13 10:23:38 UTC-08:00 Last physical down time : 2023-09-13 10:34:21 UTC-08:00 Current system time: 2023-09-13 10:34:43-08:00 Physical layer is synchronous, Virtualbaudrate is 64000 bps Interface is DTE, Cable type is V11, Clock mode is TC Last 300 seconds input rate 5 bytes/sec 40 bits/sec 0 packets/sec Last 300 seconds output rate 2 bytes/sec 16 bits/sec 0 packets/sec Input: 294 packets, 9875 bytes Broadcast: 0, Multicast: 0 Errors: 0, Runts: 0 Giants: 0, CRC: 0 Alignments: 0, Overruns: 0 Dribbles: 0, Aborts: 0 No Buffers: 0, Frame Error: 0
重新打开串口Serial 4/0/0 ,使链路重新协商
[RT-SZ-Serial4/0/0]undo shutdown [RT-SZ-Serial4/0/0]qu [RT-SZ] Sep 13 2023 10:38:21-08:00 RT-SZ %%01IFPDT/4/IF_STATE(l)[16]:Interface Serial4/0 /0 has turned into UP state. [RT-SZ] Sep 13 2023 10:38:23-08:00 RT-SZ %%01IFNET/4/LINK_STATE(l)[17]:The line protocol PPP on the interface Serial4/0/0 has entered the UP state. [RT-SZ] Sep 13 2023 10:38:23-08:00 RT-SZ %%01IFNET/4/LINK_STATE(l)[18]:The line protocol PPP IPCP on the interface Serial4/0/0 has entered the UP state. [RT-SZ]display interface Serial 4/0/0 Serial4/0/0 current state : UP Line protocol current state : UP Last line protocol up time : 2023-09-13 10:38:23 UTC-08:00 Description:HUAWEI, AR Series, Serial4/0/0 Interface Route Port,The Maximum Transmit Unit is 1500, Hold timer is 10(sec) Internet Address is 192.168.90.3/24 Link layer protocol is PPP LCP opened, IPCP opened Last physical up time : 2023-09-13 10:38:21 UTC-08:00 Last physical down time : 2023-09-13 10:34:21 UTC-08:00 Current system time: 2023-09-13 10:39:14-08:00 Physical layer is synchronous, Virtualbaudrate is 64000 bps Interface is DTE, Cable type is V11, Clock mode is TC Last 300 seconds input rate 2 bytes/sec 16 bits/sec 0 packets/sec Last 300 seconds output rate 1 bytes/sec 8 bits/sec 0 packets/sec Input: 311 packets, 10482 bytes Broadcast: 0, Multicast: 0 Errors: 0, Runts: 0 Giants: 0, CRC: 0 Alignments: 0, Overruns: 0 Dribbles: 0, Aborts: 0 No Buffers: 0, Frame Error: 0 ---- More ----
现在两端可以互ping
[RT-SZ]ping 192.168.90.2 PING 192.168.90.2: 56 data bytes, press CTRL_C to break Reply from 192.168.90.2: bytes=56 Sequence=1 ttl=255 time=100 ms Reply from 192.168.90.2: bytes=56 Sequence=2 ttl=255 time=20 ms Reply from 192.168.90.2: bytes=56 Sequence=3 ttl=255 time=20 ms Reply from 192.168.90.2: bytes=56 Sequence=4 ttl=255 time=20 ms Reply from 192.168.90.2: bytes=56 Sequence=5 ttl=255 time=20 ms --- 192.168.90.2 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 20/36/100 ms <RT-BJ>sys Enter system view, return user view with Ctrl+Z. [RT-BJ]ping 192.168.90.3 PING 192.168.90.3: 56 data bytes, press CTRL_C to break Reply from 192.168.90.3: bytes=56 Sequence=1 ttl=255 time=30 ms Reply from 192.168.90.3: bytes=56 Sequence=2 ttl=255 time=20 ms Reply from 192.168.90.3: bytes=56 Sequence=3 ttl=255 time=20 ms Reply from 192.168.90.3: bytes=56 Sequence=4 ttl=255 time=30 ms Reply from 192.168.90.3: bytes=56 Sequence=5 ttl=255 time=20 ms --- 192.168.90.3 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 20/24/30 ms
现在进行数据抓包
先关闭路由器的串口Serial 4/0/0,再重新打开 该串口,使链路重新协商
chap抓到的需要注意的包
- Challenge 报文:服务器向客户端发送 Challenge 报文,其中包含一个随机数作为挑战。客户端需要使用自己的密码和该挑战进行计算,生成响应报文。
- Response 报文:客户端收到 Challenge 报文后,使用自己的密码和挑战进行计算,生成 Response 报文。该报文包括了客户端的身份信息以及一个通过 HMAC(Hash-based Message Authentication Code)算法计算的消息摘要值。
- Success 报文:服务器接收到客户端发送的 Response 报文后,使用相同的算法和密码对挑战进行计算,并将结果与客户端发送的消息摘要进行比对。如果两者一致,服务器会发送 Success 报文给客户端,表示认证成功。
- Failure 报文:如果在认证过程中出现错误或认证失败,服务器会发送 Failure 报文,通知客户端认证失败。
多耐心等会儿
注:如果抓不到包可能的原因
- 未启用 CHAP:确保在链路重新协商之前已正确启用了 CHAP。双方必须都配置了 CHAP,并且在链路建立之前进行了正确的身份验证设置。
- 认证失败:如果链路重新协商后仍无法捕获到 CHAP 报文,可能是因为认证过程中出现了错误或认证失败。这可能是由于密码不正确、身份信息不匹配等原因导致的。需要确认配置信息是否正确,并检查认证失败的原因。
- 数据包丢失:有时,在网络中的某些节点或设备上,数据包可能会丢失或被屏蔽,从而导致无法捕获到特殊的 CHAP 报文。可能需要通过调试和排除法来确定是否存在数据包丢失的情况。
- 加密和隧道技术:如果 CHAP 通信是通过加密的隧道或虚拟专用网络(VPN)进行的,Wireshark 在抓取数据包时可能无法读取加密的内容。在这种情况下,Wireshark 可能无法直接解密和显示 CHAP 报文。
4.IP地址的协商
ip address ppp-negotiate
1.PPP 协商地址:在 PPP 连接建立过程中,双方之间的 PPP 协议会协商分配 IP 地址。如果启用了 "ip address ppp-negotiate" 命令,在 PPP 连接建立时,设备将发送请求来获取可用的 IP 地址。
2.动态 IP 地址分配:一旦 PPP 连接成功并且对方设备同意提供 IP 地址,本地设备将被分配一个动态 IP 地址。这个地址通常由对端设备或服务器分配,并且每次建立 PPP 连接时都可能有所不同。
在完成路由器PPP,CHAP的配置基础上
(1)配置路由器RT-BJ
<RT-BJ>sys Enter system view, return user view with Ctrl+Z. #创建全局地址池,用于为被验证方分配地址 [RT-BJ]ip pool 1 #配置全局地址池下可分配的网段地址 Info: It's successful to create an IP address pool. [RT-BJ-ip-pool-1]network 192.168.90.0 mask 255.255.255.0 [RT-BJ-ip-pool-1]qu #配置串口Serial 4/0/0,为被验证方从指定地址池分配ip地址 [RT-BJ]interface Serial 4/0/0 [RT-BJ-Serial4/0/0]remote add pool 1 #也可以为被验证方分配ip地址 [RT-BJ-Serial4/0/0]remote add 192.168.90.8 #关闭串口再重新打开,使得链路重新协商 [RT-BJ-Serial4/0/0]shutdown Sep 13 2023 10:52:36-08:00 RT-BJ %%01PPP/4/PHYSICALDOWN(l)[0]:On the interface S erial4/0/0, PPP link was closed because the status of the physical layer was Dow n. [RT-BJ-Serial4/0/0] Sep 13 2023 10:52:36-08:00 RT-BJ %%01IFNET/4/LINK_STATE(l)[1]:The line protocol PPP on the interface Serial4/0/0 has entered the DOWN state. [RT-BJ-Serial4/0/0] Sep 13 2023 10:52:36-08:00 RT-BJ %%01IFNET/4/LINK_STATE(l)[2]:The line protocol PPP IPCP on the interface Serial4/0/0 has entered the DOWN state. [RT-BJ-Serial4/0/0] Sep 13 2023 10:52:36-08:00 RT-BJ %%01IFPDT/4/IF_STATE(l)[3]:Interface Serial4/0/ 0 has turned into DOWN state. [RT-BJ-Serial4/0/0]undo shutdown [RT-BJ-Serial4/0/0] Sep 13 2023 10:52:45-08:00 RT-BJ %%01IFPDT/4/IF_STATE(l)[4]:Interface Serial4/0/ 0 has turned into UP state. [RT-BJ-Serial4/0/0]qu [RT-BJ] Sep 13 2023 10:52:47-08:00 RT-BJ %%01IFNET/4/LINK_STATE(l)[5]:The line protocol PPP on the interface Serial4/0/0 has entered the UP state. [RT-BJ] Sep 13 2023 10:52:47-08:00 RT-BJ %%01IFNET/4/LINK_STATE(l)[6]:The line protocol PPP IPCP on the interface Serial4/0/0 has entered the UP state. #查看串口状态 [RT-BJ]display interface Serial 4/0/0 Serial4/0/0 current state : UP Line protocol current state : UP Last line protocol up time : 2023-09-13 10:52:47 UTC-08:00 Description:HUAWEI, AR Series, Serial4/0/0 Interface Route Port,The Maximum Transmit Unit is 1500, Hold timer is 10(sec) Internet Address is 192.168.90.2/24 Link layer protocol is PPP LCP opened, IPCP opened Last physical up time : 2023-09-13 10:52:45 UTC-08:00 Last physical down time : 2023-09-13 10:52:36 UTC-08:00 Current system time: 2023-09-13 10:53:02-08:00 Physical layer is synchronous, Virtualbaudrate is 64000 bps Interface is DTE, Cable type is V11, Clock mode is TC Last 300 seconds input rate 6 bytes/sec 48 bits/sec 0 packets/sec Last 300 seconds output rate 2 bytes/sec 16 bits/sec 0 packets/sec Input: 508 packets, 17441 bytes Broadcast: 0, Multicast: 0 Errors: 0, Runts: 0 Giants: 0, CRC: 0 Alignments: 0, Overruns: 0 Dribbles: 0, Aborts: 0 No Buffers: 0, Frame Error: 0 [RT-BJ] Please check whether system data has been changed, and save data in time Configuration console time out, please press any key to log on
(2)配置路由器RT-SZ
<RT-SZ>sys Enter system view, return user view with Ctrl+Z. #配置串口Serial 4/0/0通过地址协商从验证方分配ip地址 [RT-SZ]interface Serial 4/0/0 [RT-SZ-Serial4/0/0]ip add ppp-negotiate Sep 13 2023 11:07:22-08:00 RT-SZ %%01IFNET/4/LINK_STATE(l)[0]:The line protocol PPP IPCP on the interface Serial4/0/0 has entered the DOWN state. [RT-SZ-Serial4/0/0]qu [RT-SZ]display Sep 13 2023 11:07:28-08:00 RT-SZ %%01IFNET/4/LINK_STATE(l)[1]:The line protocol PPP IPCP on the interface Serial4/0/0 has entered the UP state. [RT-SZ]display interface Serial 4/0/0 Serial4/0/0 current state : UP Line protocol current state : UP Last line protocol up time : 2023-09-13 11:07:28 UTC-08:00 Description:HUAWEI, AR Series, Serial4/0/0 Interface Route Port,The Maximum Transmit Unit is 1500, Hold timer is 10(sec) Internet Address is negotiated, 192.168.90.8/32 Link layer protocol is PPP LCP opened, IPCP opened Last physical up time : 2023-09-13 10:52:44 UTC-08:00 Last physical down time : 2023-09-13 10:52:42 UTC-08:00 Current system time: 2023-09-13 11:07:36-08:00 Physical layer is synchronous, Virtualbaudrate is 64000 bps Interface is DTE, Cable type is V11, Clock mode is TC Last 300 seconds input rate 6 bytes/sec 48 bits/sec 0 packets/sec Last 300 seconds output rate 2 bytes/sec 16 bits/sec 0 packets/sec Input: 669 packets, 22804 bytes Broadcast: 0, Multicast: 0 Errors: 0, Runts: 0 Giants: 0, CRC: 0 Alignments: 0, Overruns: 0 Dribbles: 0, Aborts: 0 No Buffers: 0, Frame Error: 0 ---- More ---- [RT-SZ]interface serial 4/0/0 #关闭串口再重新打开,使链路重新协商 [RT-SZ-Serial4/0/0]shutdown Sep 13 2023 11:10:08-08:00 RT-SZ %%01PPP/4/PHYSICALDOWN(l)[2]:On the interface S erial4/0/0, PPP link was closed because the status of the physical layer was Dow n. [RT-SZ-Serial4/0/0] [RT-SZ-Serial4/0/0] Sep 13 2023 11:10:08-08:00 RT-SZ %%01IFNET/4/LINK_STATE(l)[3]:The line protocol PPP on the interface Serial4/0/0 has entered the DOWN state. [RT-SZ-Serial4/0/0] Sep 13 2023 11:10:08-08:00 RT-SZ %%01IFNET/4/LINK_STATE(l)[4]:The line protocol PPP IPCP on the interface Serial4/0/0 has entered the DOWN state. [RT-SZ-Serial4/0/0] Sep 13 2023 11:10:08-08:00 RT-SZ %%01IFPDT/4/IF_STATE(l)[5]:Interface Serial4/0/ 0 has turned into DOWN state. [RT-SZ-Serial4/0/0]undo shutdown [RT-SZ-Serial4/0/0] Sep 13 2023 11:10:13-08:00 RT-SZ %%01IFPDT/4/IF_STATE(l)[6]:Interface Serial4/0/ 0 has turned into UP state. [RT-SZ-Serial4/0/0] Sep 13 2023 11:10:13-08:00 RT-SZ %%01IFNET/4/LINK_STATE(l)[7]:The line protocol PPP on the interface Serial4/0/0 has entered the UP state. [RT-SZ-Serial4/0/0] Sep 13 2023 11:10:13-08:00 RT-SZ %%01IFNET/4/LINK_STATE(l)[8]:The line protocol PPP IPCP on the interface Serial4/0/0 has entered the UP state. [RT-SZ-Serial4/0/0]qu
(3)两端互ping
[RT-SZ]ping 192.168.90.2 PING 192.168.90.2: 56 data bytes, press CTRL_C to break Reply from 192.168.90.2: bytes=56 Sequence=1 ttl=255 time=20 ms Reply from 192.168.90.2: bytes=56 Sequence=2 ttl=255 time=20 ms Reply from 192.168.90.2: bytes=56 Sequence=3 ttl=255 time=20 ms Reply from 192.168.90.2: bytes=56 Sequence=4 ttl=255 time=30 ms Reply from 192.168.90.2: bytes=56 Sequence=5 ttl=255 time=30 ms --- 192.168.90.2 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 20/24/30 ms [RT-BJ]ping 192.168.90.8 PING 192.168.90.8: 56 data bytes, press CTRL_C to break Reply from 192.168.90.8: bytes=56 Sequence=1 ttl=255 time=40 ms Reply from 192.168.90.8: bytes=56 Sequence=2 ttl=255 time=30 ms Reply from 192.168.90.8: bytes=56 Sequence=3 ttl=255 time=20 ms Reply from 192.168.90.8: bytes=56 Sequence=4 ttl=255 time=20 ms Reply from 192.168.90.8: bytes=56 Sequence=5 ttl=255 time=20 ms --- 192.168.90.8 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 20/26/40 ms
(4)数据抓包
在PPP建立连接后,通过LCP(Link Control Protocol)完成链路的建立和配置。随后,双方会使用NCP(网络控制协议)来为对端分配IP地址,具体工作流程如下:
当PPP连接建立后,通信节点会通过发送IPCP报文来交换协商信息,并最终决定分配给本地设备的IP地址。
- 协商阶段:双方节点交互发送IPCP报文,包含各自的IP地址请求和IP配置选项。可以使用"Configure-Request"、"Configure-Ack"等消息类型进行交流。
- 协商参数:双方节点根据接收到的IPCP报文,协商并确定IP地址、网络掩码、默认网关等参数。
- IP地址分配:根据协商结果,对端会向本地设备分配一个有效的IP地址。