You want to run OSPF on a simple network.
You can enable OSPF on router by defining an OSPF process and assigning an address range to an area as follows:
Router5#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router5(config)#router ospf 87 Router5(config-router)#network 0.0.0.0 255.255.255.255 area 0 Router5(config-router)#exit Router5(config)#end Router5#
The first line in this configuration example defines the OSPF process:
Router5(config)#router ospf 87
The OSPF process number (87) doesn't propagate outside of the router. So you can use a different value for every router in an AS. Note that this is different from EIGRP, where every router in the AS must have the same process number. The process number can take any value between 1 and 65,535.
The network statement in this example then takes the simplest possible approach to defining areas by putting every interface on the router into area 0:
Router5(config-router)#network 0.0.0.0 255.255.255.255 area 0
The first two arguments of the network statement are an IP address and a corresponding set of wildcard bits. In this case, 0.0.0.0 255.255.255.255 matches every possible IP address. So every interface on this router is assigned to area 0.
In this case, we have defined the area by using a single number. You can define area numbers to be anything between 0 and 4,294,967,295. You can also use dotted decimal notation for areas, in which case you would write area 0 as 0.0.0.0.
OSPF treats the area number internally as a 32-bit field regardless of whether you choose to represent it as a single number or by using dotted decimals. So you could mix and match if you wanted to. But we recommend picking whichever approach better suits your network and sticking to it. It is far too easy to get confused when translating between the two formats.
In general, for small networks it is easier to remember single numbers. But for larger networks, it is often easier to work with dotted decimal notation, perhaps developing some locally meaning mnemonic to help give the area numbers significance. For example, in an international WAN, you might want to make the first octet stand for the country, the second for state or province, the third for city, and the fourth defining the actual area. Or you might want to make the area numbers the same as the summary IP addresses for each area. The only special area number is area 0, which must be the routing backbone of the network and must connect to all other areas directly, as we discussed in the Introduction to this chapter.
If you have more than one network statement, the order becomes important. In the following example, the last line matches all IP addresses and assigns them to area 0. But because this line comes last, it only picks up any addresses that are not captured by either of the lines above it. However, if we had written this line first, then all of the interfaces would wind up in area 0:
Router1#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router1(config)#router ospf 55 Router1(config-router)#network 10.0.0.0 0.255.255.255 area 2 Router1(config-router)#network 172.20.0.0 0.0.255.255 area 100 Router1(config-router)#network 0.0.0.0 255.255.255.255 area 0 Router1(config-router)#exit Router1(config)#end Router1#
The show ip protocols command lists useful information about the OSPF configuration:
Router1#show ip protocols Routing Protocol is "ospf 55" Outgoing update filter list for all interfaces is not set Incoming update filter list for all interfaces is not set Router ID 172.25.25.1 It is an area border and autonomous system boundary router Redistributing External Routes from, Number of areas in this router is 3. 3 normal 0 stub 0 nssa Maximum path: 4 Routing for Networks: 10.0.0.0 0.255.255.255 area 2 172.20.0.0 0.0.255.255 area 100 0.0.0.0 255.255.255.255 area 0 Routing Information Sources: Gateway Distance Last Update 192.168.30.1 110 00:01:30 172.25.25.6 110 16:44:07 172.25.25.1 110 00:01:30 172.25.25.2 110 00:01:30 172.25.1.7 110 00:01:30 172.25.1.1 110 16:56:15 Distance: (default is 110) Router1#
If you want more control, you can specify individual interface IP addresses with a wildcard mask of 0.0.0.0 to match only one address at a time:
Router5#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router5(config)#router ospf 87 Router5(config-router)#network 172.25.1.7 0.0.0.0 area 0 Router5(config-router)#network 172.25.25.6 0.0.0.0 area 0 Router5(config-router)#exit Router5(config)#end Router5#
This can be useful when your addresses don't summarize well, which can be the case when you are changing your network architecture or merging two networks.
In IOS level 12.3(11)T, Cisco introduced a new way to assign interfaces to OSPF areas, using the ip ospf area interface configuration command:
Router9#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router9(config)#router ospf 87 Router9(config-router)#exit Router9(config)#interface FastEthernet0/0 Router9(config-if)#ip address 172.18.5.9 255.255.255.0 Router9(config-if)#ip ospf 87 area 10 Router9(config-if)#exit Router9(config)#end Router9#
We like this new method, particularly on ABRs, because it makes it very easy to look at a router's configuration and understand the OSPF configuration. With a complicated set of network statements, on the other hand, it can be quite a time-consuming task to figure out which interfaces belong to which areas and which don't take part in the routing protocol at all.