In the previous section you learned about OSPF and how it works. While a lot a theory was covered in that section, this one looks at configuring OSPF. The network shown in Figure 5-9 will be used for this section.
Figure 5-9 OSPF Network
Just like EIGRP, OSPF configuration is divided into two parts – the global configuration and the interface level configuration. Globally, configuring OSPF includes enabling the process and adding networks to be advertised. To enable the OSPF process use the router ospf process_id global configuration command. In this command, process_id is a locally significant number and does not represent the AS. Since multiple OSPF processes can run on a router, the process_id is used to keep the processes separate. The process id can be different on every router. On entering the command, you will arrive at the router configuration mode when the network command can be used to specify the networks that will be advertised. In respect to OSPF, the network command actually identifies the interfaces on which OSPF will be enabled and the network to which the interface belongs will be advertised. The syntax of the command is:
In the above command, network_number and wildcard_mask combine to identify the interface on which OSPF will be enabled. While network_number is a network address (example 192.168.1.0), a wildcard_mask is the inverse of subnet mask. In a subnet mask a 255 is an octet means the corresponding octet in the network number should match exactly while a 0 means it can be anything. In a wildcard mask a 255 means the corresponding octet in a network number can be anything and 0 means the corresponding octet should match exactly. Confusing? Table 5-3 shows a few examples. The last component of the above command is the area_id to which the interface will belong.
Table 5-3 Wildcard Mask examples
|192.168.1.1||0.0.0.0||192.168.1.1||Since each octet of the wildcard mask is a zero, only an interface with an IP address specified by the network number will be matched.|
|192.168.1.0||0.0.0.255||192.168.1.0-192.168.1.255||Since the last octet is 255, the value of the last octet of the network number does not matter as long as the first three octets match the given network number.|
|10.1.0.0||0.255.255.255||10.0.0.0-10.255.255.255||A wildcard mask of 0.255.255.255 means that as long as the first octet matches, the rest can be anything.|
If you want to enable OSPF on each interface individually then you can use a wildcard mask of 0.0.0.0 with network numbers consisting of the IP address of each interface. This is the simplest and easiest way to configure OSPF but you can also use wildcard mask to cover a range of addresses. For example, In Figure 5-9, RouterF has two interfaces and OSPF can be enabled on them using two network commands like:
network 192.168.6.0 0.0.0.255 area 2
network 192.168.7.0 0.0.0.255 area 2
Another way to configure OSPF on RouterF is to use a single network commands as shown below:
While the first method is precise and safe, the second method can introduce problems since it covers a wide range of networks. Another method to use wildcard masks is to specify network blocks. Wilcard masks can represent blocks of network just like network masks. You may recall that network masks can represent only specific sizes of blocks – 2, 4, 8, 16, 32, 64, 128 and 255. To specify a block with wildcard mask simply deduct one from the block size. For example, in RouterF networks 192.168.6.0 and 192.168.7.0 can be covered using any of the following:
Now that you understand the network command, let us configure the OSPF in the network shown in Figure 5-9. I will be using a mix of wildcard masks types discussed above to configure each router. Make sure you pay attention to the area each interface should belong to. With OSPF, area 0 should be configured first, so we will start with routers belonging to area 0.
RouterB has one interface in area 0 while RouterC has 2 interfaces in area 0. The best way to configure them is to use a wildcard mask of 0.0.0.0 with the interfaces addresses.
Note that 192.168.3.0 and 192.168.4.0 cannot be configured as a single block since a block of 2 or 4 will not cover them and a block of 8 will cover 192.168.5.0, which is in area 2. So we had to use two statements with a mask of 0.0.0.0.
Now that area 0 has been configured, other areas can be configured. RouterA has two interfaces in area 1 and RouterB has one interface in that area.
Notice that on RouterA a network number of 0.0.0.0 and a wildcard mask of 255.255.255.255 are used. This mask essentially means all networks and can be used on RouterA since both the interfaces belong to area 1.
The final area spans across four routers. All interfaces of RouterD, RouterE and RouterF belong to area 2.
In the above configuration notice the three different ways wildcard has been used on RouterD, RouterE and RouterF.
Now that OSPF configuration is complete, let us take a look at the routing table on each router to verify the configuration.
The above outputs show that all networks are known across the internetwork. You should also notice the following:
- While an O precedes OSPF routes, inter-area routes are preceded with an IA also.
- In the outputs from RouterC and RouterF notice that OSPF is load balancing across equal cost paths.
Influencing path selection
As discussed in the earlier section, Cisco uses interface bandwidth as a metric for cost and the sum of cost of the entire path is used to select the best route to a destination. The cost of an interface can be manually changed using the ip ospf cost command in the interface configuration mode.
For example, in the network shown in Figure 5-9, traffic going from RouterF to 192.168.4.0/24 is being load balanced between the paths going through RouterD and RouterE. RouterF can be made to route traffic only through RouterD and use RouterE has a backup path by increasing the cost associated with interface fa0/0 on RouterE. This will cause the cost of the entire path to increase causing RouterF to not use that path along with the other path. The following commands will increase the cost on RouterE:
The effect of this change will almost immediately be seen on the routing table of RouterF:
In the output above, notice that RouterF is no longer load balancing the traffic across the two paths.
Influencing DR/BDR election
In the previous section you learned that OSPF routes do not form adjacencies with all neighbors in a multi-access network. A DR and a BDR are elected and all other routers form adjacencies with them. This election takes into consideration the OSPF priority and in case of a tie, the Router ID.
For example, in the network shown in Figure 5-9, RouterE will be the DR and RouterD will be the BDR in the Ethernet network 192.168.5.0/24 because RouterE has the highest router ID (192.168.6.5) and RouterD has the second highest router ID (192.168.6.4). RouterC has a router ID of 192.168.6.3. If you wanted RouterC to always be the DR, either the priority or the Router ID would have to be increased. The easiest way to do this is to increase the priority on interface fa0/1 of RouterC as shown below:
The show ip ospf interface interface command can be used as shown below:
While the entire output is discussed in the next section, notice that the third line shows the state as DOTHER. DOTHER means that the router is not a DR or BDR. So why did the new priority not cause RouterC to become the DR or BDR?
That is because a DR/BDR election does not take place till the existing DR/BDR leaves the network. One way to force a reelection is to restart the OSPF process on the current DR and BDR. A reset will cause the OSPF process to restart and the network will think that the DR and BDR are lost and will force an election. You can rest the process using clear ip ospf process command. To force an election in the network, let’s reset the OSPF process on RouterD and RouterE as shown below:
Once the adjacencies are reestablished, the output of show ip ospf interface on RouterC looks like the following:
Notice that RouterC is now the DR. Another way to influence the election would have been to create a loop back interface on RouterC with a high IP address as shown below:
This would cause the router ID of RouterC to be higher than the rest.