OSPF Advertising Loopback Interface

Unlike RIP/EIGRP, OSPF has a special way to advertise loopback interfaces. In OSPF, the route information of the loopback interface is advertised as the host route with subnet mask /32.

For example, configure IP address 10.0.0.2/24 for Loopback0 on R2 in the following figure, and advertise it with OSPF. Then, the host route 10.0.0.2/32 will be advertised instead of 10.0.0.0/24.

Figure The route of the loopback interface is the host route.
Figure The route of the loopback interface is the host route.

No other hosts will be connected to the end of the loopback interface. Therefore, when you configure an IP address for the loopback interface, you may often use a subnet mask of /32. However, there will be times when you want to advertise the route of the loopback interface with the configured subnet mask, such as when verifying the operation of OSPF. There are three ways to do this.

  1. Configure the network type as POINT_TO_POINT
  2. Summarize the routes of the loopback interface
  3. Redistribute the route of the loopback interface to OSPF

The simplest and most straightforward way is to configure the network type as POINT_TO_POINT. Please understand that other methods can also be used in this way.

In the following sections, we will use Cisco routers to specifically explain how to advertise a loopback interface in OSPF.

Network diagram

Consider the following simple network diagram to advertise a loopback interface in OSPF.

Figure Advertising Loopback Interface network diagram
Figure Advertising Loopback Interface network diagram

Let’s start with R1 and R2 with OSPF enabled on Fa0/0 as Area 0 interfaces and as neighbors.

Lo0:10.0.0.2/24
Lo1:10.1.1.2/24
Lo2:10.2.2.2/24
Lo3:10.3.3.2/24

Treat the route of Lo0 as a host route with /32. Then, make sure to advertise the routes of Lo1 to Lo3 with subnet mask /24.

Advertising the Lo0 route

Enable OSPF on Lo0 and advertise the Lo0 route with OSPF.

R2

router ospf 1
 network 10.0.0.0 0.0.0.255 area 0

No special configuration is done, so the Lo0 route will be advertised as the /32 host route “10.0.0.2/32”. If you look at show ip ospf interface loopback0 on R2, you will see that the network type is “LOOPBACK”.

R2

R2#show ip ospf interface loopback 0
Loopback0 is up, line protocol is up
  Internet Address 10.0.0.2/24, Area 0
  Process ID 1, Router ID 2.2.2.2, Network Type LOOPBACK, Cost: 1
  Loopback interface is treated as a stub Host

And the routing table on R1 is as follows.

R1

R1#show ip route ospf
     10.0.0.0/32 is subnetted, 1 subnets
O       10.0.0.2 [110/11] via 192.168.12.2, 00:33:56, FastEthernet0/0

Figure The route of the loopback interface is the host route
Figure The route of the loopback interface is the host route.

Advertising the Lo1 route

Next, advertise the route of Lo1 with the configured subnet mask of 10.1.1.0/24 instead of the host route. To do so, change the network type to POINT_TO_POINT in Lo1.

R2

interface Loopback1
 ip ospf network point-to-point
!
router ospf 1
 network 10.1.1.0 0.0.0.255 area 0

By changing the network type to POINT_TO_POINT, the route 10.1.1.0/24 will be advertised from R2. R1のルーティングテーブルは以下の通りです。

R1

R1#show ip route ospf
     10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
O       10.0.0.2/32 [110/11] via 192.168.12.2, 00:43:58, FastEthernet0/0
O       10.1.1.0/24 [110/11] via 192.168.12.2, 00:01:06, FastEthernet0/0

Figure Configure the network type as POINT_TO_POINT
Figure Configure the network type as POINT_TO_POINT

As you can see, changing the network type of the loopback interface to POINT_TO_POINT is the simplest way to advertise it as a route with a configured subnet mask.

Advertising the Lo2 route

Lo2 routes will also be advertised on /24. Summarize the /32 subnet mask to /24. To summarize route with OSPF, it must be ABR; making the area of Lo2 as 1, make R2 ABR and generate summary route on R2.

R2

router ospf 1
 network 10.2.2.0 0.0.0.255 area 1
 area 1 range 10.2.2.0 255.255.255.0

Then, the routing table on R1 will look like the following.

R1

R1#show ip route ospf
     10.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
O       10.0.0.2/32 [110/11] via 192.168.12.2, 00:52:51, FastEthernet0/0
O IA    10.2.2.0/24 [110/11] via 192.168.12.2, 00:00:10, FastEthernet0/0
O       10.1.1.0/24 [110/11] via 192.168.12.2, 00:09:59, FastEthernet0/0

Since Lo2 is configured as Area 1 for summarization, it will be registered in the routing table with the code “O IA”.

Figure Summarize the routes of the loopback interface
Figure Summarize the routes of the loopback interface

Advertising the Lo3 route

Finally, the Lo3 route is also advertised in /24. Instead of enabling OSPF on the loopback interface, redistribute Connected to OSPF and it will be treated as a route with the configured subnet mask. Redistribute Lo3’s Connected routes to OSPF with the following configuration on R2.

R2

router ospf 1
 redistribute connected subnets route-map Lo3
!
route-map Lo3 permit 10
 match interface Loopback3

In the routing table on R1, 10.3.3.0/24 looks like the following

R1

R1#show ip route ospf
     10.0.0.0/8 is variably subnetted, 4 subnets, 2 masks
O       10.0.0.2/32 [110/11] via 192.168.12.2, 01:02:09, FastEthernet0/0
O E2    10.3.3.0/24 [110/20] via 192.168.12.2, 00:01:16, FastEthernet0/0
O IA    10.2.2.0/24 [110/11] via 192.168.12.2, 00:09:28, FastEthernet0/0
O       10.1.1.0/24 [110/11] via 192.168.12.2, 00:19:17, FastEthernet0/0

Since it is redistributed, 10.3.3.0/24 is registered in the routing table with the code “O E2”.

Figure Redistribute the route of the loopback interface to OSPF
Figure Redistribute the route of the loopback interface to OSPF

Summary

Point

  • In OSPF, the route of the loopback interface is advertised as the /32 host route.
  • To advertise the route of a loopback interface with the configured subnet mask, you can use the following method.
    • Configure the network type as POINT_TO_POINT
    • Summarize the routes of the loopback interface
    • Redistribute the route of the loopback interface to OSPF

How the OSPF works