Use Zebra for OSPF experiments

Source: Internet
Author: User

The OSPF (Open Shortest Path First) routing protocol, which uses Zebra for OSPF experiments, is a link-state technology and is the most widely used and optimal performance protocol in IGP, it solves the large and scalable network requirements that RIP cannot solve, and is suitable for large-scale networks. Zebra supports OSPFv2 and OSPFv3 (OSPF for IPv6, CISCO has not encapsulated it). Due to restrictions, the following OSPF verification is also performed under RedHat7.2 of two single NICs. Zebra uses the ospfd program to implement the OSPF routing function, but ospfd needs to obtain the interface information from the zebra program, so the zebra program must run before the ospfd program. Ospfd does not support multiple OSPF processes. We cannot specify OSPF process numbers. Initialize the first machine: shell_1> cd/usr/local/etc shell_1> cp zebra. conf. sample zebra. conf shell_1> cp ospfd. conf. sample ospfd. conf shell_1> enter zebra-d and set IPshell_1> telnet localhost 2601 Password: Router> en Password: Router # conf t Router (config) # hostname r1 (config) # int eth0 r1 (config-if) # ip address 192.168.5.121/24 r1 (config-if) # ctrl + z r1 # copy run start enter the ospf setting shell_1> ospfd-d shell_1> telne of the first machine T localhost 2604 Password: ospfd> en ospfd # conf t ospfd (config) # hostname r1_ospfd! Change the name to identify r1_ospfd (config) # router ospf! Start ospf r1_ospfd (config-router) # ospf router-id 192.168.5.121! Set router-id r1_ospfd (config-router) # network 192.168.5.0/24 area 0! The most important thing is to identify which IP addresses on the router are part of OSPF. For each network, we must identify the region of the network. Because we only have two machines and of course only one network, we only need to execute one network command. For our small network, even if ospf is configured, let's test it below: rw.ospfd (config-router) # ctrl + z r1_ospfd # sh ip ospf route =========== OSPF network routing table ============= N 192.168.5.0 /24 [10] area: 0.0.0.0 directly attached to eth0 ============= OSPF routing table ===================== ===== OSPF external routing table ========= rsf-ospfd # sh ip ospf databaseOSPF Router with ID (192.168.5.121) router Link States (Area 0.0.0.0) Link id adv Router Age Seq # CkSum Link count 192.168.5.121 192.168.5.121 126 0x80000002 0x8584 1r1_ospfd # sh ip ospf int eth0 eth0 is up, line protocol is upInternet Address 192.168.5.121/24, area 0.0.0.0 Router ID 192.168.5.121, Network Type BROADCAST, Cost: 10 Transmit Delay is 1 sec, State DR, Priority 1 Designated Router (ID) 192.168.5.121, Interface Address 192.168.5.121 No backup designated Router on this network Timer intarvals configured, Hello 10, Dead 40, Wait 40, Retransmit 5 Hello due in 00:00:07 Neighbor Count is 0, adjacent neighbor count is 0 because there are no other routers in the network, r1 selects itself as the DR (specified router. Zebra may have some problems with log processing, so that the use of log stdout cannot display a variety of debug information, so only files can be recorded, and you can use the tail command in shell to view. In addition, the debug command is different from the actual vro. R1_ospfd # debug ospf event r1_ospfd (config) # log file/usr/local/etc/ospfd. log and then we can view the debug information shell_1> tail-f/usr/local/etc/ospfd in shell. log 14:24:27 OSPF: make_hello: options: 2, int: eth0: 192.168.5.121 2002/04/28 14:24:37 OSPF: make_hello: options: 2, int: eth0: 192.168.5.121 2002/04/28 14:24:47 OSPF: make_hello: o Ptions: 2, int: eth0: 192.168.5.121 2002/04/28 14:24:57 OSPF: make_hello: options: 2, int: eth0: 192.168.5.121 2002/04/28 14:25:07 OSPF: make_hello: options: 2, int: eth0: 192.168.5.121 -------------------------------- 8 <--------------------------------------- we missed the initial information and saw the router send a hello packet every 10 seconds. Hello data packets are sent out through the multicast address 224.0.0.5. If we open debug ospf packet all, we can see it clearly. The initialization of the second machine is the same as that of the first machine, but the name is set to r2 to facilitate identification, and the IP address is set to 192.168.5.123/24. Set shell_2> ospfd-d shell_2> telnet localhost 2604 Password: ospfd> en ospfd # conf t ospfd (config) # hostname r2_ospfd r2_ospfd (config) on the second machine) # router ospf r2_ospfd (config-router) # ospf router-id 192.168.5.123 r2_ospfd (config-router) # network 192.168.5.0/24 area 0 after running the network command, we can see the tail-f/usr/local/etc/ospfd of the first machine. log output information: ---------------------------------- 8 <------------------------------------ --- 2002/04/28 14:25:51 OSPF: Packet 192.168.5.123 [Hello: RECV]: Options * |-| E | * 2002/04/28 14:25:51 OSPF: NSM [eth0: 192.168.5.121: 0.0.0.0]: start 2002/04/28 14:25:52 OSPF: make_hello: options: 2, int: eth0: 192.168.5.121 2002/04/28 14:25:52 OSPF: couldn't find any VL to associate the packet with 2002/04/28 14:25:52 OSPF: DR-Election [1st]: Backup 192.168.5.123 2002/04/28 14:25:52 OSPF: DR-El Ection [1st]: DR 192.168.5.121 2002/04/28 14:25:52 OSPF: Packet [DD]: Negotiation done (Slave ). ------------------------------ 8 <r1 receives the hello packet sent by r2 (192.168.5.123). After information is exchanged, the DR is elected. Because 192.168.5.121 is DR, only BDR is elected. Now we can see R2. R1_ospfd # sh ip ospf neigNeighbor ID Pri State Dead Time Address Interface RXmtL RqstL DBsmL 192.168.5.123 1 Full/Backup 00:00:37 192.168.5.123 eth0: 192.168.5.121 0 0 0 check other information r1_ospfd # sh ip ospf databaseOSPF Router with ID (192.168.5.121) Router Link States (Area 0.0.0.0) link id adv Router Age Seq # CkSum Link count 192.168.5.121 192.168.5.121 1259 0 0x80000008 0x534e 1 192.168.5.123 192.168.5.123 1265 0x80000006 0x534a 1Net Link States (Area 0.0.0.0) Link id adv Router Age Seq # CkSum 192.168.5.123 192.168.5.123 1265 0x80000001 0x5a5ar1_ospfd # sh ip ospf int eth0 eth0 is up, line protocol is upInternet Address 192.168.5.121/24, Area 0.0.0.0 Router ID 192.168.5.121, Network Type BROADCAST, Cost: 10 Transmit Delay is 1 sec, State DR, Priority 1 Designated Router (ID) 192.168.5.121, interface adsid Ss 192.168.5.121 Backup Designated Router (ID) 192.168.5.123, Interface Address 192.168.5.123 Timer intarvals configured, Hello 10, Dead 40, Wait 40, Retransmit 5 Hello due in 00:00:01 Neighbor Count is 1, adjacent neighbor count is 1. Compared with the previous output information, the two routers have recognized each other. Unlike RIP, OSPF broadcasts a complete route table to all neighbors every 30 seconds, instead, a small hello packet is sent every 10 seconds at the IP address 224.0.0.5 to maintain the neighbor relationship. When the link changes, it is re-computed. Unplug the network cables connected to the two machines and check the ospfd. log records: -------------------------------- 8 <20172002/04/28 16:25:53 OSPF: make_hello: options: 2, int: eth0: 192.168.5.121 2002/04/28 16:25:57 OSPF: Packet 192.168.5.123 [Hello: RECV]: options * |-| E | * 2002/04/28 16:26:03 OSPF: make_hello: options: 2, int: eth0: 192.168.5.121 2002/04/28 16:26:13 OSPF: make_hello: options: 2, int: eth0: 192.168. 5.121 2002/04/28 16:26:23 OSPF: make_hello: options: 2, int: eth0: 192.168.5.121 2002/04/28 16:26:33 OSPF: make_hello: options: 2, int: eth0: 192.168.5.121 2002/04/28 16:26:37 OSPF: Success (): start 2002/04/28 16:26:37 OSPF: ospf_check_abr_status (): looked through areas 2002/04/28 16:26:37 OSPF: Pull (): bb_configured: 1 2002/04/28 16:26:37 OSPF: ospf_check_abr_status (): Bb_act_attached: 1 2002/04/28 16:26:37 OSPF: routing (): areas_configured: 1 2002/04/28 16:26:37 OSPF: routing (): routing: 1 2002/04/28 16:26:37 OSPF: nsm_change_status (): scheduling new router-LSA origination 2002/04/28 16:26:37 OSPF: DR-Election [1nd]: Backup 0.0.0.0 2002/04/28 16:26:37 OSPF: DR-Election [1nd]: DR 192.168.5.121 2002/04/28 16:26:37 OSPF: ospf _ Check_abr_status (): Start 2002/04/28 16:26:37 OSPF: Pull (): looked through areas 2002/04/28 16:26:37 OSPF: Pull (): bb_configured: 1 2002/04/28 16:26:37 OSPF: Pull (): bb_act_attached: 1 2002/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: Timer [router-LSA]: (router-LSA Refresh expire) 2002/04/28 16:26:37 OSPF: counting fully adjacent virtual neighbors in area 0.0.0.0 2002/04/28 16:26:37 OSPF: there are 0 of them limit 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: decrypt (): considering int eth0: 192.168.5.121 2002/ 04/28 16:26:37 OSPF: Begin (): considering nbr 192.168.5.121 2002/04/28 16:26:42 OSPF: SPF: Timer (SPF calculation expire) 2002/04/28 16:26:42 OSPF: ospf_spf_calculate: Start 2002/04/28 16:26:42 OSPF: accept: running Dijkstra for area 0.0.0.0 2002/04/28 16:26:42 OSPF: SPF Result: 0 [R] 192.168.5.121 2002/04/28 16:26:42 OSPF: ========= OSPF routing table ========== = 2002/04/28 16:26:42 OSPF: ========================================================== 2002/04/28 16:26:42 OSPF: merge (): processing stubs for area 0.0.0.0 2002/04/28 16:26:42 OSPF: ospf_process_stub (): processing router LSA, id: 192.168.5.121 2002/04/28 16:26:42 OSPF: ospf_process_stub (): we have 1 links to process 2002/04/28 16:26:42 OSPF: ospf_intra_add_stub (): Start 2002/04/28 16:26:42 OSPF: ospf_intr A_add_stub (): processing route to 192.168.5.0/24 2002/04/28 16:26:42 OSPF: Calculate (): calculated cost is 0 + 10 = 10 2002/04/28 16:26:42 OSPF: ospf_intra_add_stub (): installing new route 2002/04/28 16:26:42 OSPF: routing (): this network is on this router 2002/04/28 16:26:42 OSPF: routing (): the interface is eth0: 192.168.5.121 2002/04/28 16:26:42 OSPF: ospf_intra _ Add_stub (): Stop 2002/04/28 16:26:42 OSPF: children of V: 2002/04/28 16:26:42 OSPF: ospf_spf_calculate: Stop 2002/04/28 16:26:42 OSPF: Starting (): start 2002/04/28 16:26:42 OSPF: enabled (): not ABR, considering all areas 2002/04/28 16:26:42 OSPF: Pruning unreachable networks 2002/04/28 16:26:42 OSPF: Pruning unreachable routers 2002/04/28 16:26:42 OSPF: Route: Router Routing Table fr Ee 2002/04/28 16:26:42 OSPF: SPF: calculation complete -------------------------------- 8 <strong we can see that r1 generates an LSA package and notifies other routers that they only have their own vrouters. The same is true for r2.-

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.