SoFunction
Updated on 2025-04-06

Discuss the network configuration of OSPF

When to use a complete IP address, and when to use a network address?

OSPF is a link state protocol, mainly the interface state (such as ip address, mask, Hello time...). These information are

During the process of establishing adjency between Routers, LSAs will be exchanged until the same area converges, all Routers have the same link state database, and then use itself as the root to establish SPF tree. Finally, after calculating the changes of any interface in the route based on SPF, it will be updated.

Let's take a look at the process of OSPF execution: (Simple example)

int s1
ip add 10.1.1.1 255.255.255.0 (10.1.1.1/24)

int s2
ip add 172.2.0.1 255.255.255.0 (172.2.0.1/24)

int s3
ip add 172.3.0.1 255.255.0.0 (172.3.0.1/16)

int s4
ip add 172.4.0.1 255.255.0.0 (172.4.0.1/16)

route ospf 10
network 10.1.1.1 0.0.0.0 area 0
network 172.2.0.0 0.0.255.255 area 0

When entering OSPF 10, OSPF first executes network 10.1.1.1 0.0.0.0, finds the interface address, matches s0, allocates to Area 0, and then executes network 172.2.0.0.0.0.0.255.255 aera 0, matches s2->Area 0, and finally the information we see on other Routers is:

172.16.0.0/24 is subnetted, 1 subnets
O 172.16.0.0 [110/128] via 192.168.0.1, 00:00:00, Serialx
10.0.0.0/24 is subnetted, 1 subnets
O 10.1.1.0 [110/74] via 192.168.0.1, 00:00:05, Serialx

In the following, you can see that the submask is 24, and the inverse mask configured in the network is ignored. Why?

Let's see what the results will happen after adding a new network?
route ospf 10
network 10.1.1.1 0.0.0.0 area 0
network 172.2.0.0 0.0.255.255 area 0
network 172.0.0.0 0.255.255.255 area 1
network 0.0.0.0 0.0.0.0 area 2
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
O IA 172.3.0.0/16 [110/933] via 192.168.0.1, 00:00:05, Serialx
O IA 172.4.0.0/16 [110/933] via 192.168.0.1, 00:00:02, Serialx
172.16.0.0/24 is subnetted, 1 subnets
O 172.16.0.0 [110/128] via 192.168.0.1, 00:00:10, Serialx
10.0.0.0/24 is subnetted, 1 subnets
O 10.1.1.0 [110/74] via 192.168.0.1, 00:00:05, Serialx

Here s3 and s4 are both in Area 1 (marked as IA mask 16).

Summary: I have actually gone around with you, just to understand it more thoroughly. The actual network scope has been explained in the interface mask. This is clearly marked in all Routers' Link state databases and will not change due to OSPF's network configuration. In OSPF network configuration, inverse mask only serves to specify the network scope in the OSPF process of this Router. For example, network 172.0.0.0 0.255.255.255.255 specifies the range from 172.0.0.0 to 172.255.255.255. All interfaces in the sub-range are assigned to Area 1, and finally all other addresses are assigned to Area 2.

If in the Stub Area, without a Loopback interface, it can even be simply configured as

router ospf 20
network 0.0.0.0 255.255.255.255 area x

This way, there is no need to specify the network range separately.

Among other types, it is recommended to configure interface ip address, 0.0.0.0, that is, precise matching to prevent errors from occurring. like:

network 10.1.1.1 0.0.0.0 area 0 Article entry: csh     Editor in charge: csh