Monday, 20 February 2012

Juniper IS-IS Routing Policy

Note: This is Juniper Junos related article, and IS-IS is not on the CCIE R&S Blueprint anyway :)

This post is a bit of a recap on using IS-IS on Juniper routers.

To enable IS-IS, on the physical interfaces besides adding the inet family to enable IPv4 addressing, the iso family also requires enabling, this way IS-IS related frames will not be discarded by the router.  Once this is done, we need to set a NSAP address on one of the interfaces (typically this would be loopback0 unit 0) which specifies what IS-IS area this router lives in.  Unlike OSPF where area membership is on a link by link basis, an IS-IS router is normally a member of a single area.

Inter-area communications can occur on Level 2 routers, when Intra-Area communications can occur on Level 1 routers (IS-IS routers that are both Level 1 and Level 2 routers are much like an OSPF ABR)

In this topology we have 4 routers existing in two areas.  R1 and R2 are in area 12 while R3 and R4 are in area 34

R1(Area 12)--L1-(Area 12)R2(Area 12)--L2--(Area 34)R3(Area 34)--L1--(L1 Area 34)R4

To derive the System IDs I followed the general method to looking at the router id, inserted leading zeroes where necessary and removing the dots to the string is 12 characters long.

e.g. 1.23.123.4 would become 001023123004  then a dot would be added every 4th character resulting in a System ID of 0010.2312.3004  to generate the lo0.0 NSAP address we prepend the area and append the selector (00)

By Disabling IS-IS Level 2 on R1, R1 is a Level 1 only Router:

root@R1> show configuration | display set
set system host-name R1
set interfaces em1 vlan-tagging
set interfaces em1 unit 12 vlan-id 12
set interfaces em1 unit 12 family inet address 10.1.12.1/24
set interfaces em1 unit 12 family iso
set interfaces lo0 unit 0 family inet address 1.1.1.1/32
set interfaces lo0 unit 0 family iso address 12.0010.0100.1001.00
set routing-options router-id 1.1.1.1
set protocols isis level 2 disable
set protocols isis interface em1.12
set protocols isis interface lo0.0 passive

As R1 and R2 are both in the same IS-IS area, they will communicate (but only on Level 1 since R1 has disabled Level 2)

root@R2> show configuration | display set
set system host-name R2
set interfaces em1 vlan-tagging
set interfaces em1 unit 12 vlan-id 12
set interfaces em1 unit 12 family inet address 10.1.12.2/24
set interfaces em1 unit 12 family iso
set interfaces em1 unit 23 vlan-id 23
set interfaces em1 unit 23 family inet address 10.1.23.2/24
set interfaces em1 unit 23 family iso
set interfaces lo0 unit 0 family inet address 2.2.2.2/32
set interfaces lo0 unit 0 family iso address 12.0020.0200.2002.00
set protocols isis interface em1.12
set protocols isis interface em1.23
set protocols isis interface lo0.0 passive

R2 and R3 are in different IS-IS areas and therefore will not communicate on Level 1 however they will at Level 2

root@R3> show configuration | display set
set system host-name R3
set interfaces em1 vlan-tagging
set interfaces em1 unit 23 vlan-id 23
set interfaces em1 unit 23 family inet address 10.1.23.3/24
set interfaces em1 unit 23 family iso
set interfaces em1 unit 34 vlan-id 34
set interfaces em1 unit 34 family inet address 10.1.34.3/24
set interfaces em1 unit 34 family iso
set interfaces lo0 unit 0 family inet address 3.3.3.3/32
set interfaces lo0 unit 0 family iso address 34.0030.0300.3003.00
set routing-options router-id 3.3.3.3
set protocols isis interface em1.23
set protocols isis interface em1.34
set protocols isis interface lo0.0 passive

As R3 and R4 are both in the same IS-IS area, they will communicate (but only on Level 1 since R4 has disabled Level 2)


root@R4> show configuration | display set
set system host-name R4
set interfaces em1 vlan-tagging
set interfaces em1 unit 34 vlan-id 34
set interfaces em1 unit 34 family inet address 10.1.34.4/24
set interfaces em1 unit 34 family iso
set interfaces lo0 unit 0 family inet address 4.4.4.4/32
set interfaces lo0 unit 0 family iso address 34.0040.0400.4004.00
set routing-options router-id 4.4.4.4
set protocols isis level 2 disable
set protocols isis interface em1.34
set protocols isis interface lo0.0 passive



Lets check the IS-IS interface state and adjacencies for each of the routers


root@R1> show isis interface
IS-IS interface database:
Interface             L CirID Level 1 DR        Level 2 DR        L1/L2 Metric
em1.12                1   0x2 R1.02             Disabled               10/10
lo0.0                 0   0x1 Passive           Passive                 0/0

root@R1> show isis adjacency
Interface             System         L State        Hold (secs) SNPA
em1.12                R2             1  Up                   21  8:0:27:9:ed:8

root@R2> show isis interface
IS-IS interface database:
Interface             L CirID Level 1 DR        Level 2 DR        L1/L2 Metric
em1.12                3   0x1 R1.02             R2.00                  10/10
em1.23                3   0x1 R2.00             R3.02                  10/10
lo0.0                 0   0x1 Passive           Passive                 0/0

root@R2> show isis adjacency
Interface             System         L State        Hold (secs) SNPA
em1.12                R1             1  Up                    6  8:0:27:e9:be:75
em1.23                R3             2  Up                    7  8:0:27:21:fd:cf

root@R3> show isis interface
IS-IS interface database:
Interface             L CirID Level 1 DR        Level 2 DR        L1/L2 Metric
em1.23                3   0x2 R3.00             R3.02                  10/10
em1.34                3   0x1 R4.02             R3.00                  10/10
lo0.0                 0   0x1 Passive           Passive                 0/0

root@R3> show isis adjacency
Interface             System         L State        Hold (secs) SNPA
em1.23                R2             2  Up                   23  8:0:27:9:ed:8
em1.34                R4             1  Up                    7  8:0:27:55:b6:d1

root@R4> show isis interface
IS-IS interface database:
Interface             L CirID Level 1 DR        Level 2 DR        L1/L2 Metric
em1.34                1   0x2 R4.02             Disabled               10/10
lo0.0                 0   0x1 Passive           Passive                 0/0

root@R4> show isis adjacency
Interface             System         L State        Hold (secs) SNPA
em1.34                R3             1  Up                   22  8:0:27:21:fd:


So we can see that the connectivity and adjacencies appear connect  (By the way if you saw L3 for some interfaces e.g. on R2 and R3 that is because they are operating at both L1 and L2)

R1 and R4 will appear to be existing in the equivalent of an OSPF totally stubby area

root@R1> show route table inet.0 terse

inet.0: 6 destinations, 6 routes (6 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

A Destination        P Prf   Metric 1   Metric 2  Next hop        AS path
* 0.0.0.0/0          I  15         10            >10.1.12.2
* 1.1.1.1/32         D   0                       >lo0.0
* 2.2.2.2/32         I  15         10            >10.1.12.2
* 10.1.12.0/24       D   0                       >em1.12
* 10.1.12.1/32       L   0                        Local
* 10.1.23.0/24       I  15         20            >10.1.12.2


root@R4> show route table inet.0 terse

inet.0: 6 destinations, 6 routes (6 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

A Destination        P Prf   Metric 1   Metric 2  Next hop        AS path
* 0.0.0.0/0          I  15         10            >10.1.34.3
* 3.3.3.3/32         I  15         10            >10.1.34.3
* 4.4.4.4/32         D   0                       >lo0.0
* 10.1.23.0/24       I  15         20            >10.1.34.3
* 10.1.34.0/24       D   0                       >em1.34
* 10.1.34.4/32       L   0                        Local


There is a default route installed by R1 due to R2 advertising its "Attached" status

root@R1> show isis database
IS-IS level 1 link-state database:
LSP ID                      Sequence Checksum Lifetime Attributes
R1.00-00                         0xc   0x3127      559 L1
R1.02-00                         0xb   0x4377      559 L1
R2.00-00                        0x11   0x7895      502 L1 L2 Attached
  3 LSPs

IS-IS level 2 link-state database:
  0 LSPs

And the same occurs for R4 due to R3 advertising its "Attached" status

root@R4> show isis database
IS-IS level 1 link-state database:
LSP ID                      Sequence Checksum Lifetime Attributes
R3.00-00                         0x8   0xfd36      486 L1 L2 Attached
R4.00-00                         0x5   0xc94a      488 L1
R4.02-00                         0x5   0x1039      488 L1
  3 LSPs

IS-IS level 2 link-state database:
  0 LSPs

R2 and R3 both have full routing table visibility

root@R2> show route table inet.0 terse

inet.0: 9 destinations, 9 routes (9 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

A Destination        P Prf   Metric 1   Metric 2  Next hop        AS path
* 1.1.1.1/32         I  15         10            >10.1.12.1
* 2.2.2.2/32         D   0                       >lo0.0
* 3.3.3.3/32         I  18         10            >10.1.23.3
* 4.4.4.4/32         I  18         20            >10.1.23.3
* 10.1.12.0/24       D   0                       >em1.12
* 10.1.12.2/32       L   0                        Local
* 10.1.23.0/24       D   0                       >em1.23
* 10.1.23.2/32       L   0                        Local
* 10.1.34.0/24       I  18         20            >10.1.23.3

root@R3> show route table inet.0 terse

inet.0: 9 destinations, 9 routes (9 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

A Destination        P Prf   Metric 1   Metric 2  Next hop        AS path
* 1.1.1.1/32         I  18         20            >10.1.23.2
* 2.2.2.2/32         I  18         10            >10.1.23.2
* 3.3.3.3/32         D   0                       >lo0.0
* 4.4.4.4/32         I  15         10            >10.1.34.4
* 10.1.12.0/24       I  18         20            >10.1.23.2
* 10.1.23.0/24       D   0                       >em1.23
* 10.1.23.3/32       L   0                        Local
* 10.1.34.0/24       D   0                       >em1.34
* 10.1.34.3/32       L   0                        Local

Enabling R1 to communicate with R4

root@R1> ping 4.4.4.4 source 1.1.1.1 count 3
PING 4.4.4.4 (4.4.4.4): 56 data bytes
64 bytes from 4.4.4.4: icmp_seq=0 ttl=62 time=2.672 ms
64 bytes from 4.4.4.4: icmp_seq=1 ttl=62 time=1.781 ms
64 bytes from 4.4.4.4: icmp_seq=2 ttl=62 time=1.719 ms

--- 4.4.4.4 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max/stddev = 1.719/2.057/2.672/0.435 ms

So far a long story without the promised policy configuration.

Firstly, lets decide that R4 should not have a default route installed installed in its routing table.  The way we do this is by telling the router not to pay attention to the attached bit in the LSA from the L2 router

root@R4> configure
Entering configuration mode

[edit]
root@R4# set protocols isis ignore-attached-bit

[edit]
root@R4# commit and-quit
commit complete
Exiting configuration mode

root@R4> show isis database
IS-IS level 1 link-state database:
LSP ID                      Sequence Checksum Lifetime Attributes
R3.00-00                         0x8   0xfd36      424 L1 L2 Attached
R4.00-00                         0x6   0xa46e     1182 L1
R4.02-00                         0x6    0xe3a     1182 L1
  3 LSPs

IS-IS level 2 link-state database:
  0 LSPs


So we're still receiving the Attached bit because we haven't stopped R3 from advertising it, we're just not actioning it..

root@R4> show route table inet.0 terse

inet.0: 5 destinations, 5 routes (5 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

A Destination        P Prf   Metric 1   Metric 2  Next hop        AS path
* 3.3.3.3/32         I  15         10            >10.1.34.3
* 4.4.4.4/32         D   0                       >lo0.0
* 10.1.23.0/24       I  15         20            >10.1.34.3
* 10.1.34.0/24       D   0                       >em1.34
* 10.1.34.4/32       L   0                        Local

Okay, so the default route is gone, however we no longer have routes beyond R3.  The way we can work around this is to do controlled leaking of routes from L2 to L1 using routing policy.

In this initial example we'll allow R1 lo0.0's IP address to leak from L2 to L1 and therefore visible by R4

root@R3> configure
Entering configuration mode

[edit]
root@R3# edit policy-options policy-statement R1toR4

[edit policy-options policy-statement R1toR4]
root@R3# set term 10 from protocol isis
root@R3# set term 10 from level 2
root@R3# set term 10 from route-filter 1.1.1.1/32 exact
root@R3# set term 10 to level 1
root@R3# set term 10 then accept
root@R3# set term 20 from protocol isis
root@R3# set term 20 from level 2
root@R3# set term 20 to level 1
root@R3# set term 20 then reject
[edit policy-options policy-statement R1toR4]
root@R3# up

[edit policy-options]

root@R3# show
policy-statement R1toR4 {
    term 10 {
        from {
            protocol isis;
            level 2;
            route-filter 1.1.1.1/32 exact;
        }
        to level 1;
        then accept;
    }
    term 20 {
        from {
            protocol isis;
            level 2;
        }
        to level 1;
        then reject;
    }
}




Specifically we're only allowing the L2 1.1.1.1/32 route to be send to L1.  So lets apply this to IS-IS

[edit policy-options]
root@R3# top

[edit]
root@R3# set protocols isis export R1toR4

[edit]
root@R3# commit and-quit
commit complete
Exiting configuration mode
So are we now seeing this route on R4?

root@R4> show route table inet.0 terse

inet.0: 6 destinations, 6 routes (6 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

A Destination        P Prf   Metric 1   Metric 2  Next hop        AS path
* 1.1.1.1/32         I  18         30            >10.1.34.3
* 3.3.3.3/32         I  15         10            >10.1.34.3
* 4.4.4.4/32         D   0                       >lo0.0
* 10.1.23.0/24       I  15         20            >10.1.34.3
* 10.1.34.0/24       D   0                       >em1.34
* 10.1.34.4/32       L   0                        Local

root@R4> ping 1.1.1.1 source 4.4.4.4 count 3
PING 1.1.1.1 (1.1.1.1): 56 data bytes
64 bytes from 1.1.1.1: icmp_seq=0 ttl=62 time=9.980 ms
64 bytes from 1.1.1.1: icmp_seq=1 ttl=62 time=2.042 ms
64 bytes from 1.1.1.1: icmp_seq=2 ttl=62 time=3.662 ms

--- 1.1.1.1 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max/stddev = 2.042/5.228/9.980/3.425 ms

What if we wanted R4 to be also able to reach R2? All we really need to do is to extend the R1toR4 policy on R3 to include R2 Lo0.0

Firstly we need to insert the entry between term 10 and term 20, so firstly we'll rename term 20 to term 30

root@R3> configure
Entering configuration mode

[edit]
root@R3# edit policy-options policy-statement R1toR4

[edit policy-options policy-statement R1toR4]
root@R3# rename term 20 to term 30

[edit policy-options policy-statement R1toR4]
root@R3# show
term 10 {
    from {
        protocol isis;
        level 2;
        route-filter 1.1.1.1/32 exact;
    }
    to level 1;
    then accept;
}
term 30 {
    from {
        protocol isis;
        level 2;
    }
    to level 1;
    then reject;
}

Now we'll add term 20 to allow 2.2.2.2/32

[edit policy-options policy-statement R1toR4]
root@R3# set term 20 from protocol isis level 2 route-filter 2.2.2.2/32 exact
root@R3# set term 20 to level 1
root@R3# set term 20 then accept

[edit policy-options policy-statement R1toR4]
root@R3# show
term 10 {
    from {
        protocol isis;
        level 2;
        route-filter 1.1.1.1/32 exact;
    }
    to level 1;
    then accept;
}
term 30 {
    from {
        protocol isis;
        level 2;
    }
    to level 1;
    then reject;
}
term 20 {
    from {
        protocol isis;
        level 2;
        route-filter 2.2.2.2/32 exact;
    }
    to level 1;
    then accept;
}

We have a slight problem here in that term 20 will be evaluated after term 30 because terms get evaluated in the order they appear in the configuration - term 30 will be evaluated and reject all L2 routes before term 20 can be evaluated.  Thankfully Junos gives up the tools to resolve this.

[edit policy-options policy-statement R1toR4]
root@R3# insert term 20 before term 30

[edit policy-options policy-statement R1toR4]
root@R3# show
term 10 {
    from {
        protocol isis;
        level 2;
        route-filter 1.1.1.1/32 exact;
    }
    to level 1;
    then accept;
}
term 20 {
    from {
        protocol isis;
        level 2;
        route-filter 2.2.2.2/32 exact;
    }
    to level 1;
    then accept;
}
term 30 {
    from {
        protocol isis;
        level 2;
    }
    to level 1;
    then reject;
}

[edit policy-options policy-statement R1toR4]
root@R3# commit and-quit
commit complete
Exiting configuration mode

Lets check that R4 can reach R2

root@R4> show isis route
 IS-IS routing table             Current version: L1: 26 L2: 0
IPv4/IPv6 Routes
----------------
Prefix             L Version   Metric Type Interface       NH   Via
1.1.1.1/32         1      26       30 int  em1.34          IPV4 R3             
2.2.2.2/32         1      26       20 int  em1.34          IPV4 R3             
3.3.3.3/32         1      26       10 int  em1.34          IPV4 R3             
10.1.23.0/24       1      26       20 int  em1.34          IPV4 R3           

root@R4> ping 2.2.2.2 source 4.4.4.4 count 3
PING 2.2.2.2 (2.2.2.2): 56 data bytes
64 bytes from 2.2.2.2: icmp_seq=0 ttl=63 time=9.064 ms
64 bytes from 2.2.2.2: icmp_seq=1 ttl=63 time=3.630 ms
64 bytes from 2.2.2.2: icmp_seq=2 ttl=63 time=3.649 ms

--- 2.2.2.2 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max/stddev = 3.630/5.448/9.064/2.557 ms

Success!

Sunday, 5 February 2012

Juniper OSPF Discontiguous Backbone (Virtual-Links)

Note: This is blog post is part of a series of articles dealing with Juniper Junos rather than Cisco IOS which is what some readers may be expecting. 

Traffic cannot traverse different ospf areas without going through the OSPF backbone and OSPF expects that the backbone area (area 0) is contiguous.  OSPF area membership is interface/link based.

So it is possible to use some kind of virtual technique to logically extend the OSPF backbone.  One of the tools in our toolbox is "virtual-links" which uses a non-backbone area to provide transit capability to an OSPF ABR.

In this example:

R1 is an ABR with lo0.0 in area 0 and em1.12 in area 12
R2 is a normal router with lo0.0 and em1.12 in area 12, with em1.23 in area 23
R3 is a normal router with lo0.0 and em1.23 in area 23

The starting configs are shown below:


R1 (ABR OSPF Area 0 / 23)
root@R1> show configuration | display set
set system host-name R1
set interfaces em1 vlan-tagging
set interfaces em1 unit 12 vlan-id 12
set interfaces em1 unit 12 family inet address 10.1.12.1/24
set interfaces lo0 unit 0 family inet address 1.1.1.1/32
set routing-options router-id 1.1.1.1
set protocols ospf area 0.0.0.0 interface lo0.0
set protocols ospf area 0.0.0.12 interface em1.12

R2 (OSPF Area 12 / 23)
root@R2> show configuration | display set
set system host-name R2
set interfaces em1 vlan-tagging
set interfaces em1 unit 12 vlan-id 12
set interfaces em1 unit 12 family inet address 10.1.12.2/24
set interfaces em1 unit 23 vlan-id 23
set interfaces em1 unit 23 family inet address 10.1.23.2/24
set interfaces lo0 unit 0 family inet address 2.2.2.2/32
set routing-options router-id 2.2.2.2
set protocols ospf area 0.0.0.12 interface em1.12
set protocols ospf area 0.0.0.23 interface em1.23
set protocols ospf area 0.0.0.12 interface lo0.0

R3 (OSPF Area 12 / 23)
root@R3> show configuration | display set
set system host-name R3
set interfaces em1 vlan-tagging
set interfaces em1 unit 23 vlan-id 23
set interfaces em1 unit 23 family inet address 10.1.23.3/24
set interfaces lo0 unit 0 family inet address 3.3.3.3/32
set routing-options router-id 3.3.3.3
set protocols ospf area 0.0.0.0 interface lo0.0
set protocols ospf area 0.0.0.23 interface em1.23


Let's verify OSPF is up and running and we have neighbors

root@R1> show ospf interface
Interface           State   Area            DR ID           BDR ID          Nbrs
lo0.0               DR      0.0.0.0         1.1.1.1         0.0.0.0            0
em1.12              BDR     0.0.0.12        1.1.1.1         2.2.2.2            1

root@R2> show ospf interface
Interface           State   Area            DR ID           BDR ID          Nbrs
em1.23              BDR      0.0.0.23        2.2.2.2         3.3.3.3            1
em1.12              DR      0.0.0.12        1.1.1.1         2.2.2.2            1
lo0.0               DR      0.0.0.12        2.2.2.2         0.0.0.0            0

root@R3> show ospf interface
Interface           State   Area            DR ID           BDR ID          Nbrs
em1.23              DR      0.0.0.23        2.2.2.2         3.3.3.3            1
lo0.0               DR      0.0.0.23        3.3.3.3         0.0.0.0            0

now check the routing table on R1 and R3

root@R1> show route terse

inet.0: 6 destinations, 6 routes (6 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

A Destination        P Prf   Metric 1   Metric 2  Next hop        AS path
* 1.1.1.1/32         D   0                       >lo0.0
* 2.2.2.2/32         O  10          1            >10.1.12.2
* 10.1.12.0/24       D   0                       >em1.12
* 10.1.12.1/32       L   0                        Local
* 10.1.23.0/24       O  10          2            >10.1.12.2
* 224.0.0.5/32       O  10          1             MultiRecv

root@R3> show route terse

inet.0: 6 destinations, 6 routes (6 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

A Destination        P Prf   Metric 1   Metric 2  Next hop        AS path
* 2.2.2.2/32         O  10          1            >10.1.23.2
* 3.3.3.3/32         D   0                       >lo0.0
* 10.1.12.0/24       O  10          2            >10.1.23.2
* 10.1.23.0/24       D   0                       >em1.23
* 10.1.23.3/32       L   0                        Local
* 224.0.0.5/32       O  10          1             MultiRecv
On R1, we cant see a route for 3.3.3.3/32 which is in OSPF Area 23, and on R3, we cant see a route for 1.1.1.1/32 which is in OSPF Area 0, since the connectivity between R1 and R3 traverses OSPF area 12.


To resolve this using virtual-links we need to add the virtual-link configuration to OSPF area 0 (this is implemented differently to the way IOS does it but personally I think this makes it much clearer as to what the configuration is doing, which is extending OSPF 0 to a new ABR)

root@R1> configure
Entering configuration mode

[edit]
root@R1# set protocols ospf area 0 virtual-link neighbor-id 2.2.2.2 transit-area 12
[edit]
root@R1# commit and-quit
commit complete
Exiting configuration mode

root@R2> configure
Entering configuration mode

[edit]
root@R2# set protocols ospf area 0 virtual-link neighbor-id 1.1.1.1 transit-area 12
[edit]
root@R2# commit and-quit
commit complete
Exiting configuration mode

Just to show what the OSPF config on R1 and R2 now looks like

root@R1> show configuration protocols ospf
area 0.0.0.0 {
    virtual-link neighbor-id 2.2.2.2 transit-area 0.0.0.12;
    interface lo0.0;
}
area 0.0.0.12 {
    interface em1.12;
}

root@R2> show configuration protocols ospf
area 0.0.0.23 {
    interface em1.23;
}
area 0.0.0.12 {
    interface lo0.0;
    interface em1.12;
}
area 0.0.0.0 {
    virtual-link neighbor-id 1.1.1.1 transit-area 0.0.0.12;
}


The virtual-link configuration establishes an on-demand point-to-point link

root@R1> show ospf interface
Interface           State   Area            DR ID           BDR ID          Nbrs
lo0.0               DR      0.0.0.0         1.1.1.1         0.0.0.0            0
vl-2.2.2.2          PtToPt  0.0.0.0         0.0.0.0         0.0.0.0            1
em1.12              BDR     0.0.0.12        2.2.2.2         1.1.1.1            1

root@R2> show ospf interface
Interface           State   Area            DR ID           BDR ID          Nbrs
em1.23              BDR     0.0.0.23        3.3.3.3         2.2.2.2            1
em1.12              DR      0.0.0.12        2.2.2.2         1.1.1.1            1
lo0.0               DR      0.0.0.12        2.2.2.2         0.0.0.0            0
vl-1.1.1.1          PtToPt  0.0.0.0         0.0.0.0         0.0.0.0            1

Let's check that R1 and R3 now have visibility of each others loopbacks in the routing table:

root@R1> show route terse

inet.0: 7 destinations, 7 routes (7 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

A Destination        P Prf   Metric 1   Metric 2  Next hop        AS path
* 1.1.1.1/32         D   0                       >lo0.0
* 2.2.2.2/32         O  10          1            >10.1.12.2
* 3.3.3.3/32         O  10          2            >10.1.12.2
* 10.1.12.0/24       D   0                       >em1.12
* 10.1.12.1/32       L   0                        Local
* 10.1.23.0/24       O  10          2            >10.1.12.2
* 224.0.0.5/32       O  10          1             MultiRecv

root@R3> show route terse

inet.0: 7 destinations, 7 routes (7 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

A Destination        P Prf   Metric 1   Metric 2  Next hop        AS path
* 1.1.1.1/32         O  10          2            >10.1.23.2
* 2.2.2.2/32         O  10          1            >10.1.23.2
* 3.3.3.3/32         D   0                       >lo0.0
* 10.1.12.0/24       O  10          2            >10.1.23.2
* 10.1.23.0/24       D   0                       >em1.23
* 10.1.23.3/32       L   0                        Local
* 224.0.0.5/32       O  10          1             MultiRecv

Yes, lets verify IP connectivity

root@R1> ping 3.3.3.3 source 1.1.1.1 count 3
PING 3.3.3.3 (3.3.3.3): 56 data bytes
64 bytes from 3.3.3.3: icmp_seq=0 ttl=63 time=7.210 ms
64 bytes from 3.3.3.3: icmp_seq=1 ttl=63 time=2.663 ms
64 bytes from 3.3.3.3: icmp_seq=2 ttl=63 time=2.657 ms

--- 3.3.3.3 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max/stddev = 2.657/4.177/7.210/2.145 ms

Success!

Saturday, 4 February 2012

Juniper OSPF Inter-Area Filtering

Right now I'm on a bit of a break with my CCIE studies but I'm still playing with routers.  As it's been a little while since I've played with Junos and I'm planning on attempting the JNCIP-SP in the next couple of months, I have been getting familiar again using Olives which will really only allow a subset of the blueprint to be tested because things like QoS and VPLS cant really be tested on it but it's still quite a reasonable platform.  I'm not going to discuss much on Olives, there is plenty of guides and so on available which your favourite search engine may assist with.

For those people interested in learning Junos but are really only have an IOS background.  There is some free online training material from Juniper called Junos as a Second Language


The routers I'm playing with at the moment have all have interface em1 connected to the same virtual switch.  Point to point links are established using VLANs.  R3 is the OSPF ABR with only it's loopback interface in OSPF Area 0

R1 (OSPF Area 13)
root@R1> show configuration | display set
set system host-name R1
set interfaces em1 vlan-tagging
set interfaces em1 unit 13 vlan-id 13
set interfaces em1 unit 13 family inet address 10.1.13.1/24
set interfaces lo0 unit 0 family inet address 1.1.1.1/32
set routing-options router-id 1.1.1.1
set protocols ospf area 0.0.0.13 interface lo0.0
set protocols ospf area 0.0.0.13 interface em1.13

R2 (OSPF Area 23)
root@R2> show configuration | display set
set system host-name R2
set interfaces em1 vlan-tagging
set interfaces em1 unit 23 vlan-id 23
set interfaces em1 unit 23 family inet address 10.1.23.2/24
set interfaces lo0 unit 0 family inet address 2.2.2.2/32
set routing-options router-id 2.2.2.2
set protocols ospf area 0.0.0.23 interface em1.23
set protocols ospf area 0.0.0.23 interface lo0.0

R3 (ABR)
root@R3> show configuration | display set
set system host-name R3
set interfaces em1 vlan-tagging
set interfaces em1 unit 13 vlan-id 13
set interfaces em1 unit 13 family inet address 10.1.13.3/24
set interfaces em1 unit 23 vlan-id 23
set interfaces em1 unit 23 family inet address 10.1.23.3/24
set interfaces lo0 unit 0 family inet address 3.3.3.3/32
set routing-options router-id 3.3.3.3
set protocols ospf area 0.0.0.0 interface lo0.0
set protocols ospf area 0.0.0.13 interface em1.13
set protocols ospf area 0.0.0.23 interface em1.23

Let's check that our adjacencies are up:
root@R1> show ospf neighbor
Address          Interface              State     ID               Pri  Dead
10.1.13.3        em1.13                 Full      3.3.3.3          128    39

root@R2> show ospf neighbor
Address          Interface              State     ID               Pri  Dead
10.1.23.3        em1.23                 Full      3.3.3.3          128    36

root@R3> show ospf neighbor
Address          Interface              State     ID               Pri  Dead
10.1.23.2        em1.23                 Full      2.2.2.2          128    34
10.1.13.1        em1.13                 Full      1.1.1.1          128    34

Lets have a look at the routing table and ospf databases

 root@R1> show route terse

inet.0: 7 destinations, 7 routes (7 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

A Destination        P Prf   Metric 1   Metric 2  Next hop        AS path
* 1.1.1.1/32         D   0                       >lo0.0
* 2.2.2.2/32         O  10          2            >10.1.13.3
* 3.3.3.3/32         O  10          1            >10.1.13.3
* 10.1.13.0/24       D   0                       >em1.13
* 10.1.13.1/32       L   0                        Local
* 10.1.23.0/24       O  10          2            >10.1.13.3
* 224.0.0.5/32       O  10          1             MultiRecv


In this mode which is the basic way to see the routing table, we cant tell what kind of OSPF routes are present as we can in IOS - however there's a different command "show ospf route" which can help out in that regard:



root@R1> show ospf route
Topology default Route Table:

Prefix             Path  Route      NH       Metric NextHop       Nexthop
                   Type  Type       Type            Interface     Address/LSP
3.3.3.3            Intra Area BR    IP            1 em1.13        10.1.13.3
1.1.1.1/32         Intra Network    IP            0 lo0.0
2.2.2.2/32         Inter Network    IP            2 em1.13        10.1.13.3
3.3.3.3/32         Inter Network    IP            1 em1.13        10.1.13.3
10.1.13.0/24       Intra Network    IP            1 em1.13
10.1.23.0/24       Inter Network    IP            2 em1.13        10.1.13.3

root@R2> show ospf route
Topology default Route Table:

Prefix             Path  Route      NH       Metric NextHop       Nexthop
                   Type  Type       Type            Interface     Address/LSP
3.3.3.3            Intra Area BR    IP            1 em1.23        10.1.23.3
1.1.1.1/32         Inter Network    IP            2 em1.23        10.1.23.3
2.2.2.2/32         Intra Network    IP            0 lo0.0
3.3.3.3/32         Inter Network    IP            1 em1.23        10.1.23.3
10.1.13.0/24       Inter Network    IP            2 em1.23        10.1.23.3
10.1.23.0/24       Intra Network    IP            1 em1.23

root@R3> show ospf route
Topology default Route Table:

Prefix             Path  Route      NH       Metric NextHop       Nexthop
                   Type  Type       Type            Interface     Address/LSP
1.1.1.1            Intra Router     IP            1 em1.13        10.1.13.1
2.2.2.2            Intra Router     IP            1 em1.23        10.1.23.2
1.1.1.1/32         Intra Network    IP            1 em1.13        10.1.13.1
2.2.2.2/32         Intra Network    IP            1 em1.23        10.1.23.2
3.3.3.3/32         Intra Network    IP            0 lo0.0
10.1.13.0/24       Intra Network    IP            1 em1.13
10.1.23.0/24       Intra Network    IP            1 em1.23


The "show ospf route" command are from the router's point of view.  When the router is an OSPF ABR because we are serving multiple areas, what is considered an intra network route may be correct for one area, while being inter-network routes for other areas and therfore the "show ospf database" may be of more help here.

root@R3> show ospf database

    OSPF database, Area 0.0.0.0
 Type       ID               Adv Rtr           Seq      Age  Opt  Cksum  Len
Router  *3.3.3.3          3.3.3.3          0x80000004    36  0x22 0x67a3  36
Summary *1.1.1.1          3.3.3.3          0x80000002    36  0x22 0x922   28
Summary *2.2.2.2          3.3.3.3          0x80000003    36  0x22 0xd84d  28
Summary *10.1.13.0        3.3.3.3          0x80000003    36  0x22 0x17fe  28
Summary *10.1.23.0        3.3.3.3          0x80000021    35  0x22 0x6c81  28

    OSPF database, Area 0.0.0.13
 Type       ID               Adv Rtr           Seq      Age  Opt  Cksum  Len
Router   1.1.1.1          1.1.1.1          0x80000007    37  0x22 0x6973  48
Router  *3.3.3.3          3.3.3.3          0x80000007    36  0x22 0x2eaf  36
Network *10.1.13.3        3.3.3.3          0x80000003    36  0x22 0x9d63  32
Summary *2.2.2.2          3.3.3.3          0x80000003    36  0x22 0xd84d  28
Summary *3.3.3.3          3.3.3.3          0x80000003    36  0x22 0xa082  28
Summary *10.1.23.0        3.3.3.3          0x80000006    35  0x22 0xa266  28

    OSPF database, Area 0.0.0.23
 Type       ID               Adv Rtr           Seq      Age  Opt  Cksum  Len
Router   2.2.2.2          2.2.2.2          0x8000002e    37  0x22 0xc88   48
Router  *3.3.3.3          3.3.3.3          0x8000002c    36  0x22 0xc0e3  36
Network *10.1.23.3        3.3.3.3          0x80000002    36  0x22 0x6390  32
Summary *1.1.1.1          3.3.3.3          0x80000002    36  0x22 0x922   28
Summary *3.3.3.3          3.3.3.3          0x80000003    36  0x22 0xa082  28
Summary *10.1.13.0        3.3.3.3          0x80000003    36  0x22 0x17fe  28

Lets add an extra internal network on R1 to be advertised in OSPF - we can do this by adding another IP Address on the loopback interface.

root@R1> configure
Entering configuration mode

[edit]
root@R1# set interfaces lo0 unit 0 family inet address 111.111.111.111/24
root@R1# commit and-quit

root@R1> show route terse | match 111
* 111.111.111.0/24   D   0                       >lo0.0
* 111.111.111.111/32 L   0                        Local


root@R2> show route terse | match 111
* 111.111.111.0/24   O  10          2            >10.1.23.3
* 111.111.111.111/32 O  10          2            >10.1.23.3

Seeing two routes associated was a little unexpected, however I suspect this is due to the type "L" local route.

Interestingly Junos appears to advertise both of these into OSPF rather than treating the loopback interface with a network mask the same as a host route (as per page 128 of RFC2328) - it seems to do a bit of a hybrid of the point-to-point network type and host-route

root@R1> show ospf database router lsa-id 1.1.1.1 detail

    OSPF database, Area 0.0.0.13
 Type       ID               Adv Rtr           Seq      Age  Opt  Cksum  Len
Router  *1.1.1.1          1.1.1.1          0x8000000c   463  0x22 0xb6f4  72
  bits 0x0, link count 4
  id 10.1.13.3, data 10.1.13.1, Type Transit (2)
    Topology count: 0, Default metric: 1
  id 1.1.1.1, data 255.255.255.255, Type Stub (3)
    Topology count: 0, Default metric: 0
  id 111.111.111.111, data 255.255.255.255, Type Stub (3)
    Topology count: 0, Default metric: 0
  id 111.111.111.0, data 255.255.255.0, Type Stub (3)
    Topology count: 0, Default metric: 0
  Topology default (ID 0)
    Type: Transit, Node ID: 10.1.13.3
      Metric: 1, Bidirectional

If we specifically set the ospf network interface type of the loopback to to point-to-point maybe that brings things back to what I would expect to see.

root@R1> configure
Entering configuration mode

[edit]
root@R1# set protocols ospf area 13 interface lo0.0 interface-type p2p

[edit]
root@R1# show protocols ospf
area 0.0.0.13 {
    interface lo0.0 {
        interface-type p2p;
    }
    interface em1.13;
}

[edit]
root@R1# commit and-quit
commit complete
Exiting configuration mode
root@R1> show ospf database router lsa-id 1.1.1.1 detail

    OSPF database, Area 0.0.0.13
 Type       ID               Adv Rtr           Seq      Age  Opt  Cksum  Len
Router  *1.1.1.1          1.1.1.1          0x8000000e    25  0x22 0x3d3a  60
  bits 0x0, link count 3
  id 10.1.13.3, data 10.1.13.1, Type Transit (2)
    Topology count: 0, Default metric: 1
  id 111.111.111.0, data 255.255.255.0, Type Stub (3)
    Topology count: 0, Default metric: 0
  id 1.1.1.1, data 255.255.255.255, Type Stub (3)
    Topology count: 0, Default metric: 0
  Topology default (ID 0)
    Type: Transit, Node ID: 10.1.13.3
      Metric: 1, Bidirectional


root@R2> show ospf database netsummary

    OSPF database, Area 0.0.0.23
 Type       ID               Adv Rtr           Seq      Age  Opt  Cksum  Len
Summary  1.1.1.1          3.3.3.3          0x80000004  1073  0x22 0x524   28
Summary  3.3.3.3          3.3.3.3          0x80000004  1091  0x22 0x9e83  28
Summary  10.1.13.0        3.3.3.3          0x80000004   905  0x22 0x15ff  28
Summary  111.111.111.0    3.3.3.3          0x80000001  1073  0x22 0x8d54  28
 
root@R2> show route terse | match 111
* 111.111.111.0/24   O  10          2            >10.1.23.3

Yes it does.  Okay now things are as expected, now lets filter the 111.111.111.0/24 route from appearing in R2's routing table and ospf database.

Lets check the OSPF database for the different area on the ABR with the summary routes for 111.111.111.0/24

root@R3> show ospf database | match "Area|111"
    OSPF database, Area 0.0.0.0
Summary *111.111.111.0    3.3.3.3          0x80000001  1428  0x22 0x8d54  28
    OSPF database, Area 0.0.0.13
    OSPF database, Area 0.0.0.23
Summary *111.111.111.0    3.3.3.3          0x80000001  1428  0x22 0x8d54  28

Inter-Area filtering can be done to limit the flow of Type 3 (Summary) LSAs on the ABR using routing policy, in this case we will be stopping 111.111.111.0/24 from being exported from OSPF Area 0 into OSPF Area 23:


root@R3> configure
Entering configuration mode

[edit]
root@R3# set policy-options policy-statement ToArea23 term 10 from route-filter 111.111.111.0/24 exact
root@R3# set policy-options policy-statement ToArea23 term 10 then reject
root@R3# set policy-options policy-statement ToArea23 term 20 then accept
root@R3# set protocols ospf area 0.0.0.23 network-summary-export ToArea23
root@R3# commit and-quit

Let's make sure the ABR still has the route available



root@R3> show route terse 111.111.111.0/24

inet.0: 9 destinations, 9 routes (9 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

A Destination        P Prf   Metric 1   Metric 2  Next hop        AS path
* 111.111.111.0/24   O  10          1            >10.1.13.1

And lets compare the ospf database output and see if 111.111.111.0/24 is no longer in area 23

root@R3> show ospf database | match "Area|111"
    OSPF database, Area 0.0.0.0
Summary *111.111.111.0    3.3.3.3          0x80000001  1546  0x22 0x8d54  28
    OSPF database, Area 0.0.0.13
    OSPF database, Area 0.0.0.23

Nope, one last final verification

root@R2> show route terse 111.111.111.0/24

root@R2> show ospf database netsummary

    OSPF database, Area 0.0.0.23
 Type       ID               Adv Rtr           Seq      Age  Opt  Cksum  Len
Summary  1.1.1.1          3.3.3.3          0x80000004  1547  0x22 0x524   28
Summary  3.3.3.3          3.3.3.3          0x80000004  1565  0x22 0x9e83  28
Summary  10.1.13.0        3.3.3.3          0x80000004  1379  0x22 0x15ff  28

Cool.  So we've tried an export policy, lets quickly test an import policy doing a similar job.  This time lets add 222.222.222.222/16 to R2's loopback and stop it from being advertised to R1.



root@R2> configure
Entering configuration mode

[edit]
root@R2# set interfaces lo0 unit 0 family inet address 222.222.222.222/16
root@R2# set protocols ospf area 23 interface lo0.0 interface-type p2p
root@R2# commit and-quit

root@R1> show route terse | match 222
* 222.222.0.0/16     O  10          2            >10.1.13.3

root@R3> show ospf database | match "Area|222"
    OSPF database, Area 0.0.0.0
Summary *222.222.0.0      3.3.3.3          0x80000001     5  0x22 0x75fc  28
    OSPF database, Area 0.0.0.13
Summary *222.222.0.0      3.3.3.3          0x80000001     5  0x22 0x75fc  28
    OSPF database, Area 0.0.0.23

root@R3> show ospf database router lsa-id 2.2.2.2 detail

    OSPF database, Area 0.0.0.23
 Type       ID               Adv Rtr           Seq      Age  Opt  Cksum  Len
Router   2.2.2.2          2.2.2.2          0x80000032  1292  0x22 0x7052  60
  bits 0x0, link count 3
  id 10.1.23.3, data 10.1.23.2, Type Transit (2)
    Topology count: 0, Default metric: 1
  id 2.2.2.2, data 255.255.255.255, Type Stub (3)
    Topology count: 0, Default metric: 0
  id 222.222.0.0, data 255.255.0.0, Type Stub (3)
    Topology count: 0, Default metric: 0
  Topology default (ID 0)
    Type: Transit, Node ID: 10.1.23.3
      Metric: 1, Bidirectional


In this case, we're using an import policy on the ABR to stop the route associated Type 1 LSA from being turned into a Type 3 LSA
 
root@R3> configure
Entering configuration mode

[edit]
root@R3# set policy-options policy-statement FromArea23 term 10 from route-filter 222.222.0.0/16 exact
root@R3# set policy-options policy-statement FromArea23 term 10 then reject
root@R3# set policy-options policy-statement FromArea23 term 20 then accept
root@R3# set protocols ospf area 0.0.0.23 network-summary-import FromArea23
root@R2# commit and-quit

Let's make sure the ABR still has the route (which it will have due to one of the interfaces being in OSPF area 23)

root@R3> show route terse | match 222
* 222.222.0.0/16     O  10          1            >10.1.23.2

Now lets see if there are any Type 3 LSAs associated with 222.222.0.0/16

root@R3> show ospf database | match "Area|222"
    OSPF database, Area 0.0.0.0
    OSPF database, Area 0.0.0.13
    OSPF database, Area 0.0.0.23

Nope - our policy is doing it's job, so there shouldn't be a route for 222.222.0.0/16 on R1 either:

root@R1> show route terse | match 222

Which is what we wanted to see.

So there you go.