Thursday, November 1, 2012

OSPF max-metric command

The usage of max-metric router-lsa eluded me, so I labbed it up.  Here's our topology:



As usual, X represents the router number. 
 
OSPF is running on all links in the topology, including R4's loopback.  Our test traffic flow will be travelling from R1 to R4.  Traffic has been manually preffed to go R1 -> R2 -> R4:
 
R1:
interface FastEthernet0/0
 ip ospf cost 10000
 

R1#trace 4.4.4.4

Type escape sequence to abort.
Tracing the route to 4.4.4.4

  1 192.168.0.2 60 msec 24 msec 32 msec
  2 192.168.2.4 64 msec *  84 msec
Now, let's say we had to take R2 down for maintenance.  If we just walk over and unplug the router, we'll be down for the time it takes to notice the router went down, plus reconvergence time.  Let's even give it a try.  I'll shut down R2's Fa0/0 while pinging.
 
R1#ping 4.4.4.4 repeat 100000
 
Type escape sequence to abort.
Sending 100000, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
!!!!!!!!!!...!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
We lost about 3 pings there during the reconverge.  Maybe not a problem at 2am, but if you wanted to do maintenance in the afternoon.... (but none of us do that, right?)
 
Instead of just shutting the router off, we could use max-metric router-lsa on R2.  This feature is called the "stub router advertisement" - confusing, I know - not to be confused with stub areas! This feature will advertise R2's router LSA with the maximum metric, making it least likely as a transit router.  This may seem a tad unnecessary in such a small lab - you could always just manipulate the cost on the links - but imagine a complex network where it's hard to track down all the paths in and out of a multi-interface router.  max-metric router-lsa gives you the best chances of not blackholing traffic.  Let's give it a try.
 
R2:
router ospf 1
 max-metric router-lsa
 
Let's check that LSA from R1 now.
 
R1#sh ip ospf database router 192.168.2.2
 
            OSPF Router with ID (192.168.1.1) (Process ID 1)
 
                Router Link States (Area 0)
 
  LS age: 634
  Options: (No TOS-capability, DC)
  LS Type: Router Links
  Link State ID: 192.168.2.2
  Advertising Router: 192.168.2.2
  LS Seq Number: 8000000C
  Checksum: 0x147A
  Length: 48
  Number of Links: 2
 
    Link connected to: a Transit Network
     (Link ID) Designated Router address: 192.168.2.2
     (Link Data) Router Interface address: 192.168.2.2
      Number of TOS metrics: 0
       TOS 0 Metrics: 65535
 
    Link connected to: a Transit Network
     (Link ID) Designated Router address: 192.168.0.1
     (Link Data) Router Interface address: 192.168.0.2
      Number of TOS metrics: 0
       TOS 0 Metrics: 65535
Now that's a big metric that R2 is advertising!  Maximum, actually - 65535.
 
R1:
trace 4.4.4.4
 
Type escape sequence to abort.
Tracing the route to 4.4.4.4
 
  1 192.168.1.3 68 msec 32 msec 28 msec
  2 192.168.3.4 68 msec *  88 msec
Great, traffic is going the other way... I could post ping statistics, but if you've read this far in, I'm sure you're following.
 
This command has several extra parameters we can specify.
 
max-metric router-lsa on-startup wait-for-bgp
 
I dig this one.  Don't try to become a transit router until BGP is fully converged.  Waits for keepalives from BGP (indicates convergence is over) before dropping the max-metric.  The benefit here is fairly obvious, consider a scenario where OSPF is originating a default, but a series of BGP links provides your back-end connectivity.  We wouldn't want OSPF to become the best default (consider a scenario where other defaults are being originated on other OSPF routers) until BGP converged.
 
max-metric router-lsa on-startup <time>
 
I deliberately put this one after wait-for-bgp.  Obviously there's a direct plugin for BGP on the max-metric command, but what if you needed to wait for some other protocol to converge?  This lets you set an arbitrary time before the max-metric is dropped.
 
max-metric router-lsa summary-lsa
 
...override the summary-lsa as well as the router-lsa.
 
max-metric router-lsa external-lsa
 
...override the external-lsa as well
 
max-metric router-lsa include-stub
 
If you have more than one router advertising a stub area, you can optionally depref the stub area as well.
 
Enjoy...
 
Jeff Kronlage
 
 

3 comments: