默认路由:一种特殊的静态路由,只有从路由表中找不到任何明确匹配的路由条目时,才会使用默认路由。(当访问Internet时,一些网络出口只有一个,此时没有必要配置)
浮动路由:配置一个管理距离更大的静态路由,作为应急出发的备份路径,在主路由有效的情况下,浮动路由不会出现在路由表中。
实验名称:华为路由器配置静态路由默认路由实现全网互通
实验拓扑图:
实验步骤:PC配置IP子网掩码网关
路由器配置接口和静态路由
验证
实验结果:实现全网互通为浮动路由做准备
实验命令:
R1
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R1
[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]undo shutdown
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[R1-GigabitEthernet0/0/0]ip address 192.168.1.254 255.255.255.0
[R1-GigabitEthernet0/0/0]quit
[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]undo shutdown
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[R1-GigabitEthernet0/0/1]ip address 192.168.2.1 255.255.255.0
[R1-GigabitEthernet0/0/1]quit
[R1]ip route-static 0.0.0.0 0.0.0.0 192.168.2.2 //ip 路由-静态 (默认路由或缺省路由一种特殊的静态路由!)
[R1]display ip routing-table #显示 IP 路由-表
Route Flags: R - relay, D - download to fib
标记 下载 到 路由表
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 11 Routes : 11
Destination/Mask Proto Pre Cost Flags NextHop Interface
目标地址 掩码 协议 下一跳 接口
0.0.0.0/0 Static 60 0 RD 192.168.2.2 GigabitEthernet
0/0/1 静态
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.1.0/24 Direct 0 0 D 192.168.1.254 GigabitEthernet
0/0/0 直连
192.168.1.254/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
192.168.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
192.168.2.0/24 Direct 0 0 D 192.168.2.1 GigabitEthernet
0/0/1
192.168.2.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.2.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
<Huawei>sysn
<Huawei>sys
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R2
[R2]interface GigabitEthernet 0/0/0
[R2-GigabitEthernet0/0/0]undo shutdown
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[R2-GigabitEthernet0/0/0]ip address 192.168.2.2 255.255.255.0
Nov 19 2018 19:09:16-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]quit
[R2]interface GigabitEthernet 0/0/1
[R2-GigabitEthernet0/0/1]undo shutdown
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[R2-GigabitEthernet0/0/1]ip address 192.168.3.1 255.255.255.0
Nov 19 2018 19:10:00-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]quit
[R2]ip route-static 192.168.1.0 255.255.255.0 192.168.2.1 //#IP 路由-静态 目标网络ID 子网掩码 下一跳端口
[R2]ip route-static 192.168.4.0 255.255.255.0 192.168.3.2
[R2]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 12 Routes : 12
Destination/Mask Proto Pre Cost Flags NextHop Interface
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.1.0/24 Static 60 0 RD 192.168.2.1 GigabitEthernet
0/0/0
192.168.2.0/24 Direct 0 0 D 192.168.2.2 GigabitEthernet
0/0/0
192.168.2.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
192.168.2.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
192.168.3.0/24 Direct 0 0 D 192.168.3.1 GigabitEthernet
0/0/1
192.168.3.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.3.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.4.0/24 Static 60 0 RD 192.168.3.2 GigabitEthernet
0/0/1
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
R3
<Huawei>sys
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R3
[R3]interface GigabitEthernet 0/0/1
[R3-GigabitEthernet0/0/1]undo shutdown
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[R3-GigabitEthernet0/0/1]ip address 192.168.3.2 255.255.255.0
Nov 19 2018 19:11:07-08:00 R3 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[R3-GigabitEthernet0/0/1]quit
[R3]interface GigabitEthernet 0/0/0
[R3-GigabitEthernet0/0/0]undo shutdown
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[R3-GigabitEthernet0/0/0]ip address 192.168.4.254 255.255.255.0
Nov 19 2018 19:12:23-08:00 R3 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[R3-GigabitEthernet0/0/0]quit
[R3]ip route-static 0.0.0.0 0.0.0.0 192.168.3.1 //ip 路由-静态 (默认路由或缺省路由一种特殊的静态路由!)
[R3]display 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
0.0.0.0/0 Static 60 0 RD 192.168.3.1 GigabitEthernet
0/0/1
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.3.0/24 Direct 0 0 D 192.168.3.2 GigabitEthernet
0/0/1
192.168.3.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.3.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.4.0/24 Direct 0 0 D 192.168.4.254 GigabitEthernet
0/0/0
192.168.4.254/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
192.168.4.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
=====================================================================================
实验名称:思科配置静态路由默认路由实现全网互通
实验拓扑图:
实验步骤:PC配置IP子网掩码网关
路由器配置接口和静态路由
验证并保存
实验结果:实现全网互通为浮动路由做准备
实验命令:
R1
Router>enable
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R1
R1(config)#no ip domain lookup
R1(config)#interface gigabitEthernet 0/1
R1(config-if)#no shutdown
R1(config-if)#ip address 192.168.1.254 255.255.255.0
R1(config-if)#exit
R1(config)#interface gigabitEthernet 0/0
R1(config-if)#no shutdown
R1(config-if)#ip address 192.168.2.1 255.255.255.0
R1(config-if)#exit
R1(config)#ip route 0.0.0.0 0.0.0.0 192.168.2.2 //静态默认路由
R1(config)#end
R1#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is 192.168.2.2 to network 0.0.0.0
192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.1.0/24 is directly connected, GigabitEthernet0/1
L 192.168.1.254/32 is directly connected, GigabitEthernet0/1
192.168.2.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.2.0/24 is directly connected, GigabitEthernet0/0
L 192.168.2.1/32 is directly connected, GigabitEthernet0/0
S* 0.0.0.0/0 [1/0] via 192.168.2.2
属性
R3#write
R2
Router>enable
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R2
R2(config)#no ip domain lookup
R2(config)#interface gigabitEthernet 0/0
R2(config-if)#no shutdown
R2(config-if)#ip address 192.168.2.2 255.255.255.0
R2(config-if)#exit
R2(config)#interface gigabitEthernet 0/2
R2(config-if)#no shutdown
R2(config-if)#ip address 192.168.3.1 255.255.255.0
R2(config-if)#exit
R2(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1
R2(config)#ip route 192.168.4.0 255.255.255.0 192.168.3.2
R2(config)#end
R2#show ip route 直连 静态
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
S 192.168.1.0/24 [1/0] via 192.168.2.1
192.168.2.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.2.0/24 is directly connected, GigabitEthernet0/0
L 192.168.2.2/32 is directly connected, GigabitEthernet0/0
192.168.3.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.3.0/24 is directly connected, GigabitEthernet0/2
L 192.168.3.1/32 is directly connected, GigabitEthernet0/2
S 192.168.4.0/24 [1/0] via 192.168.3.2
属性
R2#write
R3
Router>enable
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R3
R3(config)#no ip domain lookup
R3(config)#interface gigabitEthernet 0/2
R3(config-if)#no shutdown
R3(config-if)#ip address 192.168.3.2 255.255.255.0
R3(config-if)#exit
R3(config)#interface gigabitEthernet 0/1
R3(config-if)#no shutdown
R3(config-if)#ip address 192.168.4.254 255.255.255.0
R3(config-if)#exit
R3(config)#ip route 0.0.0.0 0.0.0.0 192.168.3.1 //静态默认路由
R3(config)#end
R3#show ip route 直连 静态
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is 192.168.3.1 to network 0.0.0.0
192.168.3.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.3.0/24 is directly connected, GigabitEthernet0/2
L 192.168.3.2/32 is directly connected, GigabitEthernet0/2
192.168.4.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.4.0/24 is directly connected, GigabitEthernet0/1
L 192.168.4.254/32 is directly connected, GigabitEthernet0/1
S* 0.0.0.0/0 [1/0] via 192.168.3.1
属性
R3#write