自由路由软件Zebra基本配置完全攻略_第1页
自由路由软件Zebra基本配置完全攻略_第2页
自由路由软件Zebra基本配置完全攻略_第3页
自由路由软件Zebra基本配置完全攻略_第4页
自由路由软件Zebra基本配置完全攻略_第5页
已阅读5页,还剩21页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、自由路由软件 Zebra 基本配置完全攻略前言Zebra 是一个路由软件包,提供基于 TCP/IP路由服务,支持 RIPv1, RIPv2, RIPng, OSPFv2, OSPFv3, BGP- 4, 和 BGP-4+等众多路由协议。 Zebra 还支持 BGP 特性路由反射器(Route Reflector 。除了传统的 IPv4路由协议, Zebra 也支持 IPv6路由协议。如果运行的 SNMP 守 护进程(需要 ucd-snmp 支持 SMUX 协 议, Zebra 还能支持路由协议 MIBs 。由以上可见, Zebra 的确是一个很不错的路由系统,但比起真正的路由器就简直是小儿 科

2、,所以网络高手 就当这文章是小孩子过家家吧,而对于象我这样的初学者(特别是没有 真实设备或足够设备进行实验 也不失为一个学习和熟悉路由配置、路由协议的好工具。 我没有实际的配置经验,对路由的技术细节也 不是十分清晰,完全是在扔破砖头。希望路 由高手指正概念错误。安装shell> cd zebra-0.92ashell> ./configureshell> makeshell> make install这 样 Zebra 就安装好了,安装的执行文件:shell> ls /usr/local/sbinbgpd ospfd ripd zebra配置文件:shell>

3、; ls /usr/local/etc运行编译安装完 Zebra 后, 可以看到有 4个可执行文件和 5个配置样本文件,我们就使用 它的配置样本文件:shell> cd /usr/local/etcZebra 的各进程有各自的终端接口或 VTY , 如果我们需要给连接到它们的端口设置别名 的话,在 /etc/ services文件添加如下内容:zebrasrv 2600/tcp# zebra servicezebra 2601/tcp# zebra vtyripd 2602/tcp# RIPd vtyripngd 2603/tcp# RIPngd vtyospfd 2604/tcp# O

4、SPFd vtybgpd 2605/tcp# BGPd vtyospf6d 2606/tcp# OSPF6d vty然后就可以启动 Zebra 了:shell> zebra -d这样, Zebra 就以守护进程启动了,其它的参数请参考 zebra -h。基本路由配置命令直接用 telnet 连接:shell> telnet localhost 2601Connected to localhost.Escape character is ''.Hello, this is zebra (version 0.92a.Copyright 1996-2001 Kunihir

5、o Ishiguro.User Access VerificationPassword:Zebra 会提示输入口令, 我 们通过 /usr/local/etc/zebra.conf可以看到口令是 zebra , enable 口令也是 zebra 。输 入口令 zebra ,得到路由器用户模式提示符:Router>进入特权模式:Router> enPassword:Router#输入一个问号,看看 Zebra 提供了多 少路由命令:Router# ?configure Configuration from vty interfacecopy Copy configurationde

6、bug Debugging functions (see also 'undebug'disable Turn off privileged mode commandend End current mode and change to enable mode.exit Exit current mode and down to previous modehelp Description of the interactive help systemlist Print command listno Negate a command or set its defaultsquit

7、Exit current mode and down to previous modeshow Show running system informationterminal Set terminal line parameterswho Display who is on vtywrite Write running configuration to memory, network, or terminal提供的命令很少,实际路由器好多命令都没有,我们只能用有限的 命令投入到无限的 实验中去。Router# sh runCurrent configuration:!hostname Rout

8、erpassword zebraenable password zebra!interface lo!interface eth0!line vty!endZebra 把操作系统的网络接口当做路由 器的接口, 所以在做比较复杂的路由实验, 会需 要比较多的网卡。进入全局模式,尽可能把实际可用的配置命令都实验一遍:Router# conf tRouter(config#自己取一个路由器名字:Router(config# hostname r1r1(config#Zebra 比较简单,登陆口令不 是在 line 下修改,而是直接在全局模式下用 password 修 改 r1(config# pas

9、sword passwordZebra 不支持 enable secret password这种 MD5加密口令,只能使用 enable password password来修改 enable 口令:r1# conf tr1(config# enable password password在路由器配置中加密所有的口令:r1(config# service password-encryption回到特权模式:r1(config# exitr1# sh runCurrent configuration:!hostname r1password 8 alA5.vcyMAwXQenable passw

10、ord 8 ksbxOFN8xcFMcservice password-encryption!interface lo!interface eth0!line vty!end我 们看到刚才的明文密码都进行加密了, 给我们的实验机也提高安全性。 Zebra 有一点 比较恶心,如果我 们先设置了 service password-encryption ,然后再修改口令, sh run 就发现口令又都是明文的了,但是由 于有 service password-encryption,所以就无法登陆了。去掉会话超时, 免得 10分钟没有动作, 就把我们给踢了。 但是在实际 的路由器配置中, 为安全起见我

11、们 最好还是设上会话超时。r1# conf tr1(config# line vtyr1(config-line# exec-timeout 0 0设置日志记录, Zebra 可以把日志记 录到标准输出、 syslog 、以及指定输出文件:r1(config-line# exitr1(config# log stdoutr1(config# no log stdoutr1(config# log syslogr1(config# no log syslogr1(config# log file /usr/local/etc/zebra.log配置接口 IP 地址:r1(config# int

12、lor1(config-if# exitr1(config# int eth0保存我们刚才的配置:r1(config-if# exitr1(config# exitr1# copy run startConfiguration saved to /usr/local/etc/zebra.confr1#2、用 Zebra 做简单的 RIP 实验RIP 是应用较早、使用较 普遍的 IGP ,适用 于小型同类网 络,是典型的 距离向量 (distance-vector协 议。 RIP 通过广播 UDP 报文来交换路由信息, 每 30秒发送一次路由信息 更新。 RIP 提供跳跃计数 (hop coun

13、t 作为尺度来衡量路由距离,跳跃计数是一个包到达目标 所必须经过的路由器的数目。如果到相同 目标有二个不等速或不同带宽的路由器,但跳跃 计数相同,则 RIP 认为两个路由是等距离的。 RIP 最多支 持的跳数为 15,即在源和目的网间所要经过的最多路由器的数目为 15,跳数 16表示不可达。 RIPv2支持 验证、密钥管理、 路由汇总、无类域间路由 (CIDR和变长子网掩码 (VLSMs。Zebra 支持 RIPv2,使用 ripd 程 序实现 RIP 路由功能,但 ripd 程序需要在 zebra 程序读 取接口信息, 所以 zebra 一定要在 ripd 之前启动。 由于条件所限, 下面的

14、 RIP 实验是在两台 单网卡的 RedHat7.2下做的,所以只是 最简单的演示。按照上面基本配置的方法初始化第一台机器:shell_1> cd /usr/local/etcshell_1> zebra -d进入 zebra 设 置 IPshell_1> telnet localhost 2601Password:Router> enPassword:Router# conf tRouter(config# hostname r1r1(config# int eth0r1(config-if# ctrl+zr1# copy run start进入第一台机器的 rip

15、设置shell_1> ripd -dshell_1> telnet localhost 2602Password:ripd> enripd# conf tripd(config# hostname r1_ripd !改个名字好辨认r1_ripd(config# router rip !启动 ripr1的 RIP 简单配置这样就可用了,下面来检验一下:r1_ripd# sh ip protocolsRouting Protocol is "rip"Sending updates every 30 seconds with +/-50%, next due i

16、n 3 secondsTimeout after 180 seconds, garbage collect after 120 secondsOutgoing update filter list for all interface is not setIncoming update filter list for all interface is not setDefault redistribution metric is 1Redistributing:Default version control: send version 2, receive version 2Interface

17、Send Recv Key-chaineth022Routing for Networks:Routing Information Sources:Gateway BadPackets BadRoutesDistance Last UpdateDistance: (default is 120我们看到 RIP 已经起来了,是 RIPv2。r1_ripd# sh ip ripCodes: R - RIP, C - connected, O - OSPF, B - BGPNetwork Next HopMetric FromTime由于就两个接口直连,没有其 它网络,所以 sh ip rip看不到

18、什么。Zebra 对 log 处理可能有些问题, 使用 log stdout不能显示各种 debug 信息, 所以只能记 录到文件,在 shell 下 用 tail 命令查看。r1_ripd# debug rip eventsr1_ripd# debug rip packetr1_ripd(config# log file /usr/local/etc/ripd.log然后我们在 shell 下查看 debug 信息shell_1> tail -f /usr/local/etc/ripd.log-8<-2002/04/28 22:17:44 RIP: update timer fi

19、re!2002/04/28 22:17:44 RIP: SEND UPDATE to eth0 ifindex 22002/04/28 22:17:44 RIP: multicast announce on eth02002/04/28 22:17:44 RIP: update routes on interface eth0 ifindex 22002/04/28 22:18:23 RIP: update timer fire!2002/04/28 22:18:23 RIP: SEND UPDATE to eth0 ifindex 22002/04/28 22:18:23 RIP: mult

20、icast announce on eth02002/04/28 22:18:23 RIP: update routes on interface eth0 ifindex 22002/04/28 22:19:04 RIP: update timer fire!2002/04/28 22:19:04 RIP: SEND UPDATE to eth0 ifindex 22002/04/28 22:19:04 RIP: multicast announce on eth02002/04/28 22:19:04 RIP: update routes on interface eth0 ifindex

21、 2-8<-RIP 每隔 30秒发送一次更新, 在 sh ip prot可以看到 Sending updates every 30 seconds with +/-50%第二台机器的设置进入第二台机器的 rip 设置shell_2> ripd -dshell_2> telnet localhost 2602Password:ripd> enripd# conf tripd(config# hostname r2_ripdr2_ripd(config# router rip执行完 network 命令, 我们看到第一台机器的 tail -f /usr/local/etc/

22、ripd.log输出下面的信 息:-8<-2002/04/28 22:19:15 RIP: RECV REQUEST version 2 packet size 242002/04/28 22:19:35 RIP: update timer fire!2002/04/28 22:19:35 RIP: SEND UPDATE to eth0 ifindex 22002/04/28 22:19:35 RIP: multicast announce on eth02002/04/28 22:19:35 RIP: update routes on interface eth0 ifindex 2

23、-8<-r1_ripd# copy run startConfiguration saved to /usr/local/etc/ripd.confr2_ripd# copy run startConfiguration saved to /usr/local/etc/ripd.confZebra 还支持很多 RIP 功能,如果 Filtering RIP Routes, RIP route-map, RIP Authentication等,有条件有时间 的话可以做更复杂的实验。3、用 Zebra 做 OSPF 实验OSPF (开放最短路径优先 路由协议是一项 链路状态型技术, 是目前

24、IGP 中应用最广、 性能最优的一个 协议,解决了 RIP 不能解决的大型、可扩展的网络需求而写的,适用于大 规模的网络。Zebra 支持 OSPFv2和 OSPFv3(用于 IPv6的 OSPF , CISCO 还未对其封装 ,由于条件所 限,下面的 OSPF 实 验同样是在两台单网卡的 RedHat7.2下做的。Zebra 使用 ospfd 程序实现 OSPF 路由功能,但 ospfd 需要从 zebra 程序获得接口信息, 所以 zebra 程序必须在 ospfd 程序之前运行。 ospfd 不支持多个 OSPF 进程,我们不能指定 OSPF 进程号。初始化第一台机器:shell_1&g

25、t; cd /usr/local/etcshell_1> zebra -d进入 zebra 设置 IPshell_1> telnet localhost 2601Password:Router> enPassword:Router# conf tRouter(config# hostname r1r1(config# int eth0r1(config-if# ctrl+zr1# copy run start进入第一台机器的 ospf 设置shell_1> ospfd -dshell_1> telnet localhost 2604Password:ospfd&g

26、t; enospfd# conf tospfd(config# hostname r1_ospfd !改个名字好辨认r1_ospfd(config# router ospf !启动 ospf! 最关键的,来标识路由器上哪些 IP 网络号是 OSPF 的一部分,对于每个网络,我们必 须标识该网络所属 的区域。由于我们只有两台机器,当然只有一个网络,所以只需执行一 个 network 命令就够了。对于我们的小网络, ospf 就算 配好了,下面来检验一下:r1_ospfd(config-router# ctrl+zr1_ospfd# sh ip ospf route= OSPF network r

27、outing table =directly attached to eth0= OSPF router routing table = OSPF external routing table =r1_ospfd# sh ip ospf databaseLink IDADV RouterAge Seq#CkSum Link countr1_ospfd# sh ip ospf int eth0eth0 is up, line protocol is upTransmit Delay is 1 sec, State DR, Priority 1No backup designated router

28、 on this networkTimer intarvals configured, Hello 10, Dead 40, Wait 40, Retransmit 5Hello due in 00:00:07Neighbor Count is 0, Adjacent neighbor count is 0由于网络里没有其它 的路由器, r1就把自己选为 DR (指定路由器了。 Zebra 对 log 处理可能有些问题,使 用 log stdout 不能显示各种 debug 信息,所以只能记录到文件,在shell 下用 tail 命令查看。而且 debug 命令和 实际路由器也有不同。r1_o

29、spfd# debug ospf eventr1_ospfd(config# log file /usr/local/etc/ospfd.log然后我们在 shell 下查看 debug 信息shell_1> tail -f /usr/local/etc/ospfd.log-8<-8<-第二台机器的设置shell_2> ospfd -dshell_2> telnet localhost 2604Password:ospfd> enospfd# conf tospfd(config# hostname r2_ospfdr2_ospfd(config# rout

30、er ospf执行完 network 命令,我们看到第一台机器的 tail -f /usr/local/etc/ospfd.log输出下面的 信息:-8<-2002/04/28 14:25:52 OSPF: couldn't find any VL to associate the packet with2002/04/28 14:25:52 OSPF: PacketDD: Negotiation done (Slave.-8<-r1_ospfd# sh ip ospf neigNeighbor ID Pri State Dead Time Address Interfac

31、e RXmtLRqstL DBsmL检验其它信息r1_ospfd# sh ip ospf databaseLink IDADV RouterAge Seq#CkSum Link countLink IDADV RouterAge Seq#CkSumr1_ospfd# sh ip ospf int eth0eth0 is up, line protocol is upTransmit Delay is 1 sec, State DR, Priority 1Timer intarvals configured, Hello 10, Dead 40, Wait 40, Retransmit 5Hel

32、lo due in 00:00:01Neighbor Count is 1, Adjacent neighbor count is 1拔掉两台机器连接的网线,看 ospfd.log 的记录:-8<-2002/04/28 16:26:37 OSPF: ospf_check_abr_status(: Start2002/04/28 16:26:37 OSPF: ospf_check_abr_status(: looked through areas2002/04/28 16:26:37 OSPF: ospf_check_abr_status(: bb_configured: 12002/04

33、/28 16:26:37 OSPF: ospf_check_abr_status(: bb_act_attached: 12002/04/28 16:26:37 OSPF: ospf_check_abr_status(: areas_configured: 12002/04/28 16:26:37 OSPF: ospf_check_abr_status(: areas_act_attached: 12002/04/28 16:26:37 OSPF: ospf_check_abr_status(: Start2002/04/28 16:26:37 OSPF: ospf_check_abr_sta

34、tus(: looked through areas2002/04/28 16:26:37 OSPF: ospf_check_abr_status(: bb_configured: 12002/04/28 16:26:37 OSPF: ospf_check_abr_status(: bb_act_attached: 12002/04/28 16:26:37 OSPF: ospf_check_abr_status(: areas_configured: 12002/04/28 16:26:37 OSPF: ospf_check_abr_status(: areas_act_attached: 1

35、2002/04/28 16:26:37 OSPF: Timerrouter-LSA: (router-LSA Refresh expire2002/04/28 16:26:37 OSPF: there are 0 of them2002/04/28 16:26:37 OSPF: SPF: calculation timer scheduled2002/04/28 16:26:37 OSPF: SPF: calculation timer delay = 52002/04/28 16:26:42 OSPF: ospf_spf_calculate: Start2002/04/28 16:26:42

36、 OSPF: = OSPF routing table =2002/04/28 16:26:42 OSPF: =2002/04/28 16:26:42 OSPF: ospf_intra_add_stub(: Start2002/04/28 16:26:42 OSPF: ospf_intra_add_stub(: installing new route2002/04/28 16:26:42 OSPF: ospf_intra_add_stub(: this network is on this router2002/04/28 16:26:42 OSPF: children of V:2002/04/28 16:26:42 OSPF: ospf_spf_calculate: Stop2002/04/28 16

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论