实验
实验要求:
1.配置浮动路由,实现PC1和PC2互通
2.断掉R1和R2之间的其中一条链路,观察路由表的变化,PC1和PC2依然可通信。
配置步骤:
一 配置PC1和PC2
①配置PC1的IP为192.168.10.1,子网掩码为255.255.255.0,网关为192.168.10.254
②配置PC1的IP为192.168.20.1,子网掩码为255.255.255.0,网关为192.168.20.254
二 配置路由器R1
①进入系统视图
②改路由器名称为R1
③接口IP设置
接口g0/0/0 ip address 192.168.10.254 24
接口g0/0/1 ip address 10.0.0.1 24
接口g0/0/2 ip address 13.0.0.1 24
④设置静态路由
ip route-static 192.168.20.0 24 10.0.0.2
ip route-static 192.168.20.0 24 13.0.0.2 preference 70
⑤保存设置
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R1
[R1]interface g0/0/0
[R1-GigabitEthernet0/0/0]ip address 192.168.10.254 24
Apr 5 2021 19:34:49-08:00 R1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[R1-GigabitEthernet0/0/0]interface g0/0/1
[R1-GigabitEthernet0/0/1]ip address 10.0.0.1 24
Apr 5 2021 19:38:18-08:00 R1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[R1-GigabitEthernet0/0/1]interface g0/0/2
[R1-GigabitEthernet0/0/2]ip address 13.0.0.1 24
Info: A similar IP subnet already exists. Please verify the current IP subnet de
sign.
Apr 5 2021 19:40:10-08:00 R1 %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP
on the interface GigabitEthernet0/0/2 has entered the UP state.
[R1-GigabitEthernet0/0/2]quit
[R1]ip route-static 192.168.20.0 24 10.0.0.2
[R1]ip route-static 192.168.20.0 24 13.0.0.2 preference 70
[R1]quit
<R1>save
The current configuration will be written to the device.
Are you sure to continue? (y/n)[n]:y
It will take several minutes to save configuration file, please wait.......
Configuration file had been saved successfully
Note: The configuration file will take effect after being activated
<R1>
三 配置路由器R2
①进入系统视图
②改路由器名称为R2
③接口IP设置
接口g0/0/0 ip address 10.0.0.2 24
接口g0/0/1 ip address 192.168.20.254 24
接口g0/0/2 ip address 23.0.0.1 24
④设置静态路由
ip route-static 192.168.10.0 24 10.0.0.1
ip route-static 192.168.10.0 24 23.0.0.2 preference 70
⑤保存设置
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R2
[R2]interface g0/0/0
[R2-GigabitEthernet0/0/0]ip address 10.0.0.2 24
Apr 5 2021 20:08:57-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 g0/0/1
[R2-GigabitEthernet0/0/1]ip address 192.168.20.254 24
Apr 5 2021 20:09:36-08:00 R2 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[R2-GigabitEthernet0/0/1]interface g0/0/2
[R2-GigabitEthernet0/0/2]ip address 23.0.0.1 24
[R2-GigabitEthernet0/0/2]
Apr 5 2021 20:10:55-08:00 R2 %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP
on the interface GigabitEthernet0/0/2 has entered the UP state.
[R2-GigabitEthernet0/0/2]quit
[R2]ip route-static 192.168.10.0 24 10.0.0.1
[R2]ip route-static 192.168.10.0 24 23.0.0.2 preference 70
[R2]quit
<R2>save
The current configuration will be written to the device.
Are you sure to continue? (y/n)[n]:y
It will take several minutes to save configuration file, please wait.......
Configuration file had been saved successfully
Note: The configuration file will take effect after being activated
<R2>
四 配置路由器R3
①进入系统视图
②改路由器名称为R3
③接口IP设置
接口g0/0/0 ip address 13.0.0.2 24
接口g0/0/1 ip address 23.0.0.2 24
④设置j静态路由
ip route-static 192.168.20.0 24 23.0.0.1
ip route-static 192.168.10.0 24 13.0.0.1
⑤保存设置
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R3
[R3]interface g0/0/0
[R3-GigabitEthernet0/0/0]ip address 13.0.0.2 24
Apr 5 2021 20:32:57-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]interface g0/0/1
[R3-GigabitEthernet0/0/1]ip address 23.0.0.2 24
Apr 5 2021 20:33:26-08:00 R3 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[R3-GigabitEthernet0/0/1]quit
[R3]ip route-static 192.168.20.0 24 23.0.0.1
[R3]ip route-static 192.168.10.0 24 13.0.0.1
[R3]quit
<R3>save
The current configuration will be written to the device.
Are you sure to continue? (y/n)[n]:y
It will take several minutes to save configuration file, please wait.......
Configuration file had been saved successfully
Note: The configuration file will take effect after being activated
<R3>
五 测试
1 浮动路由,PC1和PC2 互通测试
(1)PC1 ping 通PC2
(2)PC2 ping 通PC1
2.断掉R1和R2之间的其中一条链路,观察路由表的变化,PC1和PC2依然可通信。
(1)断开前路由器R1的路由表和R2的路由表
路由器R1的路由表
[R1]dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 14 Routes : 14
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.0.0.0/24 Direct 0 0 D 10.0.0.1 GigabitEthernet
0/0/1
10.0.0.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
10.0.0.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
13.0.0.0/24 Direct 0 0 D 13.0.0.1 GigabitEthernet
0/0/2
13.0.0.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/2
13.0.0.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/2
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
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.10.0/24 Direct 0 0 D 192.168.10.254 GigabitEthernet
0/0/0
192.168.10.254/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
192.168.10.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
192.168.20.0/24 Static 60 0 RD 10.0.0.2 GigabitEthernet
0/0/1
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
[R1]
路由器R2的路由表
[R2]dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 14 Routes : 14
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.0.0.0/24 Direct 0 0 D 10.0.0.2 GigabitEthernet
0/0/0
10.0.0.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
10.0.0.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
23.0.0.0/24 Direct 0 0 D 23.0.0.1 GigabitEthernet
0/0/2
23.0.0.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/2
23.0.0.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/2
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
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.10.0/24 Static 60 0 RD 10.0.0.1 GigabitEthernet
0/0/0
192.168.20.0/24 Direct 0 0 D 192.168.20.254 GigabitEthernet
0/0/1
192.168.20.254/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.20.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
(2)断开后R1的路由表和R2的路由表
先在路由器R1中断开g0/0/1接口,然后再查看路由表。
断开后路由器R1的路由表
[R1]int g0/0/1
[R1-GigabitEthernet0/0/1]shutdown
Apr 6 2021 00:47:17-08:00 R1 %%01IFPDT/4/IF_STATE(l)[0]:Interface GigabitEthern
et0/0/1 has turned into DOWN state.
[R1-GigabitEthernet0/0/1]
[R1-GigabitEthernet0/0/1]
Apr 6 2021 00:47:17-08:00 R1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the DOWN state.
[R1-GigabitEthernet0/0/1]q
[R1]dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 11 Routes : 11
Destination/Mask Proto Pre Cost Flags NextHop Interface
13.0.0.0/24 Direct 0 0 D 13.0.0.1 GigabitEthernet
0/0/2
13.0.0.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/2
13.0.0.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/2
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
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.10.0/24 Direct 0 0 D 192.168.10.254 GigabitEthernet
0/0/0
192.168.10.254/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
192.168.10.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
192.168.20.0/24 Static 70 0 RD 13.0.0.2 GigabitEthernet
0/0/2
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
[R1]
断开后路由器R2的路由表
[R2]dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 11 Routes : 11
Destination/Mask Proto Pre Cost Flags NextHop Interface
23.0.0.0/24 Direct 0 0 D 23.0.0.1 GigabitEthernet
0/0/2
23.0.0.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/2
23.0.0.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/2
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
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.10.0/24 Static 70 0 RD 23.0.0.2 GigabitEthernet
0/0/2
192.168.20.0/24 Direct 0 0 D 192.168.20.254 GigabitEthernet
0/0/1
192.168.20.254/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.20.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
[R2]
从上面的路由表中可以发现:
原先在R1的静态路由ip route-static 192.168.20.0 24 10.0.0.2和原先在R2的静态路由ip route-static 192.168.10.0 24 10.0.0.1没有了。
被新的静态路由所取代R1中ip route-static 192.168.20.0 24 13.0.0.2 preference 70和R2中ip route-static 192.168.10.0 24 23.0.0.2 preference 70
可以认为浮动路由是原先线路的备用路线保证,当线路不通断开时可以转到备用的线路,保证数据的正常传输不会中断。
(3)断开后PC1 和PC2互PING测试
PC1 和PC2互PING还是可以互通。
①PC1 ping 通PC2
②PC2 ping 通PC1