Rib-groups example

Rib-groups simple example.

We created two routing instances: test1 and test2, each instances has one interface in it:
    test1 - vlan.641:     172.16.10.1/24
    test2 - vlan.642:       172.16.20.1/24

# show routing-instances
test1 {
    instance-type virtual-router;
    interface vlan.641;

}
test2 {
    instance-type virtual-router;
    interface vlan.642;
}


Routing table looks like this:

root@nyc-broadway-451-0# run show route terse

inet.0: 43 destinations, 44 routes (43 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          S   5                       >108.60.137.81
* 10.0.0.0/18        S 160                       >10.255.6.2
* 10.0.2.0/24        O 150          0            >10.255.45.1
* 10.0.3.0/24        O 150          0            >10.255.45.1
* 10.0.5.0/24        O 150          0            >10.255.45.1
* 10.2.0.0/16        A 130                        Reject
* 10.2.1.0/24        D   0                       >vlan.631
* 10.2.1.1/32        L   0                        Local
* 10.2.2.0/24        D   0                       >vlan.632
* 10.2.2.1/32        L   0                        Local
* 10.2.4.0/23        D   0                       >vlan.634
* 10.2.4.1/32        L   0                        Local
* 10.255.6.0/24      D   0                       >st0.1
* 10.255.6.1/32      L   0                        Local
* 10.255.25.0/24     O 150          0            >10.255.45.1
                     S 160                       >10.255.6.2
* 10.255.45.0/24     D   0                       >reth1.0
* 10.255.45.2/32     L   0                        Local
* 1.1.1.1/29   D   0                       >reth0.0
* 1.1.1.1/32   L   0                        Local
* 224.0.0.5/32       O  10          1             MultiRecv

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

A Destination        P Prf   Metric 1   Metric 2  Next hop         AS path
* 172.16.10.1/32     L   0                        Reject

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

A Destination        P Prf   Metric 1   Metric 2  Next hop         AS path
* 172.16.20.1/32     L   0                        Reject

 


Our goal is to:
    - import static and ospf routes into routing instance test1;
    - import test1 routes into routing instance test2;
    - import test1 and test2 routes into inet.0;

 

1. Create rib-group 'group1' and add inet.0 direct routes, static rotues and ospf routes:
    # set routing-options static rib-group group1
    # set routing-options interface-routes rib-group inet group1
    # set protocols ospf rib-group group1

2.  Import inet.0 routes to test1.inet.0 table:
    # set routing-options rib-groups group1 import-rib [ inet.0 test1.inet.0 ]

    this is going to import all routes, and if we want to filter, we can create a policy:
    
    # set policy-options policy-statement import-to-vr term 9 from protocol direct
    # set policy-options policy-statement import-to-vr term 9 then accept
    # set policy-options policy-statement import-to-vr term 10 from protocol ospf
    # set policy-options policy-statement import-to-vr term 10 from route-filter 10.0.0.0/20 orlonger
    # set policy-options policy-statement import-to-vr term 10 then accept
    # set policy-options policy-statement import-to-vr term 20 from route-filter 0.0.0.0/0 exact
    # set policy-options policy-statement import-to-vr term 20 then accept
    # set policy-options policy-statement import-to-vr term 50 then reject
    # set policy-options policy-statement import-to-vr term 21 from route-filter 172.16.0.0/12 orlonger
    # set policy-options policy-statement import-to-vr term 21 then accept

    and apply it:
    # set routing-options rib-groups group1 import-policy import-to-vr


    test1.inet.0 will look like this:
# run show route terse table test1

test1.inet.0: 12 destinations, 12 routes (12 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          S   5                       >108.60.137.81
* 10.0.2.0/24        O 150          0            >10.255.45.1
* 10.0.3.0/24        O 150          0            >10.255.45.1
* 10.0.5.0/24        O 150          0            >10.255.45.1
* 10.0.10.0/24       O 150          0            >10.255.45.1
* 10.2.1.0/24        D   0                       >vlan.631
* 10.2.2.0/24        D   0                       >vlan.632
* 10.2.4.0/23        D   0                       >vlan.634
* 10.255.6.0/24      D   0                       >st0.1
* 10.255.45.0/24     D   0                       >reth1.0
* 1.1.1.1/29   D   0                       >reth0.0
* 172.16.10.1/32     L   0                        Reject


First goal is achieved.

Now, we need to create another group, lets call it 'test-routes' and add test1.inet.0 and test2.inet.0 interface routes to it:
    # set routing-instances test1 routing-options interface-routes rib-group inet test-routes
    # set routing-instances test2 routing-options interface-routes rib-group inet test-routes


root@nyc-broadway-451-0# show routing-instances
test1 {
    instance-type virtual-router;
    interface vlan.641;
    routing-options {
        interface-routes {
            rib-group inet test-routes;
        }
    }
}
test2 {
    instance-type virtual-router;
    interface vlan.642;
    routing-options {
        interface-routes {
            rib-group inet test-routes;
        }
    }
}


Set rib-group 'test-routes' to import routes:
    # set routing-options rib-groups test-routes import-rib test1.inet.0
    # set routing-options rib-groups test-routes import-rib test2.inet.0
    # set routing-options rib-groups test-routes import-policy test-routes

and apply policy to allow route from test1 to be imported to test1 routing instance:

# show policy-options policy-statement test-routes
term 10 {
    from instance test1;
    then accept;
}
term 20 {
    from instance test2;
    then reject;
}