The opposite of subnetting: combine many small networks into one shorter prefix. Summarization shrinks routing tables and hides instability — a core design skill.
Why: advertising dozens of small subnets bloats routing tables and spreads instability, so you combine contiguous networks into a single "supernet" with a shorter prefix. When: summarize at boundaries (a site, a region) to keep routing tables small and stable. Where: it is subnetting in reverse — remove network bits instead of borrowing them.
Four contiguous /24s advertised separately:
192.168.0.0/24 192.168.1.0/24 192.168.2.0/24 192.168.3.0/24
Common bits: 192.168.000000xx -> the first 22 bits match.
Summarize to ONE route: 192.168.0.0/22 (covers .0 through .3)
One advertisement instead of four. Smaller table, less churn.Why: the summary is the shortest prefix that exactly covers a set of contiguous networks — collapse_addresses finds it, so you never guess the prefix length. When: use it to design summary routes and to check that your blocks are actually contiguous (non-contiguous blocks cannot be summarized into one). Where: over-summarizing (a prefix that also covers networks you do not own) can black-hole traffic, so verify the range.
import ipaddress
nets = [ipaddress.ip_network(f"192.168.{i}.0/24") for i in range(4)]
summary = list(ipaddress.collapse_addresses(nets))
print(summary) # [IPv4Network('192.168.0.0/22')]
# Confirm the summary covers exactly what you expect:
s = summary[0]
print(s.network_address, s.broadcast_address) # 192.168.0.0 192.168.3.255Why: once you know the summary prefix, you configure the router to advertise the single supernet instead of the component routes — the payoff of the math. When: apply summarization at the interface or protocol level (here, a static summary pointing at the next hop). Where: the exact syntax varies by protocol, but the idea is identical everywhere.
! Cisco IOS — a static summary route for 192.168.0.0/22
ip route 192.168.0.0 255.255.252.0 10.0.0.2
! Under OSPF, summarize at an area border:
! area 1 range 192.168.0.0 255.255.252.0
! Under EIGRP, on the interface:
! ip summary-address eigrp 100 192.168.0.0 255.255.252.0