The OSPF network command is used to activate OSPF on the specified interfaces. Specifying an interface with the command will include the interface into the OSPF routing process. On broadcast and point-to-point network types, the router will automatically start the neighbor discovery process by sending hello packets to the AllSPFRouters multicast address (184.108.40.206) after an interface has been integrated into the OSPF process.
If there’s another OSPF router on that link and their Hello packets match, they will try to form an adjacency but that’s another story.
The OSPF network command uses the following syntax:
network ip-address wildcard-mask area area-id
The usage of the ip address and the wildcard mask allows us to specify one or multiple interfaces with one statement and assign them to the specified OSPF area. The Cisco IOS software sequentially evaluates the ip-address wildcard-mask pair for each interface as follows:
1. The wildcard-mask argument is logically ORed with the interface IP address.
2. The wildcard-mask argument is logically ORed with the ip-address argument in the network command.
3. The software compares the two resulting values. If they match, OSPF is enabled on the associated interface and this interface is attached to the OSPF area specified.
When enabling OSPF on interfaces you got three different options to do so:
1. The definition of only one interface
Definitions of only one interface are done with a wildcard-mask of 0.0.0.0 and the exact IP address of the given interface. This will match exact on that interface and nothing else.
2. The definition of mutiple but not all interfaces into one area
If you have to specify multiple interfaces and the IP concept has been done nicely, you might be able to summarize them all into one network statement. So if we have an address range like 220.127.116.11/21 which belongs to area N we can use network 18.104.22.168 0.0.7.255 area N to define them in one network statement. Every new interface on that router with an IP in that range will automatically be added into the OSPF process and added to that area.
3. The definition of all interfaces into one area
If you want to specify all interfaces on the router, the network statement network 0.0.0.0 255.255.255 area N will do the trick. Every new interface with an IP address on the router will automatically join OSPF and this area.
In older IOS versions the order in which the OSPF network statements have been configured if the area definitions have been overlapping. Nowadays Cisco IOS still doesnt allow an interface to be in more then one area:
Any individual interface can only be attached to a single area. If the address ranges specified for different areas overlap, the software will adopt the first area in the network command list and ignore the subsequent overlapping portions. In general, we recommend that you configure address ranges that do not overlap in order to avoid inadvertent conflicts.
but its not a problem any more in what order the statements got configured. The Cisco IOS will automatically reorder the network statements and places the most specific statements at the top and the least specific at the bottom. The following example will show this behavior:
R6(config)#do sh ip int brief | e una Interface IP-Address OK? Method Status Protocol FastEthernet0/0 22.214.171.124 YES manual up up FastEthernet0/1 126.96.36.199 YES manual up up Loopback0 188.8.131.52 YES manual up up R6(config)#router ospf 1 R6(config-router)#network 0.0.0.0 0.0.0.0 area 20 R6(config-router)#network 184.108.40.206 0.0.255.255 area 10 R6(config-router)#network 220.127.116.11 0.0.0.0 area 0 R6#sh run | sec router ospf router ospf 1 log-adjacency-changes network 18.104.22.168 0.0.0.0 area 0 network 22.214.171.124 0.0.255.255 area 10 network 0.0.0.0 255.255.255.255 area 20 R6#sh ip ospf int | i is up|Area FastEthernet0/1 is up, line protocol is up Internet Address 126.96.36.199/24, Area 0 FastEthernet0/0 is up, line protocol is up Internet Address 188.8.131.52/24, Area 10 Loopback0 is up, line protocol is up Internet Address 184.108.40.206/24, Area 20
So based on the above note from Cisco and the shown behavior it is possible to create overlapping network statements without the need to think about the network statement order, but also as Cisco says it should be avoided if possible.