Enable OSPF

 

r1(config)# router ospf process-id

The process-id value represents a number between 1 and 65,535 and is selected by the network administrator. The process-id value is locally significant, which means that it does not have to be the same value on the other OSPF routers to establish adjacencies with those neighbors.

Router ID

    The router ID is used to:

  • Uniquely identify the router – The router ID is used by other routers to uniquely identify each router within the OSPF domain and all packets that originate from them.
  • Participate in the election of the DR – Assuming there is no priority configured, or there is a tie, then the router with the highest router ID is elected the DR. The routing device with the second highest router ID is elected the BDR.
    For more detail how to elect a DR, check here.

    How to choose router ID:

Cisco routers derive the router ID based on one of three criteria, in the following preferential order:

  1. By R1(config-router)#router-id rid router configuration mode command. The rid value is any 32-bit value expressed as an IPv4 address. This is the recommended method to assign a router ID.
  2. If the router ID is not explicitly configured, the router chooses the highest IPv4 address of any of configured loopback interfaces. This is the next best alternative to assigning a router ID. Note that some older versions of the IOS do not recognize the router-id command; therefore, the best way to set the router ID on those routers is by using a loopback interface.
  3. If no loopback interfaces are configured, then the router chooses the highest active IPv4 address of any of its physical interfaces. This is the least recommended method because it makes it more difficult for administrators to distinguish between specific routers.  Note that if the router uses the highest IPv4 address for the router ID, the interface does not need to be OSPF-enabled.

If the router ID is the same on two neighboring routers, the router displays an error message similar to the one below:

%OSPF-4-DUP_RTRID1: Detected router with duplicate router ID.

To correct this problem, configure all routers so that they have unique OSPF router IDs.

    How to modify router ID:

After find the router ID is incorrect, we only need to re-enter the correct router ID. After assign the right router ID, Notice how an informational message appears stating that the OSPF process must be cleared or that the router must be reloaded.

The reason is because R1 already has adjacencies with other neighbors using the old router ID.  Of course, clearing the OSPF process is the better way, which can be achieved by r1#clear ip ospf process

Then we can verify the router ID by show ip protocols | section Router ID command.

Configure Single-Area OSPF

    1. Command syntax is network network-address wildcard-mask area area-id.
      • Wildcard-mask: Wildcard mask is typically the inverse of the subnet mask configured on that interface.A wildcard mask is a string of 32 binary digits used by the router to determine which bits of the address to examine for a match. In a subnet mask, binary 1 is equal to a match and binary 0 is not a match. In a wildcard mask, the reverse is true:
        • Wildcard mask bit 0 Matches the corresponding bit value in the address.
        • Wildcard mask bit 1 Ignores the corresponding bit value in the address.
      • The area area-id: Refers to the OSPF area. When configuring single-area OSPF, the network command must be configured with the same area-id value on all routers. Although any area ID can be used, it is good practice to use an area ID of 0 with single-area OSPF.
    2.  Alternative way: network intf-ip-address 0.0.0.0 area area-id

The advantage of specifying the interface is that the wildcard mask calculation is not necessary. OSPFv2 uses the interface address and subnet mask to determine the network to advertise.Some IOS versions allow the subnet mask to be entered instead of the wildcard mask. The IOS then converts the subnet mask to the wildcard mask format.

3. Advertise loopback

Default behavior of OSPF for loopback interfaces is to advertise a 32-bit host route. To ensure that the
full network is advertised, use the ip ospf network point-to-point command.

eg.

R2(config)# interface loopback 2
R2(config-if)# ip address 10.1.2.1 255.255.255.0
R2(config-if)# ip ospf network point-to-point

Passive interface

  • Inefficient Use of Bandwidth – Messages are multicasted; therefore, switches are also forwarding the messages out all ports.
  • Inefficient Use of Resources – All devices on the LAN must process the message and eventually discard the message.
  • Increased Security Risk – Advertising updates on a broadcast network is a security risk. OSPF messages can be intercepted with packet sniffing software. Routing updates can be modified and sent back to the router, corrupting the routing table with false metrics that misdirect traffic.

Command to configure:  r1(config-router)# passive-interface interface-name   or All interfaces can be made passive using the passive-interface default command. The show ip protocols command is then used to verify that the Gigabit Ethernet interface was passive.

The r1(config-router)# no passive-interface interface-name to remove a particular interface from the passive-interfaces list.

Default route redistribution

 default-information originate

default-information originate always

The always keyword is necessary for generating a default route in this scenario. Without this keyword, a
default route is generated only into OSPF if one exists in the routing table.