What does the network statement actually do in OSPF, and what is the alternative?
Show the answer
Say this first
It does not advertise a network directly. It matches interface addresses with a wildcard mask and enables
OSPF on every interface that matches, in the given area. That interface then sends hellos and its subnet is
advertised. The alternative is ip ospf <process> area <area> on the interface, which I prefer.
Go deeper
Network statements
router ospf 1
network 10.0.12.0 0.0.0.3 area 0
network 10.10.0.0 0.0.255.255 area 1
network 1.1.1.1 0.0.0.0 area 00.0.0.3with10.0.12.0matches 10.0.12.0 to 10.0.12.3.0.0.0.0matches one exact interface address. It is the most precise form.- The first matching statement wins, most specific first in the running config.
Interface mode
interface GigabitEthernet0/0/0
ip ospf 1 area 0It is explicit, cannot match a new interface by accident, and wins over a network statement.
Common mistakes
network 0.0.0.0 255.255.255.255 area 0enables OSPF on every interface, including the ones to the ISP.- The mask in the network statement is a wildcard, not a subnet mask.
- The prefix advertised is the interface's real subnet, not the range in the statement.
They will ask next
Can an interface have secondary addresses in OSPF?
Yes. Secondaries in the same area are advertised as stub networks. Hellos use the primary address.
Traps
- Thinking
network 10.0.0.0 0.255.255.255 area 0advertises a /8. It enables matching interfaces and advertises their own subnets.
How did you do?