浮动静态路由及默认路由注入实战,带你一分钟学会

2023-05-11 13:16:29

一、默认路由注入

1、实战目的:掌握如何通过 ip default-network 向网络中注入一条默认路由

2、实验步骤

(1)步骤 1:配置路由器 R1

R1(config)# router rip

R1(config-router)# version 2

R1(config-router)# no auto-summary

R1(config-router)# network 192.168.12.0

R1(config)# ip default-network 1.0.0.0

(2)步骤 2:配置路由器 R2

R2(config)# router rip

R2(config-router)# version 2

R2(config-router)# no auto-summary

R2(config-router)# network 192.168.12.0

R2(config-router)# network 2.0.0.0

3.实验调试

(1)在 R2 上查看路由表:

R2# show ip route

Codes: 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

i - IS-IS, su - IS-IS summary, 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.12.1 to network 0.0.0.0

//表明默认路由的网关为 192.168.12.1

C 192.168.12.0/24 is directly connected, Serial0/0/0

2.0.0.0/24 is subnetted, 1 subnets

C 2.2.2.0 is directly connected, Loopback0

R* 0.0.0.0/0 [120/1] via 192.168.12.1, 00:00:22, Serial0/0/0

从以上输出可以看出 R1 上的“ ip default-network”命令确实向 RIP 网络中注入一条

“ R* ”的默认路由。

(2)在 R2 上 ping 1.1.1.1;

R2# ping 1.1.1.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 12/14/16 ms

以上输出表明在路由器 R2 上可以 ping 通地址 1.1.1.1,虽然在 R1 的 RIP 进程中没有

通告该网络,也恰恰说明是默认路由起了作用。否则,因为在 R2 的路由表中没有 1.1.1.0

的路由条目,是不可能 ping 通的。

【小结】

(1)ip default-network 后面的网络一定要是主类网络;

(2)ip default-network 后面的网络可以是直连的或者通过其它协议学到的网络。

二、浮动静态路由

1、目的:通过本实验可以掌握浮动静态路由原理、配置以及备份应用

2.步骤

本实验通过修改静态路由的管理距离为 130,使得路由器选路的时候优先选择 RIP,而

静态路由作为备份。

(1)步骤 1:配置路由器 R1

R1(config)# ip route 2.2.2.0 255.255.255.0 192.168.12.2 130

//将静态路由的管理距离设置为 130

R1(config)# router rip

R1(config-router)# version 2

R1(config-router)# no auto-summary

R1(config-router)# network 1.0.0.0

R1(config-router)# network 192.168.21.0

(2)步骤 2:配置路由器 R2

R2(config)# ip route 1.1.1.0 255.255.255.0 192.168.12.1 130

R2(config)# router rip

R2(config-router)# version 2

R2(config-router)# no auto-summary

R2(config-router)# network 192.168.21.0

R2(config-router)# network 2.0.0.0

3.调试

(1)在 R1 上查看路由表:

R1# show ip route

Codes: 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

i - IS-IS, su - IS-IS summary, 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

C 192.168.12.0/24 is directly connected, Serial0/0/0

1.0.0.0/24 is subnetted, 1 subnets

C 1.1.1.0 is directly connected, Loopback0

2.0.0.0/24 is subnetted, 1 subnets

R 2.2.2.0 [120/1] via 192.168.21.2, 00:00:25, GigabitEthernet0/0

C 192.168.21.0/24 is directly connected, GigabitEthernet0/0

从以上输出可以看出,路由器将 RIP 的路由放入路由表中,因为 RIP 的管理距离为 120,

小于在静态路由中设定的 130,而静态路由处于备份的地位。

(2)在 R1 上将 g0/0 接口 shutdown,然后查看路由表:

R1(config)# interface gigabitEthernet 0/0

R1(config-if)# shutdown

R1# show ip route

Codes: 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

i - IS-IS, su - IS-IS summary, 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

C 192.168.12.0/24 is directly connected, Serial0/0/0

1.0.0.0/24 is subnetted, 1 subnets

C 1.1.1.0 is directly connected, Loopback0

2.0.0.0/24 is subnetted, 1 subnets

S 2.2.2.0 [130/0] via 192.168.12.2

以上输出说明,当主路由中断后,备份的静态路由被放入到路由表中,也很好地解释了

浮动静态路由作为备份的工作原理。

(3)在 R1 上将 g0/0 接口启动,然后查看路由表:

R1(config)# interface gigabitEthernet 0/0

R1(config-if)# no shutdown

R1# show ip route

Codes: 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

i - IS-IS, su - IS-IS summary, 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

C 192.168.12.0/24 is directly connected, Serial0/0/0

1.0.0.0/24 is subnetted, 1 subnets

C 1.1.1.0 is directly connected, Loopback0

2.0.0.0/24 is subnetted, 1 subnets

R 2.2.2.0 [120/1] via 192.168.21.2, 00:00:09, GigabitEthernet0/0

C 192.168.21.0/24 is directly connected, GigabitEthernet0/0

以上输出表明当主路由恢复后,浮动静态路由又恢复到备份的角色。