OSPF Stub Router

OSPF has a stub router feature (don’t confuse this with stub areas) that lets you prevent a router from being a transit router. Here’s an example of why you might want to use this:

ospf stub router example topology

Above we have three routers, running OSPF. R2 and R3 advertise a default route in OSPF and also run BGP. OSPF converges faster than BGP so if you reload R2 or R3, it is possible that packets get dropped because BGP hasn’t converged yet but OSPF is already advertising its default route.  To prevent this, we can configure OSPF to (temporarily) set the metric to its maximum value. You can do this until BGP converges, for a certain period, or even permanent.







Let’s look at a configuration example. I use the following topology:

ospf area 0 four routers stub feature

Above we have four routers in area 0. R4 has a loopback interface that we try to reach from R1. I increased the cost of R3’s Gigabit 0/1 interface so that the path through R2 is preferred:

R1#show ip route ospf

      4.0.0.0/32 is subnetted, 1 subnets
O        4.4.4.4 [110/3] via 192.168.12.2, 00:01:44, GigabitEthernet0/1
O     192.168.24.0/24 [110/2] via 192.168.12.2, 00:01:44, GigabitEthernet0/1
O     192.168.34.0/24 [110/3] via 192.168.12.2, 00:01:44, GigabitEthernet0/1

As you can see above, R1 uses R2 to reach 4.4.4.4/32. Here’s the router LSA that R2 advertises:

R1#show ip ospf database router 2.2.2.2

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

                Router Link States (Area 0)

  LS age: 139
  Options: (No TOS-capability, DC)
  LS Type: Router Links
  Link State ID: 2.2.2.2
  Advertising Router: 2.2.2.2
  LS Seq Number: 80000006
  Checksum: 0xF322
  Length: 48
  Number of Links: 2

    Link connected to: a Transit Network
     (Link ID) Designated Router address: 192.168.24.4
     (Link Data) Router Interface address: 192.168.24.2
      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.2
      Number of MTID metrics: 0
       TOS 0 Metrics: 1

All links that R2 advertises have a cost of one. Let’s see if we can configure R2 so that it doesn’t want to be a transit router.  We can use the max-metric router-lsa command to implement this:

R2(config)#router ospf 1
(config-router)#max-metric router-lsa ?
  external-lsa  Override external-lsa metric with max-metric value
  include-stub  Set maximum metric for stub links in router-LSAs
  on-startup    Set maximum metric temporarily after reboot
  summary-lsa   Override summary-lsa metric with max-metric value
  <cr>

There are a number of options you can choose from. The on-startup options let you set the maximum metric temporarily when OSPF has started or until BGP has converged. We will keep it simple for now and enable max-metric permanently:

R2(config-router)#max-metric router-lsa

We can verify that it is enabled:

R2#show ip ospf | begin Originating  
 Originating router-LSAs with maximum metric
    Condition: always, State: active

R1 will now prefer R3 instead of R2:

R1#show ip route ospf

      4.0.0.0/32 is subnetted, 1 subnets
O        4.4.4.4 [110/12] via 192.168.13.3, 00:00:09, GigabitEthernet0/2
O     192.168.24.0/24 [110/12] via 192.168.13.3, 00:00:09, GigabitEthernet0/2
O     192.168.34.0/24 [110/11] via 192.168.13.3, 00:00:09, GigabitEthernet0/2

Let’s take a closer look to see what R2 has changed in its router LSA:

R1#show ip ospf database router 2.2.2.2

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

                Router Link States (Area 0)

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

    Link connected to: a Transit Network
     (Link ID) Designated Router address: 192.168.24.4
     (Link Data) Router Interface address: 192.168.24.2
      Number of MTID metrics: 0
       TOS 0 Metrics: 65535

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

As you can see above, the metric is set to 65535 which makes it very unlikely that R2 will be used as a transit router. I enabled this permanently but if you want to enable it temporarily, you can do it like this:

R1(config-router)#max-metric router-lsa on-startup ?
  <5-86400>     Time, in seconds, router-LSAs are originated with max-metric
  wait-for-bgp  Let BGP decide when to originate router-LSA with normal metric

If you use the wait-for-bgp option. The router will set the max metric until BGP has converged or until 10 minutes have elapsed since OSPF started. That’s all there is to it!

We're Sorry, Full Content Access is for Members Only...

If you like to keep on reading, Become a Member Now! Here is why:

  • Learn any CCNA, CCNP and CCIE R&S Topic. Explained As Simple As Possible.
  • Try for Just $1. The Best Dollar You’ve Ever Spent on Your Cisco Career!
  • Full Access to our 785 Lessons. More Lessons Added Every Week!
  • Content created by Rene Molenaar (CCIE #41726)

1837 Sign Ups in the last 30 days

satisfaction-guaranteed
100% Satisfaction Guaranteed!
You may cancel your monthly membership at any time.
No Questions Asked!

Tags:


Forum Replies

  1. Hi rene,
    How to confirm no transit traffic on the router after performing cmd max-metric router-lsa? My network is big and i cant afford to check one by one via traceroute…
    Thanks…

  2. Hello Nor

    There’s no set way how to check that routing is being performed correctly on an overall OSPF topology. It may be necessary to check each individual router to ensure that routing is being performed as you desire.

    This is an issue that must be faced with any large network that employs routing. How do you manage such a network with potentially hundreds of routers without having to inspect each individual router? Well, there are a couple of approaches, but all rely on a sound initial design plan.

    For OSPF, creating a scalable network requires that you

    ... Continue reading in our forum

Ask a question or join the discussion by visiting our Community Forum