OSPF summarization is a routing feature that networking vendors like Cisco, Juniper, Palo Alto Networks, and Huawei support. OSPF summarization help reduce the size of the routing tables and OSPF routing traffic across the OSPF routing domain. This technique can be applied to both inter-area and external routes.

What is OSPF Summarization?

OSPF summarization is a feature that is used to reduce or summarize intra-area/inter-area routes of an area or external routes redistributed by an AS Boundary Router (ASBR) into OSPF.

In the rest of this guide, we use the network diagram in Figure 1. The network consists of five routers. Two routers are in EIGRP 12 autonomous system, and four routers are included in the OSPF routing domain.

 

Figure 1 – Network topology of the routing domain used in this tutorial

Here are the initial configurations of the routers.

Router R1

Router(config)# hostname R1
R1(config)# 
R1(config)# interface loopback 0
R1(config-if)# ip address 10.0.0.1 255.255.255.0
R1(config-if)# 
R1(config-if)# interface loopback 1
R1(config-if)# ip address 10.0.1.1 255.255.255.0
R1(config-if)# 
R1(config-if)# interface loopback 2
R1(config-if)# ip address 10.0.2.1 255.255.255.0
R1(config-if)# 
R1(config-if)# interface loopback 3
R1(config-if)# ip address 10.0.3.1 255.255.255.0
R1(config-if)# 
R1(config-if)# interface GigabitEthernet0/2
R1(config-if)# ip address 10.0.12.1 255.255.255.0
R1(config-if)# no shutdown
R1(config-if)# 
R1(config-if)# router eigrp 12
R1(config-router)# network 10.0.0.0
R1(config-router)# no auto-summary

Router R2

Router(config)# hostname R2
R2(config)# 
R2(config)# interface GigabitEthernet0/1
R2(config-if)# ip address 10.0.12.2 255.255.255.0
R2(config-if)# no shutdown
R2(config-if)# 
R2(config-if)# interface GigabitEthernet0/3
R2(config-if)# ip address 10.0.123.2 255.255.255.0
R2(config-if)# no shutdown
R2(config-if)# 
R2(config-if)# router eigrp 12
R2(config-router)# network 10.0.12.2 0.0.0.0
R2(config-router)# no auto-summary
R2(config-router)# 
R2(config-router)# router ospf 1
R2(config-router)# router-id 2.2.2.2
R2(config-router)# network 10.0.123.2 0.0.0.0 area 23
R2(config-router)# redistribute eigrp 12 subnets

Router R3

Router(config)# hostname R3
R3(config)# 
R3(config)# interface GigabitEthernet0/2
R3(config-if)# ip address 10.0.123.3 255.255.255.0
R3(config-if)# no shutdown
R3(config-if)# 
R3(config-if)# interface GigabitEthernet0/4
R3(config-if)# ip address 10.0.134.3 255.255.255.0
R3(config-if)# no shutdown
R3(config-if)# 
R3(config-if)# interface GigabitEthernet0/5
R3(config-if)# ip address 10.0.35.3 255.255.255.0
R3(config-if)# no shutdown
R3(config-if)# 
R3(config-if)# router ospf 1
R3(config-router)# router-id 3.3.3.3
R3(config-router)# network 10.0.123.3 0.0.0.0 area 23
R3(config-router)# network 10.0.134.3 0.0.0.0 area 0
R3(config-router)# network 10.0.35.3 0.0.0.0 area 35

Router R4

Router(config)# hostname R4
R4(config)# 
R4(config)# interface loopback 0
R4(config-if)# ip ospf network point-to-point
R4(config-if)# ip address 10.0.20.4 255.255.255.0
R4(config-if)# 
R4(config-if)# interface loopback 1
R4(config-if)# ip ospf network point-to-point
R4(config-if)# ip address 10.0.21.4 255.255.255.0
R4(config-if)# 
R4(config-if)# interface loopback 2
R4(config-if)# ip ospf network point-to-point
R4(config-if)# ip address 10.0.22.4 255.255.255.0
R4(config-if)# 
R4(config-if)# interface loopback 3
R4(config-if)# ip ospf network point-to-point
R4(config-if)# ip address 10.0.23.4 255.255.255.0
R4(config-if)# 
R4(config-if)# interface GigabitEthernet0/3
R4(config-if)# ip address 10.0.134.4 255.255.255.0
R4(config-if)# no shutdown
R4(config-if)# 
R4(config-if)# router ospf 1
R4(config-router)# router-id 4.4.4.4
R4(config-router)# network 10.0.0.0 0.0.255.255 area 0

Router R5

Router(config)# hostname R5
R5(config)# 
R5(config)# interface GigabitEthernet0/3
R5(config-if)# ip address 10.0.35.5 255.255.255.0
R5(config-if)# no shutdown
R5(config-if)# 
R5(config-if)# 
R5(config-if)# router ospf 1
R5(config-router)# router-id 5.5.5.5
R5(config-router)# network 10.0.35.5 0.0.0.0 area 35

Router R2 is redistributing EIGRP 12 routes into OSPF, as shown in the show ip route ospf command output below.

R3# show ip route ospf



omitted output


      10.0.0.0/8 is variably subnetted, 15 subnets, 2 masks
O E2     10.0.0.0/24 [110/20] via 10.0.123.2, 00:01:41, GigabitEthernet0/2
O E2     10.0.1.0/24 [110/20] via 10.0.123.2, 00:01:41, GigabitEthernet0/2
O E2     10.0.2.0/24 [110/20] via 10.0.123.2, 00:01:41, GigabitEthernet0/2
O E2     10.0.3.0/24 [110/20] via 10.0.123.2, 00:01:41, GigabitEthernet0/2
O E2     10.0.12.0/24 [110/20] via 10.0.123.2, 00:01:41, GigabitEthernet0/2
O        10.0.20.0/24 [110/2] via 10.0.134.4, 00:01:52, GigabitEthernet0/4
O        10.0.21.0/24 [110/2] via 10.0.134.4, 00:01:52, GigabitEthernet0/4
O        10.0.22.0/24 [110/2] via 10.0.134.4, 00:01:52, GigabitEthernet0/4
O        10.0.23.0/24 [110/2] via 10.0.134.4, 00:01:52, GigabitEthernet0/4

How Does OSPF Summarization Work for Internal and External OSPF Routes?

Before discussing how OSPF summarization work with internal and external routes, we created two aggregate routes: 10.0.20.0/22 on R3 consolidating for area 0′ subnets 10.0.20.0/24, 10.0.21.0/24, 10.0.22.0/24, and 10.0.23.0/24, and 10.0.0.0/22 on R2 to condense external networks redistributed by R2 except subnet 10.0.12.0/24.

Summarizing internal OSPF routes can be done on Area Border Routers (ABRs) only. The ABR should at least have one route matching the summary route’s IP address.

The ABR creates an aggregate address for one or more routes in a particular area and advertises the summary route, instead of the area’s routes matching it, in Type 3 LSAs to all areas connected to that ABR.

For example, router R3 creates one LSA entry for the 10.0.20.0/22 summary route in the Type 3 LSAs associated with areas 23 and 35, as illustrated in the next show ip ospf database summary command output.

R3# show ip ospf database summary 10.0.20.0

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

                Summary Net Link States (Area 23)

  LS age: 1441
  Options: (No TOS-capability, DC, Upward)
  LS Type: Summary Links(Network)
  Link State ID: 10.0.20.0 (summary Network Number)
  Advertising Router: 3.3.3.3
  LS Seq Number: 80000001
  Checksum: 0xD43F
  Length: 28
  Network Mask: /22
        MTID: 0         Metric: 2 


                Summary Net Link States (Area 35)

  LS age: 1441
  Options: (No TOS-capability, DC, Upward)
  LS Type: Summary Links(Network)
  Link State ID: 10.0.20.0 (summary Network Number)
  Advertising Router: 3.3.3.3
  LS Seq Number: 80000001
  Checksum: 0xD43F
  Length: 28
  Network Mask: /22
        MTID: 0         Metric: 2 

The ABR adds an OSPF intra-area routing table entry for the summary route with null0 as the exit interface in order to prevent possible routing loops, as you see in the routing table of R3.

R3# show ip route ospf


omitted output

      10.0.0.0/8 is variably subnetted, 16 subnets, 4 masks
O E2     10.0.0.0/24 [110/20] via 10.0.123.2, 00:31:25, GigabitEthernet0/2
O E2     10.0.1.0/24 [110/20] via 10.0.123.2, 00:31:25, GigabitEthernet0/2
O E2     10.0.2.0/24 [110/20] via 10.0.123.2, 00:31:25, GigabitEthernet0/2
O E2     10.0.3.0/24 [110/20] via 10.0.123.2, 00:31:25, GigabitEthernet0/2
O E2     10.0.12.0/24 [110/20] via 10.0.123.2, 00:31:25, GigabitEthernet0/2
O        10.0.20.0/22 is a summary, 00:31:25, Null0
O        10.0.20.0/25 [110/2] via 10.0.134.4, 00:27:22, GigabitEthernet0/4
O        10.0.21.0/24 [110/2] via 10.0.134.4, 00:31:25, GigabitEthernet0/4
O        10.0.22.0/24 [110/2] via 10.0.134.4, 00:31:25, GigabitEthernet0/4
O        10.0.23.0/24 [110/2] via 10.0.134.4, 00:31:25, GigabitEthernet0/4

In other words, the ABR announces the summary route using the Type 3 LSA of each area the router is attached to.

The default metric advertised with the summary route is the least metric among all metrics of the routes forming the OSPF summary IP prefix.

External OSPF routes can only be condensed on ASBRs only. Unlike internal routes, external route summaries get advertised using LSAs Type 5, as illustrated in the following show ip ospf database external command output.

R2# show ip ospf database external 10.0.0.0

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

                Type-5 AS External Link States

  LS age: 2
  Options: (No TOS-capability, DC, Upward)
  LS Type: AS External Link
  Link State ID: 10.0.0.0 (External Network Number )
  Advertising Router: 2.2.2.2
  LS Seq Number: 80000004
  Checksum: 0x147A
  Length: 36
  Network Mask: /22
        Metric Type: 2 (Larger than any link state path)
        MTID: 0 
        Metric: 20 
        Forward Address: 0.0.0.0
        External Route Tag: 0

How to Calculate an OSPF Route Summary without a Calculator?

Here are the steps to calculate a summary address and subnet mask for subnets 173.16.0.0/24, 173.16.0.0/24, 173.16.0.0/24, 173.16.0.0/24, and 173.16.0.0/24.

Step 1. Determine the common bits from the left between the IP addresses of the five subnets (after converting them to binary). The common bits must be contiguous and include the first bit from the left.

Subnet IP address Binary Value
173.16.0.0 10101101 00010000 00000000 00000000
173.16.1.0 10101101 00010000 00000001 00000000
173.16.2.0 10101101 00010000 00000010 00000000
173.16.3.0 10101101 00010000 00000011 00000000
173.16.4.0 10101101 00010000 00000100 00000000

The common bits are 10101101 00010000 00000(the first 21 bits from the left).

Step 2. Complete the 21 bits with eleven 0s to obtain a 32-bit value, and then convert this value to decimal format. Thus, the summarized route is 10101101 00010000 00000000 00000000 or 173.16.0.0 in decimal format.

Step 3. Calculate the subnet mask of the summary route. The subnet masks will have the value of all 1s in the first 21 bits and the value of all 0s in the rest of the mask. It is therefore 255.255.248.0.

How to Configure OSPF Summarization on Cisco IOS?

Configuring OSPF summarization is a simple task. You can accomplish this task using either the area range or summary-address command depending on whether to summarize internal or external routes.

Internal OSPF Route Summarization

To summarize a set of OSPF routes at an ABR, use the area number range ip_prefix subnet_mask command in router configuration mode, where number is the identifier of the area containing the routes to summarize, and ip_prefix/mask pair is the summary route’s IP address/subnet mask pair. Also, OSPF allows summarizing all the area’s routes or a part of them.

Besides, the command should be issued on ABRs. Using the area range command on a router connected to one area or multiple areas not including the backbone area is useless.

The area range advertise command is identical to the area range ip_prefix subnet_mask command. Using the area range not-advertise command instructs the router to filter out the routes matched by ip_prefix and subnet_mask.

This example advertises the 10.0.20.0/22 summary route from area 0 to OSPF areas connected to router R3.

R3(config)# router ospf 1
R3(config-router)# area 0 range 10.0.20.0 255.255.252.0

To verify the summary route, we use the show ip ospf database summary command to check that router R3 generates Type 3 LSAs of the 10.0.20.0/22 route for areas 23 and 35, and the show ip route command to ensure routers in areas connected to R3 except the source area receive the summary route.

Router R3

R3# show ip ospf database summary 10.0.20.0

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

                Summary Net Link States (Area 23)

  LS age: 471
  Options: (No TOS-capability, DC, Upward)
  LS Type: Summary Links(Network)
  Link State ID: 10.0.20.0 (summary Network Number)
  Advertising Router: 3.3.3.3
  LS Seq Number: 80000007
  Checksum: 0xC845
  Length: 28
  Network Mask: /22
        MTID: 0         Metric: 2 


                Summary Net Link States (Area 35)

  LS age: 471
  Options: (No TOS-capability, DC, Upward)
  LS Type: Summary Links(Network)
  Link State ID: 10.0.20.0 (summary Network Number)
  Advertising Router: 3.3.3.3
  LS Seq Number: 80000007
  Checksum: 0xC845
  Length: 28
  Network Mask: /22
        MTID: 0         Metric: 2

Router R2

R2# show ip route ospf


omitted output

      10.0.0.0/8 is variably subnetted, 11 subnets, 3 masks
O IA     10.0.20.0/22 [110/3] via 10.0.123.3, 00:10:41, GigabitEthernet0/3
O IA     10.0.35.0/24 [110/2] via 10.0.123.3, 00:33:31, GigabitEthernet0/3
O IA     10.0.134.0/24 [110/2] via 10.0.123.3, 00:33:31, GigabitEthernet0/3

Router R5

R5# show ip route ospf


omitted output

      10.0.0.0/8 is variably subnetted, 10 subnets, 3 masks
O E2     10.0.0.0/24 [110/20] via 10.0.35.3, 00:34:05, GigabitEthernet0/3
O E2     10.0.1.0/24 [110/20] via 10.0.35.3, 00:34:05, GigabitEthernet0/3
O E2     10.0.2.0/24 [110/20] via 10.0.35.3, 00:34:05, GigabitEthernet0/3
O E2     10.0.3.0/24 [110/20] via 10.0.35.3, 00:34:05, GigabitEthernet0/3
O E2     10.0.12.0/24 [110/20] via 10.0.35.3, 00:34:05, GigabitEthernet0/3
O IA     10.0.20.0/22 [110/3] via 10.0.35.3, 00:11:20, GigabitEthernet0/3
O IA     10.0.123.0/24 [110/2] via 10.0.35.3, 00:34:10, GigabitEthernet0/3
O IA     10.0.134.0/24 [110/2] via 10.0.35.3, 00:34:10, GigabitEthernet0/3

By default, the cost advertised with the summary route is the least metric among all metrics of the routes forming in the OSPF summary IP prefix.

To set the metric/cost for a summary route manually, use the the area range ip_prefix subnet_mask cost metric command, where metric is a number from 0 to 16777215.

This example advertises the 10.0.20.0/22 summary route from area 0 with a metric of 10.

R3(config)# router ospf 1
R3(config-router)# area 0 range 10.0.20.0 255.255.252.0 cost 10

The following show ip ospf database summary command output states that the summary in question is getting announced with a cost of 10.

R3# show ip ospf database summary 10.0.20.0
            OSPF Router with ID (3.3.3.3) (Process ID 1)

                Summary Net Link States (Area 23)

  LS age: 76
  Options: (No TOS-capability, DC, Upward)
  LS Type: Summary Links(Network)
  Link State ID: 10.0.20.0 (summary Network Number)
  Advertising Router: 3.3.3.3
  LS Seq Number: 80000008
  Checksum: 0x17ED
  Length: 28
  Network Mask: /22
        MTID: 0         Metric: 10 


                Summary Net Link States (Area 35)

  LS age: 76
  Options: (No TOS-capability, DC, Upward)
  LS Type: Summary Links(Network)
  Link State ID: 10.0.20.0 (summary Network Number)
  Advertising Router: 3.3.3.3
  LS Seq Number: 80000008
  Checksum: 0x17ED
  Length: 28
  Network Mask: /22
        MTID: 0         Metric: 10 

External OSPF Route Summarization

OSPF allows summarizing external routes whether they are redistributed into OSPF from connected routes, static routes, or a dynamic routing protocol. The ASBR injecting those routes can be configured to advertise a summary of them instead of sharing all external routes eligible for redistribution.

To advertise a summary of a set of external routes at an ASBR into OSPF, use the summary-address ip_address mask command in router configuration mode, where ip_address is the summary address and mask the summary route’s IP subnet mask. Additionally, The command does not work on ABRs.

This example configures router R2, the only ASBR in the network, to inject an aggregate address for IP prefixes 10.0.0.0/24, 10.0.1.0/24, 10.0.2.0/24, and 10.0.3.0/24 into OSPF.

R2(config)# router ospf 1
R2(config-router)# summary-address 10.0.0.0 255.255.252.0

The show ip ospf database external command output states that R2 created a Type 5 LSA for the summary route.

R2# show ip ospf database external 10.0.0.0

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

                Type-5 AS External Link States

  LS age: 10
  Options: (No TOS-capability, DC, Upward)
  LS Type: AS External Link
  Link State ID: 10.0.0.0 (External Network Number )
  Advertising Router: 2.2.2.2
  LS Seq Number: 8000000E
  Checksum: 0xFF84
  Length: 36
  Network Mask: /22
        Metric Type: 2 (Larger than any link state path)
        MTID: 0 
        Metric: 20 
        Forward Address: 0.0.0.0
        External Route Tag: 0

Routers R3, R4, and R5 no longer have routes to IP prefixes 10.0.0.0/24, 10.0.1.0/24, 10.0.2.0/24, and 10.0.3.0/24. Instead, they use the OSPF summary route in order to reach those networks, as shown in the following show ip route ospf command outputs.

Router R3

R3# show ip route ospf


omitted output

      10.0.0.0/8 is variably subnetted, 13 subnets, 3 masks
O E2     10.0.0.0/22 [110/20] via 10.0.123.2, 00:07:16, GigabitEthernet0/2
O E2     10.0.12.0/24 [110/20] via 10.0.123.2, 00:15:39, GigabitEthernet0/2
O        10.0.20.0/22 is a summary, 00:15:39, Null0
O        10.0.20.0/24 [110/2] via 10.0.134.4, 00:15:39, GigabitEthernet0/4
O        10.0.21.0/24 [110/2] via 10.0.134.4, 00:15:39, GigabitEthernet0/4
O        10.0.22.0/24 [110/2] via 10.0.134.4, 00:15:39, GigabitEthernet0/4
O        10.0.23.0/24 [110/2] via 10.0.134.4, 00:15:39, GigabitEthernet0/4

Router R4

R4# show ip route ospf


omitted output

      10.0.0.0/8 is variably subnetted, 14 subnets, 3 masks
O E2     10.0.0.0/22 [110/20] via 10.0.134.3, 00:07:34, GigabitEthernet0/3
O E2     10.0.12.0/24 [110/20] via 10.0.134.3, 00:15:52, GigabitEthernet0/3
O IA     10.0.35.0/24 [110/2] via 10.0.134.3, 00:15:52, GigabitEthernet0/3
O IA     10.0.123.0/24 [110/2] via 10.0.134.3, 00:15:52, GigabitEthernet0/3

Router R5

R5# show ip route ospf


omitted output

      10.0.0.0/8 is variably subnetted, 7 subnets, 3 masks
O E2     10.0.0.0/22 [110/20] via 10.0.35.3, 00:07:42, GigabitEthernet0/3
O E2     10.0.12.0/24 [110/20] via 10.0.35.3, 00:16:01, GigabitEthernet0/3
O IA     10.0.20.0/22 [110/11] via 10.0.35.3, 00:16:01, GigabitEthernet0/3
O IA     10.0.123.0/24 [110/2] via 10.0.35.3, 00:16:01, GigabitEthernet0/3
O IA     10.0.134.0/24 [110/2] via 10.0.35.3, 00:16:01, GigabitEthernet0/3

The cost advertised with the OSPF summary route is the lowest metric of all routes with the largest subnet mask. Cisco IOS does not allow setting a cost for an aggregate address using the summary-address command. But, you set a tag by including the tag keyword.

Finally, the summary-address ip_address mask not-advertise command prevents routes that match the ip_address /mask pair.

Related Lessons to OSPF Summarization

Mohamed Ouamer is a computer science teacher and a self-published author. He taught networking technologies and programming for more than fifteen years. While he loves to share knowledge and write, Mohamed's best passions include spending time with his family, visiting his parents, and learning new things.