|
failover 之后:
清单 15. Failover 之后路由器 A 的路由表
RouterA#show ip route Codes: C - connected, S - static, I - IGRP, 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
10.0.0.0/24 is subnetted, 3 subnets R 10.0.2.0 [120/2] via 192.168.0.2, 00:00:09, Serial0/0 C 10.0.0.0 is directly connected, Loopback0 R 10.0.1.0 [120/1] via 192.168.0.2, 00:00:09, Serial0/0 192.168.0.0/30 is subnetted, 1 subnets C 192.168.0.0 is directly connected, Serial0/0 192.168.1.0/30 is subnetted, 1 subnets R 192.168.1.0 [120/1] via 192.168.0.2, 00:00:09, Serial0/0 192.168.2.0/30 is subnetted, 1 subnets R 192.168.2.0 [120/2] via 192.168.0.2, 00:00:10, Serial0/0 使用 Zebra 配置 OSPF 路由
完成 RIP 的配置后,我们开始配置 OSPF 路由。尽管 OSPF 和 RIP 可以同时使用,不过为了配置的简化,我们现在只使用 OSPF。我们只需要把 ripd 服务停掉,就可以在 Zebra 中将 RIP 禁用。
# service ripd stop
和前面一样,我们从 OSPF 的一个基本的配置文件开始,这次是 ospfd.conf,文件所在目录仍是 /etc/zebra。
清单 16. 一个基本的 /etc/zebra/ospfd.conf 文件
hostname speedmetal-ospf password zebra enable password zebra
然后,我们启动 OSPF 服务:
# service ospfd start
对 OSPF 的配置比 RIP 简单:基本上我们仅仅需要告诉 OSPF 去广播所有它知道的路由。
配置 OSPF 的端口是 2604。
下面是我们配置 OSPF 的会话。
清单 17. OSPF 配置会话
[root@speedmetal zebra]# telnet 127.0.0.1 2604 User Access Verification
Password: zebra speedmetal-ospf> enable Password: zebra speedmetal-ospf# configure terminal speedmetal-ospf(config)# router ospf speedmetal-ospf(config-router)# network 0.0.0.0/0 area 0 speedmetal-ospf(config-router)# end speedmetal-ospf# write Configuration saved to /etc/zebra/ospfd.conf speedmetal-ospf# show run Current configuration: ! hostname speedmetal-ospf password zebra enable password zebra ! ! router ospf network 0.0.0.0/0 area 0 ! line vty ! end speedmetal-ospf#
ospfd.conf 配置文件的修改结果如下:
清单 18. Zebra 修改后的 /etc/zebra/ospfd.conf 文件
! ! Zebra configuration saved from vty ! 2003/08/19 14:22:17 ! hostname speedmetal-ospf password zebra enable password zebra ! ! ! interface lo ! interface eth0 ! interface eth1 ! interface dummy0 ! router ospf network 0.0.0.0/0 area 0 ! line vty ! 在 Cisco 路由器上配置 OSPF
我们用以下命令来移除 RIP 协议并添加 OSPF 协议:
清单 19. 移除 RIP 协议,添加 OSPF 协议
RouterA#conf term RouterA(config)no router rip RouterA(config)#router ospf 100 RouterA(config-router)#network 0.0.0.0 255.255.255.255 area 0 RouterA(config-router)end
我们在路由器 A 和路由器 B 上执行同样的步骤。
使用 OSPF 传播路由
我们的 MRLG 报告是这样的:
清单 20. Zebra 反映的 OSPF 路由
Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF, B - BGP, > - selected route, * - FIB route
O>* 10.0.0.0/32 [110/11] via 192.168.2.2, eth0, 00:00:01 O>* 10.0.1.1/32 [110/11] via 192.168.1.2, eth1, 00:02:53 O 10.0.2.0/24 [110/10] is directly connected, dummy0, 00:03:31 C>* 10.0.2.0/24 is directly connected, dummy0 K * 127.0.0.0/8 is directly connected, lo C>* 127.0.0.0/8 is directly connected, lo O>* 192.168.0.0/30 [110/58] via 192.168.2.2, eth0, 00:00:01 via 192.168.1.2, eth1, 00:00:01 O 192.168.1.0/30 [110/10] is directly connected, eth1, 00:03:21 C>* 192.168.1.0/30 is directly connected, eth1 O 192.168.2.0/30 [110/10] is directly connected, eth0, 00:03:31 C>* 192.168.2.0/30 is directly connected, eth0
请注意 10.0.0.1/32 和到 10.0.1.1/32 的路由被标记为 O,说明这些路由是通过 OSPF 得到的。
当我们把从 Zebra 路由器到路由器 A 的连接断开时,路由自动更新。MRLG 生成的报告如下:
清单 21. Failover 之后 Zebra 反映的 OSPF 路由
Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF, B - BGP, > - selected route, * - FIB route
O>* 10.0.0.1/32 [110/59] via 192.168.2.2, eth0, 00:01:10 O>* 10.0.1.1/32 [110/11] via 192.168.1.2, eth1, 00:09:46 O 10.0.2.0/24 [110/10] is directly connected, dummy0, 00:10:24 C>* 10.0.2.0/24 is directly connected, dummy0 K * 127.0.0.0/8 is directly connected, lo C>* 127.0.0.0/8 is directly connected, lo O>* 192.168.0.0/30 [110/58] via 192.168.1.2, eth1, 00:01:10 O 192.168.1.0/30 [110/10[ is directly connected, eth1, 00:10:14 C>* 192.168.1.0/30 is directly connected, eth1 O 192.168.2.0/30 [110/10] is directly connected, eth0, 00:10:24 C>* 192.168.2.0/30 is directly connected, eth0
由于 OSPF 是基于链路状态的,所以 failover 速度快得多:新的路由在 30 秒内就可以传播完成。
结束语
我们的出发点是一个简单的需求,那就是我们的网络课程受设备条件所限,需要寻找一个 Cisco 路由器的替代品。Zebra 是一个明智的选择,它在网络上得到了诸多的好评。正如前面我们的实验所示,Zebra 在简单网络环境中完全可以取代 Cisco 路由器,可能也能用于一些更复杂的情形。
无可否认,要转而使用 Zebra 需要一定程度的学习。使用单独的守护进程及单独的配置文件在刚开始时令人费解,但是当我们把这些理顺了以后,感觉它几乎和 Cisco IOS 没什么区别。
总的来说,Zebra 使得在 Linux 上实现动态路由成为一项简单的任务。如果您需要尽快构建一个路由器,而您的预算却有限,不妨试试 Zebra。
|