Previous section   Next section

Recipe 8.1 Configuring OSPF

8.1.1 Problem

You want to run OSPF on a simple network.

8.1.2 Solution

You can enable OSPF on a 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)#end
Router5#

8.1.3 Discussion

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 area, so you can actually use any value here. In fact, the OSPF process number doesn't even propagate outside of the router; 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 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 example, we have defined the area 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. 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.

For small networks it is generally easier to remember single numbers. But for larger networks it is often easier to work with dotted decimal notation, perhaps developing some locally meaningful 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 for 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 is 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)#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 101
Router5(config-router)#network 172.25.25.6 0.0.0.0 area 102
Router5(config-router)#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.


  Previous section   Next section
Top