Now let’s examine network statements as used with OSPF. Refer to Figure 1:
Image may be NSFW.
Clik here to view.
When using network statements with OSPF, the wildcard masks are required, as are area numbers. To get OSPF Area 0 running on all interfaces, we could do this:
router ospf 1
network 192.168.1.1 0.0.0.0 area 0
network 172.16.1.1 0.0.0.0 area 0
network 10.1.1.1 0.0.0.0 area 0
network 10.2.2.1 0.0.0.0 area 0
As a result, the interfaces would advertise the following prefixes:
- Fa0/0 – 10.1.1.0/24, 10.2.2.0/28 and 172.16.1.0/24
- Fa0/1 – 10.1.1.0/24, 172.16.1.0/24 and 192.168.1.0/24
- Fa0/2 – 10.1.1.0/24, 10.2.2.0/28 and 192.168.1.0/24
- Fa0/3 – 10.2.2.0/28, 172.16.1.0/24 and 192.168.1.0/24
Note that automatic route summarization is not available with Cisco’s implementation of OSPF, so the actual prefixes are advertised.
Since both of the network 10.0.0.0 interfaces are assigned to OSPF Area 0, we could get the same result like this:
router ospf 1
network 192.168.1.1 0.0.0.0 area 0
network 172.16.1.1 0.0.0.0 area 0
network 10.0.0.0 0.255.255.255 area 0
Or we could use just one network statement, like this:
router ospf 1
network 0.0.0.0 255.255.255.255 area 0
When the router is acting as an OSPF ABR (Area Border Router) it is critical that the interfaces be assigned to the correct areas. For example, if we want the network 10.0.0.0 interfaces in Area 1 and the other interfaces in Area 0, we could do this:
router ospf 1
network 192.168.1.1 0.0.0.0 area 0
network 172.16.1.1 0.0.0.0 area 0
network 10.0.0.0 0.255.255.255 area 1
In the previous OSPF examples the network statements didn’t overlap, so the order wasn’t important. Since EIGRP and OSPF network statements are “top-down, first-match” (like Access Control Lists), to get the network 10.0.0.0 interfaces into Area 1 and the rest into Area 0 we could also do this:
router ospf 1
network 10.0.0.0 0.255.255.255 area 1
network 0.0.0.0 255.255.255.255 area 0
How you do it is a “style” question, but you’d better end up with the right interface(s) in the right area(s). You can verify this with “show ip ospf interface”.
We can also set interfaces “passive” under OSPF, which stops the “Hello” packets from being sent, and prevents OSPF adjacencies from forming. As with RIP and EIGRP, if we cover an interface with a network statement, the router will inject the subnet of the interface into the routing protocol, and if we don’t, it won’t (unless we use “redistribute connected” or some other option).
Next time, we’ll take a look at some additional techniques involving OSPF.