实验要求:![](https://img-blog.csdnimg.cn/6f97ccb28d5e48208e02dbc00a6b0f73.jpeg)
实验拓扑图![](https://img-blog.csdnimg.cn/5fb4ec44366e409ea1b413a3bdbcd1a6.png)
一:IP配置
以R1为例
[r1]int g0/0/1
[r1-GigabitEthernet0/0/1]ip add 192.168.1.1 24
Aug 2 2023 20:38:20-08:00 r1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[r1-GigabitEthernet0/0/1]int s4/0/0
[r1-Serial4/0/0]ip add 14.1.1.1 24
[r1-Serial4/0/0]
[r1]ip rou
[r1]ip route
[r1]ip route-static 0.0.0.0 0 14.1.1.2
二:HDLC封装
以R1为例
[r1]int
[r1]interface s4/0/0
[r1-Serial4/0/0]lin
[r1-Serial4/0/0]link-protocol hdlc
Warning: The encapsulation protocol of the link will be changed. Continue? [Y/N]:y
Aug 2 2023 20:48:34-08:00 r1 %%01IFNET/4/CHANGE_ENCAP(l)[0]:The user performed
the configuration that will change the encapsulation protocol of the link and th
en selected Y.
[r1-Serial4/0/0]
三:ppp封装,pap认证,R2为主证方
R2上配置:
[ISP]aaa
[ISP-aaa]local-user xiao password cipher 123456
[ISP-aaa]local-user xiao service-type ppp
[ISP]int s4/0/1
[ISP-Serial4/0/1]ppp authentication-mode pap
R3上配置:
[R3]int s4/0/0
[R3-Serial4/0/0]ppp pap local-user xiao password cipher 123456
四:ppp封装,chap认证,R2为主证方
R2上配置:
[ISP]aaa
[ISP-aaa]local-user gang password cipher 123456
[ISP-aaa]local-user gang service-type ppp
[ISP]int s3/0/0
[ISP-Serial3/0/0]ppp authentication-mode chap
R3上配置:
[R4]int s4/0/0
[R4-Serial4/0/0]ppp chap user gang
[R4-Serial4/0/0]ppp chap password cipher 123456
五:路由器之间构成mgre环境,仅r1ip地址固定。
(1)r1ip固定以及其他配置
[r1]int
[r1]interface tun
[r1]interface Tunnel 0/0/0
[r1-Tunnel0/0/0]ip add 192.168.4.1 24
[r1-Tunnel0/0/0]tun
[r1-Tunnel0/0/0]tunnel-protocol gre p2mp
[r1-Tunnel0/0/0]sou
[r1-Tunnel0/0/0]source 14.1.1.1
Aug 2 2023 21:15:58-08:00 r1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface Tunnel0/0/0 has entered the UP state.
[r1-Tunnel0/0/0]
[r1-Tunnel0/0/0]nh
[r1-Tunnel0/0/0]nhrp en
[r1-Tunnel0/0/0]nhrp entry mu
[r1-Tunnel0/0/0]nhrp entry multicast dyn
[r1-Tunnel0/0/0]nhrp entry multicast dynamic
[r1-Tunnel0/0/0]nh
[r1-Tunnel0/0/0]nhrp netw
[r1-Tunnel0/0/0]nhrp network-id 100
(2)r3和r4ip不固定(但是端口固定)图中的r2是充当isp
[r3]int
[r3]interface tun
[r3]interface Tunnel 0/0/0
[r3-Tunnel0/0/0]ip add 192.168.4.2 24
[r3-Tunnel0/0/0]tun
[r3-Tunnel0/0/0]tunnel-protocol gre p2mp
[r3-Tunnel0/0/0]sou
[r3-Tunnel0/0/0]source s
[r3-Tunnel0/0/0]source Serial 4/0/0
Aug 2 2023 21:19:12-08:00 r3 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface Tunnel0/0/0 has entered the UP state.
[r3-Tunnel0/0/0]
[r3-Tunnel0/0/0]nh
[r3-Tunnel0/0/0]nhrp en
[r3-Tunnel0/0/0]nhrp entry 192.168.4.1 14.1.1.1 re
[r3-Tunnel0/0/0]nhrp entry 192.168.4.1 14.1.1.1 register
[r3-Tunnel0/0/0]nh
[r3-Tunnel0/0/0]nhrp netw
[r3-Tunnel0/0/0]nhrp network-id 100
[r3-Tunnel0/0/0]q
[r4]int
[r4]interface tun
[r4]interface Tunnel 0/0/0
[r4-Tunnel0/0/0]ip add 192.168.4.3 24
[r4-Tunnel0/0/0]tun
[r4-Tunnel0/0/0]tunnel-protocol gre p2mp
[r4-Tunnel0/0/0]sourc
[r4-Tunnel0/0/0]source s
[r4-Tunnel0/0/0]source Serial 4/0/0
Aug 2 2023 21:21:59-08:00 r4 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface Tunnel0/0/0 has entered the UP state.
[r4-Tunnel0/0/0]
[r4-Tunnel0/0/0]nh
[r4-Tunnel0/0/0]nhrp en
[r4-Tunnel0/0/0]nhrp entry 192.168.4.1 14.1.1.1 re
[r4-Tunnel0/0/0]nhrp entry 192.168.4.1 14.1.1.1 register
[r4-Tunnel0/0/0]nhrp net
[r4-Tunnel0/0/0]nhrp network-id 100
六 内网使用rip获取路由,所有pc可以互相访问,并且可访问r2的环回。
[R1]rip
[R1-rip-1]version 2
[R1-rip-1]network 192.168.1.0
[R1-rip-1]network 192.168.4.0
[R3]rip
[R3-rip-1]version 2
[R3-rip-1]network 192.168.4.0
[R3-rip-1]network 192.168.2.0
[R4]rip
[R4-rip-1]version 2
[R4-rip-1]network 192.168.4.0
[R4-rip-1]network 192.168.3.0
测试![](https://img-blog.csdnimg.cn/6e36479443e34eed9f5ffed804fe708d.png)