Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Part IV of Experimental Design and troubleshooting OSPF configuration, Analysis and troubleshooting

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

1. Brief introduction of OSPF protocol

OSPF (Open shortest path first) is an internal gateway protocol. Unlike IGRP,OSPF, it is a classless link-state routing protocol rather than a classified distance vector protocol. OSPF is standardized and widely used in both public and private networks. Here is a brief introduction to the working process of link-state routing protocols, as follows:

Each router learns to activate directly connected networks.

Each router communicates with the directly connected router, sends Hello messages, and establishes a neighbor relationship.

Each router builds a LSA (Link-State Advertisement, link-state advertisement) that contains directly connected link states. Link-state advertisements (LSA) record all relevant routers, including the identification of neighboring routers, link type, bandwidth, and so on.

Each router floods link-state advertisements (LSA) to all neighboring routers, stores the LSA sent by neighboring routes locally, and then floods the received LSA to all its neighbors until all routers in the same area receive all LSA. Each router keeps all received copies of LSA in a local database, which is called a link-state database (LSDB,Link-State Database).

Each router executes the shortest path first (SPF) algorithm based on the local link-state database (LSDB), and takes this router as the root to generate a SPF tree. Based on this SPF tree, the shortest path to each network is calculated, and the final routing table is obtained.

2. Purpose of the experiment

Simply understand the following two basic knowledge points of OSPF.

Understand neighbor tables, topology tables, and routing tables

How does OSPF elect RID?

The calculation method of OSPF measure

3. Experimental topology

Description: there is no Fast Ethernet link from R1 to R3 by default, which will be used in the calculation of OPSF metrics later)

(1), routing table

R2#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/8 is variably subnetted, 5 subnets, 2 masks

O 10.2.0.2/32 [110/65] via 192.168.10.2, 00:04:11, Serial1/1

O 10.5.0.2/32 [110/65] via 192.168.20.2, 00:02:21, Serial1/0

C 10.6.0.0/16 is directly connected, Loopback0

O 10.11.0.2/32 [110/65] via 192.168.50.2, 00:00:31, Serial1/3

O 10.12.0.2/32 [110/65] via 192.168.40.2, 00:01:26, Serial1/2

192.168.10.0/30 is subnetted, 1 subnets

C 192.168.10.0 is directly connected, Serial1/1

192.168.20.0/30 is subnetted, 1 subnets

C 192.168.20.0 is directly connected, Serial1/0

192.168.30.0/30 is subnetted, 1 subnets

O 192.168.30.0 [110/128] via 192.168.40.2, 00:00:31, Serial1/2

[110/128] via 192.168.50.2, 00:00:31, Serial1/3

192.168.40.0/30 is subnetted, 1 subnets

C 192.168.40.0 is directly connected, Serial1/2

192.168.50.0/30 is subnetted, 1 subnets

C 192.168.50.0 is directly connected, Serial1/3

As in the red section above, all loopback interfaces in OSPF are automatically declared as 32-bit host routes "/ 32". If you want to display the actual subnet mask of the loopback interface, you can use the following command on the loopback port:

Ip ospf network point-to-point

Let's take a look at the actual results, which are shown as follows when you enter this command on the loopback0 ports on R1 and R2:

R2#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/8 is variably subnetted, 5 subnets, 2 masks

O 10.2.0.0/16 [110/65] via 192.168.10.2, 00:00:11, Serial1/1

O 10.5.0.2/32 [110/65] via 192.168.20.2, 00:36:53, Serial1/0

C 10.6.0.0/16 is directly connected, Loopback0

O 10.11.0.2/32 [110/65] via 192.168.50.2, 00:35:03, Serial1/3

O 10.12.0.2/32 [110/65] via 192.168.40.2, 00:35:57, Serial1/2

-slightly-

R1#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/8 is variably subnetted, 5 subnets, 2 masks

C 10.2.0.0/16 is directly connected, Loopback0

O 10.5.0.2/32 [110/129] via 192.168.10.1, 00:36:39, Serial0/0

O 10.6.0.0/16 [110/65] via 192.168.10.1, 00:00:38, Serial0/0

O 10.11.0.2/32 [110/129] via 192.168.10.1, 00:34:49, Serial0/0

O 10.12.0.2/32 [110/129] via 192.168.10.1, 00:35:48, Serial0/0

-slightly-

(2), neighbor table

R2#show ip ospf neighbor

Neighbor ID Pri State Dead Time Address Interface

10.5.0.2 FULL/-00:00:34 192.168.20.2 Serial1/0

10.2.0.2 0 FULL/-00:00:31 192.168.10.2 Serial1/1

10.12.0.2 0 FULL/-00:00:34 192.168.40.2 Serial1/2

10.11.0.2 FULL/-00:00:33 192.168.50.2 Serial1/3

Neighbor ID: neighbor's RID, as you can see from the output above, the RID of R3 is 10.5.0.2, the RID of R1 is 10.2.0.2, the RID of R5 is 10.12.0.2, and the RID of R4 is 10.11.0.2, which establishes neighbor relationships from different interfaces.

Pir: the priority of the OSPF neighbor interface, the interface priority is used for the election of DR and BDR, the default priority of the Ethernet interface is 1, and the serial line does not need to elect DR and BDR, so the priority of the serial line is 0, that is, 0 means not participating in the election.

State: the status of the neighbor router. FULL represents the adjacency established. "/" is followed by the elected DR or BDR identity. Because the serial line does not require an election, it is "-".

Dead time: the default time of death is 4 times the time of hello, or 40 seconds. The time of death is a countdown and when the timer is 0, the neighbor is deleted.

Address: the IP address of the neighbor's directly connected interface.

Interface: the output interface of this route.

(3), topology table

R2#show ip ospf database

OSPF Router with ID (10.6.0.2) (Process ID 1)

Router Link States (Area 0)

Link ID ADV Router Age Seq# Checksum Link count

10.6.0.2 10.6.0.2 54 0x8000000c 0x00997e 9

10.5.0.2 10.5.0.2 393 0x80000005 0x00650d 3

10.12.0.2 10.12.0.2 299 0x80000007 0x0099d6 5

10.11.0.2 10.11.0.2 285 0x80000007 0x004419 5

10.2.0.2 10.2.0.2 19 0x80000006 0x00a5ea 3

(4) how does OSPF elect Router ID?

Router ID, referred to as RID, is used to uniquely identify each router in the OSPF network. If two OSPF routers have the same RID, they cannot establish an adjacency with each other. RID is in the form of an IP address, so what is the order in which RID is elected? Let's first take a look at the RID of R1:

R1#show ip protocols

Routing Protocol is "ospf 1"

Outgoing update filter list for all interfaces is not set

Incoming update filter list for all interfaces is not set

Router ID 10.2.0.2

Number of areas in this router is 1. 1 normal 0 stub 0 nssa

Maximum path: 4

Routing for Networks:

192.168.10.0 0.0.0.255 area 0

0.0.0.0 255.255.255.255 area 0

Routing Information Sources:

Gateway Distance Last Update

10.2.0.2 110 00:07:07

10.5.0.2 110 00:13:21

10.6.0.2 110 00:07:43

10.11.0.2 110 00:11:34

10.12.0.2 110 00:11:48

Distance: (default is 110)

Let's manually configure the Router ID of R1:

R1#conf t

Enter configuration commands, one per line. End with CNTL/Z.

R1 (config) # route ospf 1

A.B.C.D OSPF router-id in IP address format

R1 (config-router) # route 20.20.20.20

R1 (config-router) # Reload or use "clear ip ospf process" command, for this to take effect

R1 (config-router) # end

R1#

% SYS-5-CONFIG_I: Configured from console by console

R1#clear ip ospf process

Reset ALL OSPF processes? [no]: y

R1#

01:24:01:% OSPF-5-ADJCHG: Process 1, Nbr 10.6.0.2 on Serial0/0 from FULL to DOWN, Neighbor Down: Adjacency forced to reset

01:24:01:% OSPF-5-ADJCHG: Process 1, Nbr 10.6.0.2 on Serial0/0 from FULL to DOWN, Neighbor Down: Interface down or detached

01:24:05:% OSPF-5-ADJCHG: Process 1, Nbr 10.6.0.2 on Serial0/0 from LOADING to FULL, Loading Done

Let's take another look at what happens to Route ID:

R1#show ip protocols

Routing Protocol is "ospf 1"

Outgoing update filter list for all interfaces is not set

Incoming update filter list for all interfaces is not set

Router ID 20.20.20.20

Number of areas in this router is 1. 1 normal 0 stub 0 nssa

-slightly-

From the example above, we can see that RID can be an IP address that does not exist, and RID is only used as the identity of the route and will not be used for addressing.

Another question we need to think about is, if you cancel the manual configuration of RID on R1 and shut down the loopback0 interface, what is the largest activated loopback interface IP at this time? Also, let's take a look at the experiment:

R1#conf t

Enter configuration commands, one per line. End with CNTL/Z.

R1 (config) # route ospf 1

R1 (config-router) # no route 20.20.20.20

R1 (config-router) # int loopback0

R1 (config-if) # shutdown

R1 (config-if) #

% LINK-5-CHANGED: Interface Loopback0, changed state to administratively down

% LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to down

R1 (config-if) # end

R1#

% SYS-5-CONFIG_I: Configured from console by console

R1#clear ip ospf process

Reset ALL OSPF processes? [no]: y

R1#

01:36:48:% OSPF-5-ADJCHG: Process 1, Nbr 10.6.0.2 on Serial0/0 from FULL to DOWN, Neighbor Down: Adjacency forced to reset

01:36:48:% OSPF-5-ADJCHG: Process 1, Nbr 10.6.0.2 on Serial0/0 from FULL to DOWN, Neighbor Down: Interface down or detached

R1#show ip protocols

Routing Protocol is "ospf 1"

Outgoing update filter list for all interfaces is not set

Incoming update filter list for all interfaces is not set

Router ID 192.168.10.2

Number of areas in this router is 1. 1 normal 0 stub 0 nssa

Maximum path: 4

Routing for Networks:

192.168.10.0 0.0.0.255 area 0

0.0.0.0 255.255.255.255 area 0

Routing Information Sources:

Gateway Distance Last Update

Distance: (default is 110)

R1#

01:36:56:% OSPF-5-ADJCHG: Process 1, Nbr 10.6.0.2 on Serial0/0 from LOADING to FULL, Loading Done

As the example above illustrates a problem, if the RID is not manually specified, the router uses the maximum activated loopback interface IP as the RID by default, but it should be noted that the maximum is not the largest interface number, but the largest IP address. Another problem is that if the router does not have an active loopback interface, the router chooses the IP address of the largest active physical interface as the RID by default, and the physical interface 192.168.10.2 is selected as above.

(5) how to calculate the OSPF measure?

The metric used in OSPF is "Cost", the default OSPF uses 100Mb/s as the reference bandwidth, uses 100Mb/s divided by the actual link bandwidth, and the resulting value is rounded (1 for results less than 0), which is the cost.

For example, the bandwidth of a serial line is 1.544m and that of Fast Ethernet is 100m, that is, as follows:

Cost of serial lines = 100M/1.544 ≈ 64 (rounded and not rounded)

Fast Ethernet line cost = 100M/100M=1

Continue the above experiment, while we add a Fast Ethernet link to R1 and R3, then configure it accordingly, and take a look at the verification of R3:

R3#show ip route ospf

10.0.0.0/8 is variably subnetted, 5 subnets, 2 masks

O 10.2.0.0 [110/2] via 172.16.50.1, 00:00:15, FastEthernet0/0

O 10.6.0.0 [110/65] via 192.168.20.1, 00:10:00, Serial0/3

O 10.11.0.2 [110/129] via 192.168.20.1, 00:10:00, Serial0/3

O 10.12.0.2 [110/129] via 192.168.20.1, 00:10:00, Serial0/3

192.168.10.0/30 is subnetted, 1 subnets

O 192.168.10.0 [110/65] via 172.16.50.1, 00:00:15, FastEthernet0/0

192.168.30.0/30 is subnetted, 1 subnets

O 192.168.30.0 [110/192] via 192.168.20.1, 00:10:00, Serial0/3

192.168.40.0/30 is subnetted, 1 subnets

O 192.168.40.0 [110/128] via 192.168.20.1, 00:10:00, Serial0/3

192.168.50.0/30 is subnetted, 1 subnets

O 192.168.50.0 [110/128] via 192.168.20.1, 00:10:00, Serial0/3

We can see that [110amp 2] is the default administrative distance of OSPF, 2 is the cost, and the cost to 10.2.0.0 amp 16 is 2, that is, the cost of Fast Ethernet plus the cost of the loopback interface, because the bandwidth of the loopback interface is very high, the removal with 100m will be less than 0, so take 1. Another 65 of 192.168.10.0 [110lap65] is obtained through a serial line cost of 64, plus an Ethernet cost of 1.

Now let's turn off the fast and network interface of R3 and look at the routing table of R3:

R3 (config) # int fa0/0

R3 (config-if) # shutdown

R3 (config-if) #

% LINK-5-CHANGED: Interface FastEthernet0/0, changed state to administratively down

% LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to down

00:17:25:% OSPF-5-ADJCHG: Process 1, Nbr 10.2.0.2 on FastEthernet0/0 from FULL to DOWN, Neighbor Down: Interface down or detached

End

R3#

% SYS-5-CONFIG_I: Configured from console by console

R3#show ip route ospf

10.0.0.0/8 is variably subnetted, 5 subnets, 2 masks

O 10.2.0.0 [110/129] via 192.168.20.1, 00:00:01, Serial0/3

O 10.6.0.0 [110/65] via 192.168.20.1, 00:17:06, Serial0/3

O 10.11.0.2 [110/129] via 192.168.20.1, 00:17:06, Serial0/3

O 10.12.0.2 [110/129] via 192.168.20.1, 00:17:06, Serial0/3

192.168.10.0/30 is subnetted, 1 subnets

O 192.168.10.0 [110/128] via 192.168.20.1, 00:00:01, Serial0/3

192.168.30.0/30 is subnetted, 1 subnets

O 192.168.30.0 [110/192] via 192.168.20.1, 00:17:06, Serial0/3

192.168.40.0/30 is subnetted, 1 subnets

O 192.168.40.0 [110/128] via 192.168.20.1, 00:17:06, Serial0/3

192.168.50.0/30 is subnetted, 1 subnets

O 192.168.50.0 [110/128] via 192.168.20.1, 00:17:06, Serial0/3

At this point, you will find that the data has to go through the serial line, and the cost has become 129. And 192.168.10.0 [110swap 128] also becomes 128. In fact, the reference bandwidth of the calculated cost can be modified by the following methods:

R3 (config) # route ospf 1

R3 (config-router) # auto-cost

R3 (config-router) # auto-cost reference-bandwidth 10000

% OSPF: Reference bandwidth is changed.

Please ensure reference bandwidth is consistent across all routers.

R3 (config-router) # end

R3#

% SYS-5-CONFIG_I: Configured from console by console

When you have modified the reference bandwidth of all routers, look at the routing table of R3:

R3#show ip route ospf

10.0.0.0/8 is variably subnetted, 5 subnets, 2 masks

O 10.2.0.0 [110/12953] via 192.168.20.1, 00:00:28, Serial0/3

O 10.6.0.0 [110/6477] via 192.168.20.1, 00:02:42, Serial0/3

O 10.11.0.2 [110/12953] via 192.168.20.1, 00:00:28, Serial0/3

O 10.12.0.2 [110/12953] via 192.168.20.1, 00:00:28, Serial0/3

O 172.16.0.0 [110/13052] via 192.168.20.1, 00:00:28, Serial0/3

192.168.10.0/30 is subnetted, 1 subnets

O 192.168.10.0 [110/12952] via 192.168.20.1, 00:00:28, Serial0/3

192.168.30.0/30 is subnetted, 1 subnets

O 192.168.30.0 [110/19428] via 192.168.20.1, 00:00:18, Serial0/3

192.168.40.0/30 is subnetted, 1 subnets

O 192.168.40.0 [110/12952] via 192.168.20.1, 00:00:28, Serial0/3

192.168.50.0/30 is subnetted, 1 subnets

O 192.168.50.0 [110/12952] via 192.168.20.1, 00:00:28, Serial0/3

The cost is also calculated using an example of 12953 going to the 10.2.0.0 Universe 16 network:

Cost of serial link between R3 and R2 = 10000M/1.544M ≈ 6476

Cost of serial link between R2 and R1 = 10000M/1.544M ≈ 6476

Cost of loopback0 interface on R1 = 10000M/8000M ≈ 1

The total cost of the three lines is 12953, and the cost of other ports is the same.

Finally, you can view the OSPF information of an interface by using the following methods:

R3#show ip ospf int se0/3

Serial0/3 is up, line protocol is up

Internet address is 192.168.20.2/30, Area 0

Process ID 1, Router ID 10.5.0.2, Network Type POINT-TO-POINT, Cost: 6476

Transmit Delay is 1 sec, State POINT-TO-POINT, Priority 0

No designated router on this network

No backup designated router on this network

Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5

Hello due in 00:00:01

Index 2/2, flood queue length 0

Next 0x0 (0) / 0x0 (0)

Last flood scan length is 1, maximum is 1

Last flood scan time is 0 msec, maximum is 0 msec

Neighbor Count is 1, Adjacent neighbor count is 1

Adjacent with neighbor 10.6.0.2

Suppress hello for 0 neighbor (s)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report