WALKTHROUGH: OSPF Route Preference

So you're stuck or don't trust your work. Here is the cheat/check page. Note that this is all done from the perspective of J2300-1. Adapt to other routers as needed.

  1. Locate a destination in your routing table which has multiple equal cost paths and was populated by OSPF
  2. admin@J2300-1> show route 
    
    inet.0: 49 destinations, 49 routes (49 active, 0 holddown, 0 hidden)
    + = Active Route, - = Last Active, * = Both
    
    3.3.3.0/24         *[OSPF/150] 00:01:13, metric 12610, tag 3
                        > to 10.1.111.101 via fe-0/0/1.1001
    4.4.4.0/24         *[OSPF/150] 22:23:07, metric 1000, tag 4
                        > to 10.1.111.101 via fe-0/0/1.1001
    5.1.1.0/25         *[Static/5] 03:33:46
                          Receive
    5.2.1.0/25         *[Static/5] 03:33:17
                          Receive
    5.5.5.0/24         *[OSPF/150] 17:03:05, metric 3515, tag 5
                        > to 10.0.12.2 via fe-0/0/1.12
    7.7.7.0/24         *[OSPF/150] 17:03:05, metric 1000, tag 7
                          to 10.0.12.2 via fe-0/0/1.12
                        > to 10.0.13.3 via fe-0/0/1.13
    10.0.0.1/32        *[Direct/0] 1d 06:04:19
                        > via lo0.0
    10.0.0.2/32        *[OSPF/10] 01:03:21, metric 5
                        > to 10.0.12.2 via fe-0/0/1.12
    10.0.0.3/32        *[OSPF/10] 01:03:21, metric 5
                        > to 10.0.13.3 via fe-0/0/1.13
                                            
    admin@J2300-1> 
    

    7.7.7.0 has more than one potential next hop.

  3. For areas 0.0.0.1, 0.0.0.2 and 0.0.0.3, log into one of those areas internal routers that connects to an ABR for which your router serves as the ABR
  4. Login using the router name for the username, and juniper123 for the password.

    user@mgmtbox~ $ ssh R2@10.99.10.2
    R2@10.99.10.2's password: 
    --- JUNOS 10.4R6.5 built 2011-07-23 10:01:44 UTC
    R2@LR:R2> 
    
  5. What is the best route from one side of the area to the other side? (i.e. from R1 to R2 in area 0.0.0.1, R6 to R8 in area 0.0.0.2 or R9 to R10 in area 0.0.0.3?
  6. R2@LR:R2> show route 10.1.0.1    
    
    inet.0: 50 destinations, 50 routes (50 active, 0 holddown, 0 hidden)
    + = Active Route, - = Last Active, * = Both
    
    10.1.0.1/32        *[OSPF/150] 00:01:25, metric 10020, tag 0
                        > to 10.1.23.103 via fxp4.123
    
    R2@LR:R2> 
    

    Best route points to R3.

  7. Perform a traceroute from one side of the area to the other and confirm the path
  8. R2@LR:R2> traceroute 10.1.0.1 no-resolve    
    traceroute to 10.1.0.1 (10.1.0.1), 30 hops max, 40 byte packets
     1  10.1.23.103  0.652 ms  0.561 ms  0.534 ms
     2  10.1.34.104  0.846 ms  0.783 ms  0.829 ms
     3  10.1.0.1  1.159 ms  1.089 ms  1.114 ms
    
    R2@LR:R2> 
    

    Trace goes to R3, to R4 to R1.

  9. For your area, configure the backbone link that connects the two ABRs together to participate in another area without harming the integrity of your backbone
  10. admin@J2300-1> edit 
    Entering configuration mode
    
    [edit]
    admin@J2300-1# edit protocols ospf area 1 
    
    [edit protocols ospf area 0.0.0.1]
    admin@J2300-1# set interface fe-0/0/1.13 secondary 
    
    [edit protocols ospf area 0.0.0.1]
    admin@J2300-1# commit 
    commit complete
    
    [edit protocols ospf area 0.0.0.1]
    admin@J2300-1# run show ospf neighbor 
    Address          Interface              State     ID               Pri  Dead
    10.0.12.2        fe-0/0/1.12            Full      10.0.0.2         128    35
      Area 0.0.0.0
    10.0.13.3        fe-0/0/1.13            Full      10.0.0.3         128    32
      Area 0.0.0.0
    10.1.111.101     fe-0/0/1.1001          Full      10.1.0.1         128    10
      Area 0.0.0.1
    10.0.13.3        fe-0/0/1.13            Full      10.0.0.3         128    32
      Area 0.0.0.1
    10.101.0.6       fe-0/0/1.101           Full      10.0.0.6         128    34
      Area 101.101.101.101
    10.101.0.5       fe-0/0/1.101           Full      10.0.0.5         128    34
      Area 101.101.101.101
    10.101.0.4       fe-0/0/1.101           Full      10.0.0.4         128    36
      Area 101.101.101.101
    10.101.0.3       fe-0/0/1.101           Full      10.0.0.3         128    35
      Area 101.101.101.101
    10.101.0.2       fe-0/0/1.101           Full      10.0.0.2         128    34
      Area 101.101.101.101
    10.101.0.10      fe-0/0/1.101           Full      10.10.10.10      128    38
      Area 101.101.101.101
    10.102.0.6       fe-0/0/1.102           Full      10.0.0.6         128    32
      Area 102.102.102.102
    10.102.0.5       fe-0/0/1.102           Full      10.0.0.5         128    37
      Area 102.102.102.102
    10.102.0.4       fe-0/0/1.102           Full      10.0.0.4         128    32
      Area 102.102.102.102
    10.102.0.3       fe-0/0/1.102           Full      10.0.0.3         128    38
      Area 102.102.102.102
    10.102.0.2       fe-0/0/1.102           Full      10.0.0.2         128    32
      Area 102.102.102.102
    10.102.0.10      fe-0/0/1.102           Full      10.10.10.10      128    34
      Area 102.102.102.102
    10.30.30.6       fe-0/0/1.100           Full      10.0.0.6         255    36
      Area 30.30.30.30
    10.30.30.5       fe-0/0/1.100           Init      10.0.0.5         255    35
      Area 30.30.30.30
    10.30.0.4        fe-0/0/1.100           Full      10.0.0.4         255    35
      Area 30.30.30.30
    10.30.30.3       fe-0/0/1.100           Full      10.0.0.3         255    32
      Area 30.30.30.30
    10.30.30.2       fe-0/0/1.100           Full      10.0.0.2         255    32
      Area 30.30.30.30
    10.30.0.5        fe-0/0/1.100           Full      10.0.0.5         255    33
      Area 30.30.30.30
    10.30.30.30      fe-0/0/1.100           Full      99.99.99.99      199    32
      Area 30.30.30.30                      
    
    [edit protocols ospf area 0.0.0.1]
    admin@J2300-1# 
    
  11. What is the best route from one side of the area to the other side? (i.e. from R1 to R2 in area 0.0.0.1, R6 to R8 in area 0.0.0.2 or R9 to R10 in area 0.0.0.3?
  12. R2@LR:R2> show route 10.1.0.1               
    
    inet.0: 50 destinations, 50 routes (50 active, 0 holddown, 0 hidden)
    + = Active Route, - = Last Active, * = Both
    
    10.1.0.1/32        *[OSPF/150] 00:00:50, metric 5010, tag 0
                        > to 10.1.123.3 via fe-0/0/1.1003
    
    R2@LR:R2> 
    

    Best route is now via J2300-3.

  13. Perform a traceroute from one side of the area to the other and confirm the path is more efficient
  14. R2@LR:R2> traceroute 10.1.0.1 no-resolve    
    traceroute to 10.1.0.1 (10.1.0.1), 30 hops max, 40 byte packets
     1  10.1.123.3  0.683 ms  0.456 ms  0.532 ms
     2  10.0.13.1  0.649 ms  1.481 ms  0.742 ms
     3  10.1.0.1  1.245 ms  1.176 ms  1.244 ms
    
    R2@LR:R2> 
    

    Trace now goes from J2300-3, to J2300-1, to R1

  15. Compare your Router LSA that is being advertised into the backbone with the Router LSA that is being advertised into area 0.0.0.1, 0.0.0.2 or 0.0.0.3
  16. admin@J2300-1> show ospf database router lsa-id 10.0.0.1 area 0 detail 
    
        OSPF database, Area 0.0.0.0
     Type       ID               Adv Rtr           Seq      Age  Opt  Cksum  Len 
    Router  *10.0.0.1         10.0.0.1         0x80000048   193  0x22 0xc755  72
      bits 0x3, link count 4
      id 10.0.0.2, data 10.0.12.1, Type PointToPoint (1)
        Topology count: 0, Default metric: 5
      id 10.0.12.0, data 255.255.255.0, Type Stub (3)
        Topology count: 0, Default metric: 5
      id 10.0.0.3, data 10.0.13.1, Type PointToPoint (1)
        Topology count: 0, Default metric: 5
      id 10.0.13.0, data 255.255.255.0, Type Stub (3)
        Topology count: 0, Default metric: 5
      Topology default (ID 0)
        Type: PointToPoint, Node ID: 10.0.0.3
          Metric: 5, Bidirectional
        Type: PointToPoint, Node ID: 10.0.0.2
          Metric: 5, Bidirectional
    
    admin@J2300-1> show ospf database router lsa-id 10.0.0.1 area 1 detail    
    
        OSPF database, Area 0.0.0.1
     Type       ID               Adv Rtr           Seq      Age  Opt  Cksum  Len 
    Router  *10.0.0.1         10.0.0.1         0x80000046   212  0x22 0x7906  48
      bits 0x3, link count 2
      id 10.1.111.101, data 10.1.111.1, Type Transit (2)
        Topology count: 0, Default metric: 2500
      id 10.0.0.3, data 0.0.0.68, Type PointToPoint (1)
        Topology count: 0, Default metric: 2500
      Topology default (ID 0)
        Type: PointToPoint, Node ID: 10.0.0.3
          Metric: 2500, Bidirectional
        Type: Transit, Node ID: 10.1.111.101
          Metric: 2500, Bidirectional
    
    admin@J2300-1> 
    

    The PointToPoint link (Type 1) between J2300-1 and J2300-3 is listed in both LSAs, but only the LSA announced to the backbone has Stub route (Type 3) announcing the IP address space of the link.

  17. Change your router to prefer BGP routes more than OSPF external routes (Hint: BGP has a default preference of 170 in Junos)
  18. admin@J2300-1> show route protocol ospf                 
    
    inet.0: 49 destinations, 49 routes (49 active, 0 holddown, 0 hidden)
    + = Active Route, - = Last Active, * = Both
    
    3.3.3.0/24         *[OSPF/150] 00:05:53, metric 5110, tag 3
                        > to 10.0.13.3 via fe-0/0/1.13
    4.4.4.0/24         *[OSPF/150] 22:39:22, metric 1000, tag 4
                        > to 10.1.111.101 via fe-0/0/1.1001
    5.5.5.0/24         *[OSPF/150] 17:19:20, metric 3515, tag 5
                        > to 10.0.12.2 via fe-0/0/1.12
    7.7.7.0/24         *[OSPF/150] 17:19:20, metric 1000, tag 7
                          to 10.0.12.2 via fe-0/0/1.12
                        > to 10.0.13.3 via fe-0/0/1.13
    10.0.0.2/32        *[OSPF/10] 01:19:36, metric 5
                        > to 10.0.12.2 via fe-0/0/1.12
    10.0.0.3/32        *[OSPF/10] 01:19:36, metric 5
                        > to 10.0.13.3 via fe-0/0/1.13
    10.0.0.4/32        *[OSPF/10] 01:19:36, metric 10
                        > to 10.0.12.2 via fe-0/0/1.12
                          to 10.0.13.3 via fe-0/0/1.13
    10.0.0.5/32        *[OSPF/10] 01:19:36, metric 10
                        > to 10.0.13.3 via fe-0/0/1.13
    10.0.0.6/32        *[OSPF/10] 01:19:36, metric 15
                                            
    admin@J2300-1> edit 
    Entering configuration mode
    
    [edit]
    admin@J2300-1# set protocols ospf external-preference 171 
    
    [edit]
    admin@J2300-1# commit and-quit 
    commit complete
    Exiting configuration mode
    
    admin@J2300-1> show route protocol ospf    
    
    inet.0: 49 destinations, 49 routes (49 active, 0 holddown, 0 hidden)
    + = Active Route, - = Last Active, * = Both
    
    3.3.3.0/24         *[OSPF/171] 00:00:07, metric 5110, tag 3
                        > to 10.0.13.3 via fe-0/0/1.13
    4.4.4.0/24         *[OSPF/171] 00:00:07, metric 1000, tag 4
                        > to 10.1.111.101 via fe-0/0/1.1001
    5.5.5.0/24         *[OSPF/171] 00:00:07, metric 3515, tag 5
                        > to 10.0.12.2 via fe-0/0/1.12
    7.7.7.0/24         *[OSPF/171] 00:00:07, metric 1000, tag 7
                        > to 10.0.12.2 via fe-0/0/1.12
                          to 10.0.13.3 via fe-0/0/1.13
    10.0.0.2/32        *[OSPF/10] 01:19:58, metric 5
                        > to 10.0.12.2 via fe-0/0/1.12
    10.0.0.3/32        *[OSPF/10] 01:19:58, metric 5
                        > to 10.0.13.3 via fe-0/0/1.13
    10.0.0.4/32        *[OSPF/10] 01:19:58, metric 10
                        > to 10.0.12.2 via fe-0/0/1.12
                          to 10.0.13.3 via fe-0/0/1.13
    10.0.0.5/32        *[OSPF/10] 01:19:58, metric 10
                        > to 10.0.13.3 via fe-0/0/1.13
    10.0.0.6/32        *[OSPF/10] 01:19:58, metric 15
                                            
    admin@J2300-1> 
    
  19. Advertise your loopback interface out as part of your Router LSA
  20. admin@J2300-1> edit   
    Entering configuration mode
    
    [edit]
    admin@J2300-1# set protocols ospf area 0 interface lo0 passive 
    
    [edit]
    admin@J2300-1# commit 
    commit complete
    
    [edit]
    admin@J2300-1# 
    [edit]
    
  21. Is your router still sending External LSAs out advertising your Loopback interface?
  22. admin@J2300-1# run show ospf database external lsa-id 10.0.0.1 
        OSPF AS SCOPE link state database
     Type       ID               Adv Rtr           Seq      Age  Opt  Cksum  Len 
    Extern  *10.0.0.1         10.0.0.1         0x80000006   269  0x22 0xa8d   36
    
    [edit]
    admin@J2300-1# 
    Yes, because the export policy is still applied.
    

    Yes, because the export policy is still applied.