实验拓扑:
实验内容:
PC1;
PC2:
R1配置:
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 192.168.1.1 24
[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 100.1.1.1 24
[Huawei-GigabitEthernet0/0/1]q
[Huawei]sys
[Huawei]sysname R1
[R1]#静态缺省路由配置
[R1]ip route-static 0.0.0.0 0 100.1.1.2#配置tunnel隧道
[R1]int Tunnel 0/0/0
[R1-Tunnel0/0/0]ip add 192.168.3.1 24
[R1-Tunnel0/0/0]tunnel-protocol gre
[R1-Tunnel0/0/0]source 100.1.1.1
[R1-Tunnel0/0/0]destination 100.2.2.3
Mar 28 2024 21:07:20-08:00 R1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface Tunnel0/0/0 has entered the UP state.
R2配置:
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 100.1.1.2 24
[R2-GigabitEthernet0/0/0]q
[R2]int g0/0/1
[R2-GigabitEthernet0/0/1]ip address 100.2.2.2 24
R3配置:
[Huawei]sys
[Huawei]sysname R3
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 100.2.2.3 24
[R3-GigabitEthernet0/0/0]int g0/0/1
[R3-GigabitEthernet0/0/1]ip add 192.168.2.3 24#静态缺省路由配置
[R3]ip route-static 0.0.0.0 0 100.2.2.2#配置tunnel隧道
[R3]int Tunnel 0/0/0
[R3-Tunnel0/0/0]ip add 192.168.3.3 24
[R3-Tunnel0/0/0]tunnel-protocol gre
[R3-Tunnel0/0/0]source 100.2.2.3
[R3-Tunnel0/0/0]destination 100.1.1.1
Mar 28 2024 21:09:47-08:00 R3 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface Tunnel0/0/0 has entered the UP state.
公网通检测:
测试隧道两端是否相通:
ping -a 源ip 目标ip(可以选择用哪一个ip到哪一个ip通信)
让PC1和PC2互相通信
方法一:在隧道两边配置静态路由
[R1]ip route-static 192.168.2.0 24 192.168.3.3[R3]ip route-static 192.168.1.0 24 192.168.3.1
测试:
方法二:配置RIPV2
#删除静态路由
[R1]undo ip route-static 192.168.2.0 24 192.168.3.3
[R3]undo ip route-static 192.168.1.0 24 192.168.3.1#R1配置
[R1]rip 1
[R1-rip-1]v 2
[R1-rip-1]undo su
[R1-rip-1]undo summary
[R1-rip-1]net
[R1-rip-1]network 192.168.1.0
[R1-rip-1]ne
[R1-rip-1]network 192.168.3.0#R3配置
[R3]rip 1
[R3-rip-1]v 2
[R3-rip-1]undo summary
[R3-rip-1]network 192.168.3.0
[R3-rip-1]network 192.168.2.0
测试:
方法三:配置ospf
#删除rip配置
[R1]undo rip 1
Warning: The RIP process will be deleted. Continue?[Y/N]y
[R3]undo rip 1
Warning: The RIP process will be deleted. Continue?[Y/N]y#R1配置
[R1]ospf router-id 1.1.1.1
[R1-ospf-1]a 0
[R1-ospf-1-area-0.0.0.0]n
[R1-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]network 192.168.3.0 0.0.0.255#R3配置
[R3]ospf router-id 1.1.1.1
[R3-ospf-1]a 0
[R3-ospf-1-area-0.0.0.0]network 192.168.2.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]network 192.168.3.0 0.0.0.255