1、实验目的
掌握默认路由的适用场合和配置方法
2、实验拓扑
默认路由的配置
3、实验步骤
(1)配置网络连通性如下。
1)R1 的配置如下 :
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]undo info-center enable
[Huawei]sysname R1
[R1]interface g0/0/0
[R1-GigabitEthernet0/0/0]ip address 12.1.1.1 24
[R1-GigabitEthernet0/0/0]quit
2)R2 的配置如下 :
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]undo info-center enable
[Huawei]sysname R2
[R2]interface g0/0/1
[R2-GigabitEthernet0/0/1]ip address 12.1.1.2 24
[R2-GigabitEthernet0/0/1]quit
[R2]interface g0/0/0
[R2-GigabitEthernet0/0/0]ip address 23.1.1.2 24
[R2-GigabitEthernet0/0/0]quit
[R2]interface g0/0/2
[R2-GigabitEthernet0/0/2]ip address 24.1.1.2 24
[R2-GigabitEthernet0/0/2]quit
3)R3 的配置如下 :
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]undo info-center enable
[Huawei]sysname R3
[R3]interface g0/0/1
[R3-GigabitEthernet0/0/1]ip address 23.1.1.3 24
[R3-GigabitEthernet0/0/1]quit
4)R4 的配置如下 :
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]undo info-center enable
[Huawei]sysname R4
[R4]interface g0/0/1
[R4-GigabitEthernet0/0/1]ip address 24.1.1.4 24
[R4-GigabitEthernet0/0/1]quit
(2)配置静态路由。
1)R1 的配置如下 :
[R1]ip route-static 0.0.0.0 0.0.0.0 12.1.1.2 //配置默认路由到任何网段的下一跳为12.1.1.2
2)R3 的配置如下 :
[R3]ip route-static 12.1.1.0 255.255.255.0 23.1.1.2
3)R4 的配置如下 :
[R4]ip route-static 12.1.1.0 255.255.255.0 24.1.1.2
4. 实验调试
(1)查看 R1 的路由表,命令如下 :
[R1]display ip routing-table
Route Flags: R - relay, D - download to fifib
----------------------------------------------------
Routing Tables: Public
Destinations : 5 Routes : 5
Destination/Mask Proto Pre Cost Flags NextHop Interface
0.0.0.0/0 Static 60 0 RD 12.1.1.2 GigabitEthernet0/0/0
12.1.1.0/24 Direct 0 0 D 12.1.1.1 GigabitEthernet0/0/0
12.1.1.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/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
通过查看 R1 的路由表,可以看到一条默认路由,虽然简化了配置,但仍然需要测试一下网络连通性。
(2)R1 访问 R3,命令如下 :
[R1]ping 23.1.1.3
PING 23.1.1.3: 56 data bytes, press CTRL_C to break
Reply from 23.1.1.3: bytes=56 Sequence=1 ttl=254 time=100 ms
Reply from 23.1.1.3: bytes=56 Sequence=2 ttl=254 time=60 ms
Reply from 23.1.1.3: bytes=56 Sequence=3 ttl=254 time=50 ms
Reply from 23.1.1.3: bytes=56 Sequence=4 ttl=254 time=70 ms
Reply from 23.1.1.3: bytes=56 Sequence=5 ttl=254 time=80 ms
--- 23.1.1.3 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 50/72/100 ms
(3)R1 访问 R4,命令如下 :
[R1]ping 24.1.1.4
PING 24.1.1.4: 56 data bytes, press CTRL_C to break
Reply from 24.1.1.4: bytes=56 Sequence=1 ttl=254 time=60 ms
Reply from 24.1.1.4: bytes=56 Sequence=2 ttl=254 time=90 ms
Reply from 24.1.1.4: bytes=56 Sequence=3 ttl=254 time=60 ms
Reply from 24.1.1.4: bytes=56 Sequence=4 ttl=254 time=80 ms
Reply from 24.1.1.4: bytes=56 Sequence=5 ttl=254 time=80 ms
--- 24.1.1.4 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 60/74/90 ms
通过测试可以看到,默认路由虽然简化了配置,但是不影响访问,所以以后再遇到类似的拓扑可以考虑使用默认路由。