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

下载本文档

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

文档简介

自由路由软件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的确是一个很不错的路由系统,但比起真正的路由器就简直是小儿 科,所以网络高手 就当这文章是小孩子过家家吧,而对于象我这样的初学者(特别是没有真实设备或足够设备进行实验) 也不失为一个学习和熟悉路由配置、路由协议的好工具。我没有实际的配置经验,对路由的技术细节也 不是十分清晰,完全是在扔破砖头。希望路由高手指正概念错误。安装Zebra目前最新的版本是 0.92a,它的安装非常简单,我们只需从/下载zebra- 0.92a.tar.gz,然后执行以下命令安装(本文环境是RedHat7.2):shell tar xzf zebra-0.92a.tar.gzshell cd zebra-0.92ashell ./configureshell makeshell make install这 样Zebra就安装好了,安装的执行文件:shell ls /usr/local/sbinbgpd ospfdripdzebra配置文件:shell ls /usr/local/etc bgpd.conf.sample ospfd.conf.samplezebra.conf.sample bgpd.conf.sample2ripd.conf.sample运行编译安装完Zebra后, 可以看到有4个可执行文件和5个配置样本文件,我们就使用它的配置样本文件:shell cd /usr/local/etcshell cp zebra.conf.sample zebra.conf Zebra的各进程有各自的终端接口或VTY,如果我们需要给连接到它们的端口设置别名的话,在/etc/ services文件添加如下内容: zebrasrv2600/tcp # zebra servicezebra 2601/tcp # zebra vtyripd2602/tcp # RIPd vtyripngd2603/tcp # RIPngd vtyospfd 2604/tcp # OSPFd vtybgpd2605/tcp # BGPd vtyospf6d2606/tcp # OSPF6d vty然后就可以启动Zebra 了:shell zebra -d这样,Zebra就以守护进程启动了,其它的参数请参考 zebra -h。基本路由配置命令直接用telnet连接: shell telnet localhost 2601Trying .Connected to localhost.Escape character is .Hello, this is zebra (version 0.92a).Copyright 1996-2001 Kunihiro Ishiguro. User Access VerificationPassword:Zebra会提示输入口令,我 们通过/usr/local/etc/zebra.conf可以看到口令是zebra,enable口令也是zebra。输 入口令zebra,得到路由器用户模式提示符:Router进入特权模式: Router enPassword:Router#输入一个问号,看看Zebra提供了多 少路由命令:Router# ?configureConfiguration from vty interfacecopy Copy configurationdebugDebugging functions (see also undebug)disableTurn off privileged mode commandendEnd 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 Exit current mode and down to previous modeshow Show running system informationterminal Set terminal line parameters whoDisplay who is on vtywriteWrite running configuration to memory, network, or terminal提供的命令很少,实际路由器好多命令都没有,我们只能用有限的 命令投入到无限的实验中去。Router# sh runCurrent configuration:!hostname Routerpassword zebra enable password zebra!interface lo!interface eth0!line vty!endZebra把操作系统的网络接口当做路由 器的接口,所以在做比较复杂的路由实验,会需要比较多的网卡。进入全局模式,尽可能把实际可用的配置命令都实验一遍: Router# conf tRouter(config)#自己取一个路由器名字: Router(config)# hostname r1r1(config)#Zebra比较简单,登陆口令不 是在line下修改,而是直接在全局模式下用password修改r1(config)# password password Zebra不支持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 password 8 ksbxOFN8xcFMcservice password-encryption!interface lo !interface eth0!line vty!end我 们看到刚才的明文密码都进行加密了,给我们的实验机也提高安全性。Zebra有一点比较恶心,如果我 们先设置了service password-encryption,然后再修改口令,sh run就发现口令又都是明文的了,但是由 于有service password-encryption,所以就无法登陆了。去掉会话超时,免得10分钟没有动作,就把我们给踢了。但是在实际 的路由器配置中,为安全起见我们 最好还是设上会话超时。r1# conf tr1(config)# line vtyr1(config-line)# exec-timeout 0 0设置日志记录,Zebra可以把日志记 录到标准输出、syslog、以及指定输出文件:r1(config-line)# exit r1(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 lor1(config-if)# ip address /8r1(config-if)# exit r1(config)# int eth0r1(config-if)# ip address 21/24 Zebra比较奇怪,不能使用ip address 21 这种形式设置IP。测试一下,就设置成和Linux中使用的一样。保存我们刚才的配置: r1(config-if)# exitr1(config)# exitr1# copy run start Configuration saved to /usr/local/etc/zebra.confr1#2、用 Zebra做简单的RIP实验RIP是应用较早、使用较普遍的IGP,适用于小型同类网络,是典型的距离向量 (distance-vector)协 议。RIP通过广播UDP报文来交换路由信息,每30秒发送一次路由信息更新。RIP提供跳跃计数(hop count)作为尺度来衡量路由距离,跳跃计数是一个包到达目标所必须经过的路由器的数目。如果到相同 目标有二个不等速或不同带宽的路由器,但跳跃计数相同,则RIP认为两个路由是等距离的。RIP最多支 持的跳数为15,即在源和目的网间所要经过的最多路由器的数目为15,跳数16表示不可达。RIPv2支持 验证、密钥管理、路由汇总、无类域间路由(CIDR)和变长子网掩码(VLSMs)。Zebra支持RIPv2,使用ripd程 序实现RIP路由功能,但ripd程序需要在zebra程序读取接口信息,所以zebra 一定要在ripd之前启动。由于条件所限,下面的RIP实验是在两台单网卡的RedHat7.2下做的,所以只是 最简单的演示。 按照上面基本配置的方法初始化第一台机器:shell_1 cd /usr/local/etc shell_1 cp zebra.conf.sample zebra.confshell_1 cp ripd.conf.sample ripd.confshell_1 zebra -d进入zebra设 置IPshell_1 telnet localhost 2601Password: Router enPassword:Router# conf tRouter(config)# hostname r1r1(config)# int eth0r1(config-if)# ip address 21/24r1(config-if)# ctrl+zr1# copy run start 进入第一台机器的rip设置shell_1 ripd -dshell_1 telnet localhost 2602Password:ripd enripd# conf t ripd(config)# hostname r1_ripd !改个名字好辨认r1_ripd(config)# router rip !启动ripr1_ripd(config-router)# network /24 !RIPv1是有类别路由协议,RIPv2是无类别路由协议,Zebra 默认支持RIPv2,指定网络需要子网掩码。r1的 RIP简单配置这样就可用了,下面来检验一下:r1_ripd# sh ip protocolsRouting Protocol is ripSending updates every 30 seconds with +/-50%, next due in 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 set Default redistribution metric is 1Redistributing:Default version control: send version 2, receive version 2Interface SendRecv Key-chaineth0 2 2Routing for Networks: /24Routing Information Sources:Gateway BadPackets BadRoutesDistance Last UpdateDistance: (default is 120)我们看到RIP已经起来了,是RIPv2。r1_ripd# sh ip rip Codes: R - RIP, C - connected, O - OSPF, B - BGP NetworkNext Hop Metric FromTime由于就两个接口直连,没有其 它网络,所以sh ip rip看不到什么。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 fire!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 2 2002/04/28 22:18:23 RIP: multicast 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 2 -8 ripd -dshell_2 telnet localhost 2602Password: ripd enripd# conf tripd(config)# hostname r2_ripd r2_ripd(config)# router ripr2_ripd(config-router)# network /24执行完network命令,我们看到第一台机器的tail -f /usr/local/etc/ripd.log输出下面的信息: -8 family 0 tag 0 metric 162002/04/28 22:19:15 RIP: update routes to neighbor 232002/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 -8 cd /usr/local/etc shell_1 cp zebra.conf.sample zebra.confshell_1 cp ospfd.conf.sample ospfd.confshell_1 zebra -d进入 zebra设置IPshell_1 telnet localhost 2601Password: Router enPassword:Router# conf tRouter(config)# hostname r1r1(config)# int eth0r1(config-if)# ip address 21/24r1(config-if)# ctrl+zr1# copy run start 进入第一台机器的ospf设置shell_1 ospfd -dshell_1 telnet localhost 2604Password:ospfd enospfd# conf t ospfd(config)# hostname r1_ospfd !改个名字好辨认r1_ospfd(config)# router ospf !启动ospfr1_ospfd(config-router)# ospf router-id 21 !设置router-idr1_ospfd(config-router)# network /24 area 0 !最关键的,来标识路由器上哪些IP网络号是OSPF的一部分,对于每个网络,我们必须标识该网络所属 的区域。由于我们只有两台机器,当然只有一个网络,所以只需执行一个network命令就够了。对于我们的小网络,ospf就算 配好了,下面来检验一下:r1_ospfd(config-router)# ctrl+zr1_ospfd# sh ip ospf route= OSPF network routing table =N/2410 area: directly attached to eth0= OSPF router routing table = OSPF external routing table =r1_ospfd# sh ip ospf database OSPF Router with ID (21)Router Link States (Area )Link ID ADV RouterAgeSeq# CkSumLink count21 21126 0x80000002 0x8584 1r1_ospfd# sh ip ospf int eth0eth0 is up, line protocol is upInternet Address 21/24, Area Router ID 21, Network Type BROADCAST, Cost: 10 Transmit Delay is 1 sec, State DR, Priority 1Designated Router (ID) 21, Interface Address 21No backup designated router on this networkTimer intarvals configured, Hello 10, Dead 40, Wait 40, Retransmit 5Hello due in 00:00:07 Neighbor Count is 0, Adjacent neighbor count is 0由于网络里没有其它 的路由器,r1就把自己选为DR(指定路由器)了。Zebra对log处理可能有些问题,使 用log stdout不能显示各种debug信息,所以只能记录到文件,在shell下用tail命令查看。而且debug命令和 实际路由器也有不同。 r1_ospfd# debug ospf eventr1_ospfd(config)# log file /usr/local/etc/ospfd.log然后我们在shell下查看debug信息 shell_1 tail -f /usr/local/etc/ospfd.log -8- 2002/04/28 14:24:27 OSPF: make_hello: options: 2, int: eth0:212002/04/28 14:24:37 OSPF: make_hello: options: 2, int: eth0:212002/04/28 14:24:47 OSPF: make_hello: options: 2, int: eth0:212002/04/28 14:24:57 OSPF: make_hello: options: 2, int: eth0:212002/04/28 14:25:07 OSPF: make_hello: options: 2, int: eth0:21 -8 ospfd -dshell_2 telnet localhost 2604Password:ospfd enospfd# conf t ospfd(config)# hostname r2_ospfdr2_ospfd(config)# router ospf r2_ospfd(config-router)# ospf router-id 23 r2_ospfd(config-router)# network /24 area 0执行完 network命令,我们看到第一台机器的tail -f /usr/local/etc/ospfd.log输出下面的信息: -8- 2002/04/28 14:25:51 OSPF: Packet 23 Hello:RECV: Options *|*|-|-|-|-|E|*2002/04/28 14:25:51 OSPF: NSMeth0:21:: start2002/04/28 14:25:52 OSPF: make_hello: options: 2, int: eth0:212002/04/28 14:25:52 OSPF: couldnt find any VL to associate the packet with2002/04/28 14:25:52 OSPF: DR-Election1st: Backup 232002/04/28 14:25:52 OSPF: DR-Election1st: DR 212002/04/28 14:25:52 OSPF: PacketDD: Negotiation done (Slave). -8- r1收到r2(23)发过来的hello数据包,交换信息后选举DR,由于本身21是DR 了,所以 只选举了BDR就好了。这时在r1上就能看到r2了。r1_ospfd# sh ip ospf neig Neighbor ID Pri State Dead Time Address InterfaceRXmtL RqstL DBsmL23 1 Full/Backup 00:00:3723 eth0:21 0 0 0检验其它信息r1_ospfd# sh ip ospf database OSPF Router with ID (21)Router Link States (Area )Link ID ADV RouterAgeSeq# CkSumLink count21 21 1259 0x80000008 0x534e 123 23 1265 0x80000006 0x534a 1 Net Link States (Area )Link ID ADV RouterAgeSeq# CkSum23 23 1265 0x80000001 0x5a5ar1_ospfd# sh ip ospf int eth0eth0 is up, line protocol is upInternet Address 21/24, Area Router ID 21, Network Type BROADCAST, Cost: 10Transmit Delay is 1 sec, State DR, Priority 1 Designated Router (ID) 21, Interface Address 21 Backup Designated Router (ID) 23, Interface Address 23Timer intarvals configured, Hello 10, Dead 40, Wait 40, Retransmit 5Hello due in 00:00:01Neighbor Count is 1, Adjacent neighbor count is 1和前面的输出信息相比,发生了很多变化,两台路由器已经相互识别 了。OSPF不象RIP一样,每隔30秒 给所有的邻居广播一次完整的路由表,而是通过IP多目组播地址每隔10秒发送一个很小的hello 数据包来维护邻居关系,当链路发生变化的时候,才重新计算。拔掉两台机器连接的网线,看ospfd.log的记录: -8- 2002/04/28 16:25:53 OSPF: make_hello: options: 2, int: eth0:212002/04/28 16:25:57 OSPF: Packet 23 Hello:RECV: Options *|*|-|-|-|-|E|*2002/04/28 16:26:03 OSPF: make_hello: options: 2, int: eth0:212002/04/28 16:26:13 OSPF: make_hello: options: 2, int: eth0:212002/04/28 16:26:23 OSPF: make_hello: options: 2, int: eth0:21 2002/04/28 16:26:33 OSPF: make_hello: options: 2, int: eth0:212002/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/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: 1 2002/04/28 16:26:37 OSPF: ospf_check_abr_status(): areas_act_attached: 1 2002/04/28 16:26:37 OSPF: nsm_change_status(): scheduling new router-LSA origination2002/04/28 16:26:37 OSPF: DR-Election1nd: Backup 2002/04/28 16:26:37 OSPF: DR-Election1nd: DR 212002/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/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: Timerrouter-LSA: (router-LSA Refresh expire) 2002/04/28 16:26:37 OSPF: counting fully adjacent virtual neighbors in area 2002/04/28 16:26:37 OSPF: there are 0 of them 2002/04/28 16:26:37 OSPF: SPF: calculation timer scheduled 2002/04/28 16:26:37 OSPF: SPF: calculation timer delay = 5 2002/04/28 16:26:37 OSPF: ospf_flood_through_interface(): considering int eth0:212002/04/28 16:26:37 OSPF: ospf_flood_through_interface(): considering nbr 21 2002/04/28 16:26:42 OSPF: SPF: Timer (SPF calculation expire) 2002/04/28 16:26:42 OSPF: ospf_spf_calculate: Start2002/04/28 16:26:42 OSPF: ospf_spf_calculate: running Dijkstra for area 2002/04/28 16:26:42 OSPF: SPF Result: 0 R 21 2002/04/28 16:26:42 OSPF: = OSPF routing table = 2002/04/28 16:26:42 OSPF: = 2002/04/28 16:26:42 OSPF: ospf_process_stub():processing stubs for area 2002/04/28 16:26:42 OSPF: ospf_process_stub():processing router LSA, id: 212002/04/28 16:26:42 OSPF: ospf_process_stub(): we have

温馨提示

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

评论

0/150

提交评论