- 实验拓扑
- 实验要求
1、R5为ISP,只能进行IP地址配置,其所有地址均配为公有IP地址;
2、R1和R5间使用PPP的PAP认证,R5为主认证方;R2与R5之间使用ppp的CHAP认证,R5为主认证方;R3与R5之间使用HDLC封装;
3、R1、R2、R3构建一个MGRE环境,R1为中心站点,R1、R4间为点到点的GRE; 4、整个私有网络基本RIP全网可达; 5、所有Pc设置私有IP为源IP,可以访问R5环回。
实验思路:
先把IP地址配好这是最基础的一步。让公网能通,配完R1能ping通R2/R3/R4的公网IP,说明公网通了。
配链路层协议:R1-R5用PAP认证(R1输账号密码),R2-R5用CHAP认证(更安全),R3-R5改成HDLC封装。配完串口协议变成UP。
建隧道:R1(中心),R2和R3(分支)搭MGRE。
跑RIP路由:在所有隧道口和业务口开启RIP,让各设备互相学习私网路由。配完每台设备都能看到去往其他网段的路由。
做NAT让电脑上网:R1到R4各自配ACL 2000放行自己的私网段,配完PC能ping通5.5.5.5上网成功了。
最后测一遍:PC之间互ping通,PC能访问R5环回。
- 实验配置
- R1的配置
[Huawei]sys R1
[R1]interface GigabitEthernet0/0/0
[R1-GigabitEthernet0/0/0]ip address 192.168.1.254 255.255.255.0
[R1-GigabitEthernet0/0/0]interface Serial4/0/0
[R1-Serial4/0/0]link-protocol ppp
[R1-Serial4/0/0]ip address 15.1.1.1 255.255.255.0
[R1-Serial4/0/0]ppp pap local-user r1 password cipher 123456
[R1-Serial4/0/0]interface Tunnel0/0/0
[R1-Tunnel0/0/0]ip address 192.168.100.1 255.255.255.0
[R1-Tunnel0/0/0]tun
[R1-Tunnel0/0/0]tunnel-protocol gre
[R1-Tunnel0/0/0]tunnel-protocol gre p2mp
[R1-Tunnel0/0/0]source Serial4/0/0
[R1-Tunnel0/0/0]nhrp
[R1-Tunnel0/0/0]nhrp me
[R1-Tunnel0/0/0]nhrp ne
[R1-Tunnel0/0/0]nhrp network-id 100
[R1-Tunnel0/0/0]nhrp
[R1-Tunnel0/0/0]nhrp autjem
[R1-Tunnel0/0/0]nhrp authrn
[R1-Tunnel0/0/0]nhrp authen
[R1-Tunnel0/0/0]nhrp authentication cip
[R1-Tunnel0/0/0]nhrp authentication cipher 123456
[R1-Tunnel0/0/0]q
[R1]inter
[R1]interface Tun
[R1]interface Tunnel 0/0/1
[R1-Tunnel0/0/1]ip address 192.168.3.1 255.255.255.0
[R1-Tunnel0/0/1]tunn
[R1-Tunnel0/0/1]tunnel-protocol gre
[R1-Tunnel0/0/1]sour
[R1-Tunnel0/0/1]source 15.1.1.1
[R1-Tunnel0/0/1]des
[R1-Tunnel0/0/1]desti
[R1-Tunnel0/0/1]destination 45.1.1.1
[R1-Tunnel0/0/1]q
[R1]rip 1
[R1-rip-1]vers
[R1-rip-1]version 2
[R1-rip-1]network 192.168.1.0
[R1-rip-1]network 192.168.100.0
[R1-rip-1]network 192.168.3.0
[R1-rip-1]q
[R1]ip route-static 0.0.0.0 0 15.1.1.2
[R1]acl number 2000
[R1-acl-basic-2000]rule 5 permit source 192.168.1.0 0.0.0.255
[R1-acl-basic-2000]interface Serial4/0/0
[R1-Serial4/0/0]nat outbound 2000
[R1-Serial4/0/0]q
2、R2的配置
[Huawei]sys R2
[R2]inter
[R2]interface Gi
[R2]interface GigabitEthernet0/0/0
[R2-GigabitEthernet0/0/0]ip address 192.168.2.254 255.255.255.0
Aug 12 2026 21:48:04-08:00 R2 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[R2-GigabitEthernet0/0/0]interface Serial4/0/0
[R2-Serial4/0/0]link-s
[R2-Serial4/0/0]link-p
[R2-Serial4/0/0]link-protocol ppp
[R2-Serial4/0/0]ip address 25.1.1.1 255.255.255.0
[R2-Serial4/0/0]ppp authentication-mode chap
[R2-Serial4/0/0]ppp chap user r2
[R2-Serial4/0/0]ppp chap password cipher 123456
[R2-Serial4/0/0]q
[R2]inte
[R2]interface Tunn
[R2]interface Tunnel 0/0/0
[R2-Tunnel0/0/0]ip address 192.168.100.2 255.255.255.0
[R2-Tunnel0/0/0]tunnel-p
[R2-Tunnel0/0/0]tunnel-protocol
[R2]interface Tunnel0/0/0
[R2-Tunnel0/0/0]tunnel-protocol gre p2mp
[R2-Tunnel0/0/0]source Serial4/0/0
[R2-Tunnel0/0/0]nhrp
[R2-Tunnel0/0/0]nhrp net
[R2-Tunnel0/0/0]nhrp network-id 100
[R2-Tunnel0/0/0]nhrp authentication cipher 123456
[R2-Tunnel0/0/0]nhrp entry 192.168.100.1 15.1.1.1 register
[R2-Tunnel0/0/0]rip 1
[R2-rip-1]version 2
[R2-rip-1]network 192.168.2.0
[R2-rip-1]network 192.168.100.0
[R2-rip-1]ip route-static 0.0.0.0 0 25.1.1.2
[R2]ip route-static 0.0.0.0 0 25.1.1.2
Error: The route already exists.
[R2]acl number 2000
[R2-acl-basic-2000]rule 5 permit source 192.168.2.0 0.0.0.255
[R2-acl-basic-2000]interface Serial4/0/0
[R2-Serial4/0/0]nat outbound 2000
[R2-Serial4/0/0]q
[R2]q
3、R3的配置
[Huawei]sysname R3
[R3]interface GigabitEthernet0/0/0
[R3-GigabitEthernet0/0/0]ip address 192.168.3.254 255.255.255.0
Aug 12 2026 22:06:51-08:00 R3 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[R3-GigabitEthernet0/0/0]q
[R3]inter
[R3]interface S
[R3]interface Serial 4/0/0
[R3-Serial4/0/0]link-protocol hdlc
Warning: The encapsulation protocol of the link will be changed. Continue? [Y/N]
:Y
Aug 12 2026 22:07:21-08:00 R3 %%01IFNET/4/CHANGE_ENCAP(l)[1]:The user performed
the configuration that will change the encapsulation protocol of the link and th
en selected Y.
[R3-Serial4/0/0]ip address 35.1.1.1 255.255.255.0
[R3-Serial4/0/0]q
[R3]interface Tunnel0/0/0
[R3-Tunnel0/0/0]ip address 192.168.100.3 255.255.255.0
[R3-Tunnel0/0/0]tun
[R3-Tunnel0/0/0]tunnel-protocol ger
[R3-Tunnel0/0/0]tunnel-protocol gre
[R3-Tunnel0/0/0]tunnel-protocol gre p2mp
[R3-Tunnel0/0/0]source Serial4/0/0
Aug 12 2026 22:07:56-08:00 R3 %%01IFNET/4/LINK_STATE(l)[7]:The line protocol IP
on the interface Tunnel0/0/0 has entered the UP state.
[R3-Tunnel0/0/0]
[R3-Tunnel0/0/0]nhrp network-id 100
[R3-Tunnel0/0/0]nhrp authentication cipher 123456
[R3-Tunnel0/0/0]nhrp entry 192.168.100.1 15.1.1.1 register
[R3-Tunnel0/0/0]q
[R3]rip 1
[R3-rip-1]version 2
[R3-rip-1]network 192.168.3.0
[R3-rip-1]network 192.168.100.0
[R3-rip-1]q
[R3]ip rout
[R3]ip route-str
[R3]ip route-sta
[R3]ip route-static 0.0.0.0 0 35.1.1.2
[R3]acl number 2000
[R3-acl-basic-2000]rule 5 permit source 192.168.3.0 0.0.0.255
[R3-acl-basic-2000]interface Serial4/0/0
[R3-Serial4/0/0]nat outbound 2000
4、R4的配置
[R4]interface GigabitEthernet0/0/1
[R4-GigabitEthernet0/0/1]ip address 192.168.4.254 255.255.255.0
Aug 12 2026 22:22:37-08:00 R4 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[R4-GigabitEthernet0/0/1]interface GigabitEthernet0/0/0
[R4-GigabitEthernet0/0/0]ip address 45.1.1.1 255.255.255.0
Aug 12 2026 22:22:57-08:00 R4 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[R4-GigabitEthernet0/0/0]interface Tunnel0/0/0
[R4-Tunnel0/0/0]ip address 192.168.3.2 255.255.255.0
[R4-Tunnel0/0/0]tunn
[R4-Tunnel0/0/0]tunnel-protocol gre
[R4-Tunnel0/0/0]source
[R4-Tunnel0/0/0]source 45.1.1.1
[R4-Tunnel0/0/0]destination 15.1.1.1
[R4-Tunnel0/0/0]q
[R4]rip 1
[R4-rip-1]ver
[R4-rip-1]version
[R4-rip-1]version 2
[R4-rip-1]net
[R4-rip-1]network 192.168.4.0
[R4-rip-1]network 192.168.3.0
[R4-rip-1]q
[R4]ip route-static 0.0.0.0 0 45.1.1.2
[R4]
Aug 12 2026 22:24:27-08:00 R4 %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP
on the interface Tunnel0/0/0 has entered the UP state.
[R4]acl number 2000
[R4-acl-basic-2000]rule 5 per
[R4-acl-basic-2000]rule 5 permit sour
[R4-acl-basic-2000]rule 5 permit source 192.168.4.0 0.0.0.255
[R4-acl-basic-2000]q
[R4]interface GigabitEthernet0/0/0
[R4-GigabitEthernet0/0/0]nat outbound 2000
[R4-GigabitEthernet0/0/0]q
[R4]q
[R4]int g0/0/0
[R4-GigabitEthernet0/0/0]ip add 45.0.0.4 24
[R4-GigabitEthernet0/0/0]int l0
[R4-LoopBack0]ip add 192.168.4.4 24
5、R5的配置
Huawei]sysname R5
[R5]interface Loopback0
[R5-LoopBack0]ip address 5.5.5.5 255.255.255.0
[R5-LoopBack0]interface Serial4/0/0
[R5-Serial4/0/0]link-
[R5-Serial4/0/0]link-protocol hdlc
Warning: The encapsulation protocol of the link will be changed. Continue? [Y/N]
:Y
Aug 12 2026 22:28:52-08:00 R5 %%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.
[R5]interface Serial4/0/0
[R5-Serial4/0/0]ip address 35.1.1.2 255.255.255.0
[R5-Serial4/0/0]q
[R5]interface Serial4/0/1
[R5-Serial4/0/1]link-protocol ppp
[R5-Serial4/0/1]ip address 15.1.1.2 255.255.255.0
[R5-Serial4/0/1]
Aug 12 2026 22:38:57-08:00 R5 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol PPP
IPCP on the interface Serial4/0/1 has entered the UP state.
[R5-Serial4/0/1]ppp authentication-mode pap
[R5-Serial4/0/1]interface Serial3/0/1
[R5-Serial3/0/1]link-protocol ppp
[R5-Serial3/0/1]ip address 25.1.1.2 255.255.255.0
[R5-Serial3/0/1]
Aug 12 2026 22:39:35-08:00 R5 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol PPP
IPCP on the interface Serial3/0/1 has entered the UP state.
[R5-Serial3/0/1]ppp authentication-mode chap
[R5-Serial3/0/1]interface GigabitEthernet0/0/0
[R5-GigabitEthernet0/0/0]ip address 45.1.1.2 255.255.255.0
Aug 12 2026 22:39:47-08:00 R5 %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[R5-GigabitEthernet0/0/0]q
[R5]aaa
[R5-aaa]loce
[R5-aaa]loca
[R5-aaa]local-user r1 passwor
[R5-aaa]local-user r1 password cip
[R5-aaa]local-user r1 password cipher 123456
Info: Add a new user.
[R5-aaa]loce
[R5-aaa]loca
[R5-aaa]local-user r1 servi
[R5-aaa]local-user r1 service-type ppp
[R5-aaa]local-user r2 password cipher 123456
Info: Add a new user.
[R5-aaa]local-user r2 service-type ppp
[R5-aaa]q
[R5]q
配置各个PC:
- 测试:私网互通
- 测试:访问公网
3、NAT配置
4、MGRE注册
5、R1PAP认证
6、R2CHAP认证
7、接口状态
用了display ip interface brief命令发现所有配置接口Physical和Protocol均为UP