OSPF Network Type Loopback

The OSPF network type loopback is assigned automatically to loopback interfaces, and OSPF advertises these as /32 host routes instead of the configured network. For example, if you have configured 192.168.1.1/24 on a loopback interface, then OSPF will advertise it as 192.168.1.1/32.

Because OSPF treats a loopback as a stub without any attached neighbors, it does not send Hello packets on a loopback interface and does not attempt to form neighbor adjacencies.

It is possible to make OSPF advertise the actual network on the loopback interface by changing the OSPF network type to point-to-point. This can be useful for labs where you want to advertise different networks in OSPF.

In this lesson, I’ll walk you through the configuration, we’ll see how OSPF advertises the loopback by default and we’ll change it to point-to-point so you can see the difference.

Configuration

Here is the topology:

Two Routers R1 R2 One Loopback Interface

I’m using Cisco IOS Software [Dublin], Linux Software (X86_64BI_LINUX-ADVENTERPRISEK9-M), Version 17.12.1, RELEASE SOFTWARE (fc5) for these two routers.

Configurations

Want to take a look for yourself? Here you will find the startup configuration of each device.

R1

hostname R1
!
interface Loopback0
 ip address 1.1.1.1 255.255.255.0
!       
interface Ethernet0/1
 ip address 192.168.12.1 255.255.255.0
!
router ospf 1
 router-id 1.1.1.1
 network 192.168.12.0 0.0.0.255 area 0
!
end

R2

hostname R2
!
interface Ethernet0/1
 ip address 192.168.12.2 255.255.255.0
!
router ospf 1
 router-id 2.2.2.2
 network 192.168.12.0 0.0.0.255 area 0
!
end

Two routers are all we need. Let’s configure a loopback interface:

R1(config)#interface Loopback 0
R1(config-if)#ip address 1.1.1.1 255.255.255.0

Notice that I used a /24 subnet mask. We’ll see why this matters in a bit.

Network Type Loopback

Let’s start with the default behavior. We’ll advertise the loopback in OSPF:

R1(config)#router ospf 1
R1(config-router)#network 1.1.1.0 0.0.0.255 area 0

Take a look at this output:

R1#show ip ospf interface Loopback 0
Loopback0 is up, line protocol is up 
  Internet Address 1.1.1.1/24, Interface ID 8, Area 0
  Attached via Network Statement
  Process ID 1, Router ID 1.1.1.1, Network Type LOOPBACK, Cost: 1
  Topology-MTID    Cost    Disabled    Shutdown      Topology Name
        0           1         no          no            Base
  Loopback interface is treated as a stub Host

In the output above, it tells us that the network type is LOOPBACK and it’s a stub network. You can also see that the cost is one.

We can also look at the link-state database (LSDB) to see that OSPF uses a Type 1 Router LSA to advertise the loopback:

R1#show ip ospf database router 1.1.1.1

            OSPF Router with ID (1.1.1.1) (Process ID 1)

                Router Link States (Area 0)

  LS age: 410
  Options: (No TOS-capability, DC)
  LS Type: Router Links
  Link State ID: 1.1.1.1
  Advertising Router: 1.1.1.1
  LS Seq Number: 80000008
  Checksum: 0x51C6
  Length: 48
  Number of Links: 2

    Link connected to: a Stub Network
     (Link ID) Network/subnet number: 1.1.1.1
     (Link Data) Network Mask: 255.255.255.255
      Number of MTID metrics: 0
       TOS 0 Metrics: 1

    Link connected to: a Transit Network
     (Link ID) Designated Router address: 192.168.12.2
     (Link Data) Router Interface address: 192.168.12.1
      Number of MTID metrics: 0
       TOS 0 Metrics: 10

The LSA shows the loopback as a stub network with a network mask of 255.255.255.255 (/32). That’s different than the 255.255.255.0 (/24) subnet mask on the interface.

Let’s check R2:

R2#show ip route ospf

      1.0.0.0/32 is subnetted, 1 subnets
O        1.1.1.1 [110/11] via 192.168.12.1, 00:03:26, Ethernet0/1

R2 has learned this network as a /32 host route.

Network Type Point-to-Point

What if we want to advertise the actual network on the loopback interface? It’s possible by changing the network type. Here are all the options:

R1(config)#interface Loopback0
R1(config-if)#ip ospf network ?
  broadcast            Specify OSPF broadcast multi-access network
  non-broadcast        Specify OSPF NBMA network
  point-to-multipoint  Specify OSPF point-to-multipoint network
  point-to-point       Specify OSPF point-to-point network

Not all options are possible. For example:

R1(config-if)#ip ospf network point-to-multipoint 
% OSPF: Invalid type for interface Loopback0

The only option that works is point-to-point:

R1(config)#interface Loopback0
% OSPF: Invalid type for interface Loopback0
R1(config-if)#ip ospf network point-to-point

The network type now shows up as point-to-point:

R1#show ip ospf interface Loopback 0
Loopback0 is up, line protocol is up 
  Internet Address 1.1.1.1/24, Interface ID 8, Area 0
  Attached via Network Statement
  Process ID 1, Router ID 1.1.1.1, Network Type POINT_TO_POINT, Cost: 1
  Topology-MTID    Cost    Disabled    Shutdown      Topology Name
        0           1         no          no            Base
  Transmit Delay is 1 sec, State POINT_TO_POINT
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    oob-resync timeout 40
  Supports Link-local Signaling (LLS)
  Cisco NSF helper support enabled
  IETF NSF helper support enabled
  Can be protected by per-prefix Loop-Free FastReroute
  Can be used for per-prefix Loop-Free FastReroute repair paths
  Not Protected by per-prefix TI-LFA
  Index 1/1/1, flood queue length 0
  Next 0x0(0)/0x0(0)/0x0(0)
  Last flood scan length is 0, maximum is 0
  Last flood scan time is 0 msec, maximum is 0 msec
  Neighbor Count is 0, Adjacent neighbor count is 0 
  Suppress hello for 0 neighbor(s)

We can also see this in the LSDB:

R1#show ip ospf database router 1.1.1.1

            OSPF Router with ID (1.1.1.1) (Process ID 1)

                Router Link States (Area 0)

  LS age: 110
  Options: (No TOS-capability, DC)
  LS Type: Router Links
  Link State ID: 1.1.1.1
  Advertising Router: 1.1.1.1
  LS Seq Number: 8000000A
  Checksum: 0x43D3
  Length: 48
  Number of Links: 2

    Link connected to: a Stub Network
     (Link ID) Network/subnet number: 1.1.1.0
     (Link Data) Network Mask: 255.255.255.0
      Number of MTID metrics: 0
       TOS 0 Metrics: 1

    Link connected to: a Transit Network
     (Link ID) Designated Router address: 192.168.12.2
     (Link Data) Router Interface address: 192.168.12.1
      Number of MTID metrics: 0
       TOS 0 Metrics: 10

Now the actual subnet mask 255.255.255.0 shows up. We can also see this on R2:

R2#show ip route ospf
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, m - OMP
       n - NAT, Ni - NAT inside, No - NAT outside, Nd - NAT DIA
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       H - NHRP, G - NHRP registered, g - NHRP registration summary
       o - ODR, P - periodic downloaded static route, l - LISP
       a - application route
       + - replicated route, % - next hop override, p - overrides from PfR
       & - replicated local route overrides by connected

Gateway of last resort is not set

      1.0.0.0/24 is subnetted, 1 subnets
O        1.1.1.0 [110/11] via 192.168.12.1, 00:01:37, Ethernet0/1

Now the network of R1’s loopback0 interface is advertised as 1.1.1.0/24. That’s all there is to it.

Unlock This Lesson for Free - No Payment Required!

If you like to keep on reading, register now!

  • Learn CCNA, CCNP and CCIE R&S. Explained As Simple As Possible.
  • Get Instant Access to this Full Lesson, Completely for Free!
  • Unlock More to Read. More Lessons Added Every Week!
  • Content created by Rene Molenaar (CCIE #41726)
1470 Sign Ups in the last 30 days

Ask a question or start a discussion by visiting our Community Forum