Use zebra for OSPF experiments

Source: Internet
Author: User

Use zebra for OSPF experiments
Keyword: Zebra
OSPF (Open Shortest Path First) routing protocol is a link-state technology. It 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> zebra-d

Enter Zebra to set IP

Shell_1> Telnet localhost 2601
Password:
Router> en
Password:
Router # conf t
Router (config) # hostname r1
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 settings of the first machine

Shell_1> ospfd-d
Shell_1> Telnet localhost 2604
Password:
Ospfd> en
Ospfd # conf t
Ospfd (config) # hostname r1_ospfd! Change the name to recognize it.
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:

R1_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 router routing table ====================

============= OSPF external routing table ================

R1_ospfd # SH ip OSPF Database

OSPF 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 1

R1_ospfd # SH ip OSPF int eth0
Eth0 is up, line protocol is up

Internet 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

Then we can view the debug information in shell.

Shell_1> tail-F/usr/local/etc/ospfd. Log
------------------------------ 8 <---------------------------------------
2002/04/28 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: Options: 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 that the router sent 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.

Settings for the second Server

The previous Initialization is the same as the first one, but the name is set to R2 to facilitate identification, and the IP address is set to 192.168.5.123/24.

Go to the OSPF settings of the second Machine

Shell_2> ospfd-d
Shell_2> Telnet localhost 2604
Password:
Ospfd> en
Ospfd # conf t
Ospfd (config) # hostname r2_ospfd
R2_ospfd (config) # 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 that the tail-F/usr/local/etc/ospfd. log of the first machine outputs the following information:

------------------------------ 8 <---------------------------------------
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
14:25:52 OSPF: couldn't find any VL to associate the packet
2002/04/28 14:25:52 OSPF: DR-election [1st]: Backup 192.168.5.123
2002/04/28 14:25:52 OSPF: DR-election [1st]: Dr 192.168.5.121
2002/04/28 14:25:52 OSPF: Packet [DD]: negotiation done (slave ).
------------------------------ 8 <---------------------------------------

R1 received the hello packet sent by R2 (192.168.5.123). After the information was exchanged, the DR was elected. Because 192.168.5.121 is Dr, only BDR is elected. Now we can see R2.

R1_ospfd # SH ip OSPF neig

Neighbor 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

Test Other information

R1_ospfd # SH ip OSPF Database

OSPF 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 0x80000008 0x534e 1
192.168.5.123 192.168.5.123 1265 0x80000006 0x534a 1

Net link states (area 0.0.0.0)

Link ID adv router age seq # cksum
192.168.5.123 192.168.5.123 1265 0x80000001 0x5a5a

R1_ospfd # SH ip OSPF int eth0
Eth0 is up, line protocol is up

Internet 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
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 identified 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 cable connected to the two machines and check the ospfd. log record:

------------------------------ 8 <---------------------------------------
2002/04/28 16:25:53 OSPF: make_hello: Options: 2, INT: eth0: 192.168.5.121
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: ospf_check_abr_status (): Start
2002/04/28 16:26:37 OSPF: ospf_check_abr_status (): looked through areas
2002/04/28 16:26:37 OSPF: ospf_check_abr_status (): 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: 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 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: ospf_check_abr_status (): looked through areas
2002/04/28 16:26:37 OSPF: ospf_check_abr_status (): 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: 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
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: 192.168.5.121

2002/04/28 16:26:37 OSPF: ospf_flood_through_interface (): 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: ospf_spf_calculate: Running Dijkstra for area 0.0.0.0
2002/04/28 16:26:42 OSPF: SPF result: 0 [R] 192.168.5.121
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 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_intra_add_stub (): processing route to 192.168.5.0/24

2002/04/28 16:26:42 OSPF: ospf_intra_add_stub (): 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: ospf_intra_add_stub (): this network is on this Router
2002/04/28 16:26:42 OSPF: ospf_intra_add_stub (): 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: ospf_ia_routing (): Start
2002/04/28 16:26:42 OSPF: ospf_ia_routing (): 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 free
2002/04/28 16:26:42 OSPF: SPF: Calculation complete
------------------------------ 8 <---------------------------------------

We can see that R1 generates an LSA package and notifies other routers. Because the network only has itself, we can select ourselves as the dr. The same is true for R2. -

Article Source: http://www.diybl.com/course/6_system/linux/Linuxjs/2008929/146644.html

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.