Friday, June 27, 2014

OSPF Loopback Network Type Advertisement



OSPF uses different types of networks to efficiently form neighbors in respect to the media that connects it to them.

These networks can be categorized as three main types.
  • Broadcast
  • Point to Point
  • Non-Broadcast Multi-Access (NBMA)

Yet one interface isn’t by default categorized as any of the above mentioned which is our beloved loopback address. The reason is Loopback is a logical interface that doesn’t carry transient traffic, it is initially used to route traffic from the router to itself or to terminate incoming traffic to the router itself, Thus; loopback advertisements by default are always generated as an Intra-Area /32 Stub host with a metric of 1

Let’s check the below topology




R3 is advertising the Loopback interface to ospf via a network or interface command directly. The IP configured under the loopback interface is 3.3.3.3/24.
Let’s first check the configuration on R3 and how it generated an LSA for that loopback address

R3#
interface Loopback0
 ip address 3.3.3.3 255.255.255.0
 ip ospf 1 area 1



R3#show ip ospf inter lo0
Loopback0 is up, line protocol is up
  Internet Address 3.3.3.3/24, Area 1
  Process ID 1, Router ID 3.3.3.3, Network Type LOOPBACK, Cost: 1
  Enabled by interface config, including secondary ip addresses
  Loopback interface is treated as a stub Host



R3#show ip ospf database router 3.3.3.3 self-originate

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

                Router Link States (Area 1)

  LS age: 557
  Options: (No TOS-capability, DC)
  LS Type: Router Links
  Link State ID: 3.3.3.3
  Advertising Router: 3.3.3.3
  LS Seq Number: 80000003
  Checksum: 0x2387
  Length: 48
  Number of Links: 2

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

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

Let’s also check how the other routers see this network

R1#show ip route 3.3.3.3
Routing entry for 3.3.3.3/32
  Known via "ospf 1", distance 110, metric 21, type inter area
  Last update from 10.0.12.2 on FastEthernet0/0, 00:00:04 ago
  Routing Descriptor Blocks:
  * 10.0.12.2, from 2.2.2.2, 00:00:04 ago, via FastEthernet0/0
      Route metric is 21, traffic share count is 1



R1#show ip ospf database summary 3.3.3.3

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

                Summary Net Link States (Area 0)

  Routing Bit Set on this LSA
  LS age: 77
  Options: (No TOS-capability, DC, Upward)
  LS Type: Summary Links(Network)
  Link State ID: 3.3.3.3 (summary Network Number)
  Advertising Router: 2.2.2.2
  LS Seq Number: 80000001
  Checksum: 0x31EC
  Length: 28
  Network Mask: /32
        TOS: 0  Metric: 11



From the above outputs, there are two things to notice here.

·         As stated in OSPF RFC#2328 page 225, the host routes is advertised as a router-LSA stub network with a hexa mask of 0xFFFFFFFF (255.255.255.255) and they indicate the router interfaces or looped router interfaces. Which tells why it was advertised as a /32 subnet
·         The other thing to notice in the output is that it is linked to two networks. A stub network, which we already discussed and to a transient network which is the IP address of the physical interface of the router connected to R3.
This is because if an incoming packet is destined to the router itself through physical interface, the network is attached to the through that physical interface

There are several ways to change this behavior

1.       Change the loopback OSPF network Type à will be advertised as configured mask and propagates in a Router-LSA
2.       Summarize the route to the desired network mask on an ABR à depending if this loopback is in a different area or not, will be propagated in a Summary-LSA
3.       Redistribute the loopback address to OSPF instead of using the network command à will be flooded with it’s configured subnet mask in an External-LSA

Let’s apply each one of the three solutions

1.      Solution 1 – change the OSPF network type under the loopback interface

We’ll begin by configuring the loopback interface as an OSPF point-to-point, one thing to notice here is that the only manual applicable network type is point to point. The broadcast, non-broadcast and point-to-multipoint are not allowed to be configured on loopback interface

interface Loopback0
 ip address 3.3.3.3 255.255.255.0
 ip ospf network point-to-point
 ip ospf 1 area 1

Now let’s do our checks again



R3#show ip ospf inter loopback 0
Loopback0 is up, line protocol is up
  Internet Address 3.3.3.3/24, Area 1
  Process ID 1, Router ID 10.0.23.3, Network Type POINT_TO_POINT, Cost: 1
  Enabled by interface config, including secondary ip addresses
  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
  Index 1/1, flood queue length 0
  Next 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)



R3#show ip ospf database router 3.3.3.3 self-originate

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

                Router Link States (Area 1)

  LS age: 32
  Options: (No TOS-capability, DC)
  LS Type: Router Links
  Link State ID: 3.3.3.3
  Advertising Router: 3.3.3.3
  LS Seq Number: 80000004
  Checksum: 0xD4D8
  Length: 48
  Number of Links: 2

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

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

The network is still advertised as a Stub, but notice how the subnet mask is now changed to /24 as configured under the loopback interface.

2.      Solution 2 – Summarize the loopback route to the desired network mask at an ABR

R2 Is an ABR between Area 0 and Area 1, we can summarize the network 3.3.3.3/32 into a bigger network /24. Even though it’s a viable workaroud, but the fact remains that this is a very poor way to resolve the issue and can introduce various problems in your network. Unless you exactly know every little detail about your network architecture, don’t start summarizing single host routes here and there otherwise it will be a mess.

R2#show ip route 3.3.3.3
Routing entry for 3.3.3.3/32
  Known via "ospf 1", distance 110, metric 11, type intra area
  Last update from 10.0.23.3 on FastEthernet0/0, 00:09:25 ago
  Routing Descriptor Blocks:
  * 10.0.23.3, from 3.3.3.3, 00:09:25 ago, via FastEthernet0/0
      Route metric is 11, traffic share count is 1

Now let’s summaries that route into a /24 and propagate it to Area 0

R2(config)#router ospf 1
R2(config-router)#area 1 range 3.3.3.0 255.255.255.0

Checking R2 database after summarization

R2#show ip ospf database summary 3.3.3.0 self-originate

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

                Summary Net Link States (Area 0)

  LS age: 113
  Options: (No TOS-capability, DC, Upward)
  LS Type: Summary Links(Network)
  Link State ID: 3.3.3.0 (summary Network Number)
  Advertising Router: 2.2.2.2
  LS Seq Number: 80000001
  Checksum: 0x4FD1
  Length: 28
  Network Mask: /24
        TOS: 0  Metric: 11



R2#show ip route
     1.0.0.0/32 is subnetted, 1 subnets
O       1.1.1.1 [110/11] via 10.0.12.1, 00:04:01, FastEthernet0/1
     2.0.0.0/32 is subnetted, 1 subnets
C       2.2.2.2 is directly connected, Loopback0
     3.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
O       3.3.3.3/32 [110/11] via 10.0.23.3, 00:04:01, FastEthernet0/0
O       3.3.3.0/24 is a summary, 00:04:01, Null0
     10.0.0.0/24 is subnetted, 2 subnets
C       10.0.12.0 is directly connected, FastEthernet0/1
C       10.0.23.0 is directly connected, FastEthernet0/0


And here’s what R1 see

R1#show ip route 3.3.3.0
Routing entry for 3.3.3.0/24
  Known via "ospf 1", distance 110, metric 21, type inter area
  Last update from 10.0.12.2 on FastEthernet0/0, 00:03:40 ago
  Routing Descriptor Blocks:
  * 10.0.12.2, from 2.2.2.2, 00:03:40 ago, via FastEthernet0/0
      Route metric is 21, traffic share count is 1


3.      Redistribute the loopback address in OSPF

We’ll go directly under OSPF and redistribute all the connected interfaces since we only have the loopback and the interface towards R2. Of course it’s recommended to filter the undesired networks during the redistribution, but we’ll skip that for the sake of simplicity.

R3#show run int lo0
interface Loopback0
 ip address 3.3.3.3 255.255.255.0

router ospf 1
redistribute connected subnets

and finally, R3 is now flooding an external LSA for 3.3.3.0/24

R3#show ip ospf database external 3.3.3.0 self-originate

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

                Type-5 AS External Link States

  LS age: 139
  Options: (No TOS-capability, DC)
  LS Type: AS External Link
  Link State ID: 3.3.3.0 (External Network Number )
  Advertising Router: 3.3.3.3
  LS Seq Number: 80000001
  Checksum: 0x216A
  Length: 36
  Network Mask: /24
        Metric Type: 2 (Larger than any link state path)
        TOS: 0
        Metric: 20
        Forward Address: 0.0.0.0
        External Route Tag: 0


And here’s how R1 see it

R1#show ip route 3.3.3.0
Routing entry for 3.3.3.0/24
  Known via "ospf 1", distance 110, metric 20, type extern 2, forward metric 20
  Last update from 10.0.12.2 on FastEthernet0/0, 00:04:09 ago
  Routing Descriptor Blocks:
  * 10.0.12.2, from 3.3.3.3, 00:04:09 ago, via FastEthernet0/0
      Route metric is 20, traffic share count is 1


Notice that by default, OSPF redistributes external network as a Type-2 with a seed metric of 20. So depending on your design, make sure you convert that to Type-1 if you need that metric to increment throughout your network.



No comments:

Post a Comment