原文地址:http://www.xuexizu.com/group/10011/forum/741/1166926


SUMMARY:

This article demonstrates how to correct a configuration in which a route import from multiple custom routing instances does not import to the default routing instance.

Note:
Although this example applies to a route not imported to the default routing instance, it can also occur between three custom routing instances.


PROBLEM OR GOAL:

Two custom routing instances have been created and the aim is to import static routes from these routing instances to the default routing instance. However, the route import is happening from only one of the routing instances and not from the other to the default routing instance.


For example, the problem can be seen with this configuration:

Configuration:

root@240-HM-5# show policy-options
policy-statement test1-to-def {
    term 1 {
        from {
            instance test1;
            protocol static;
        }
    then accept;
    }
    term 2 {
        then reject;
    }
}
policy-statement test2-to-def {
    term 1 {
        from {
            instance test2;
            protocol static;
        }
    then accept;
    }
    term 2 {
        then reject;
    }
}

root@240-HM-5# show routing-options
static {
    route 10.209.0.0/16 next-hop 10.204.115.254;
    }
instance-import [ test1-to-def test2-to-def ];


Routing Table:

root@240-HM-5# run show route

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

10.204.115.0/24 *[Direct/0] 4d 05:36:17
> via ge-0/0/0.0
10.204.115.123/32 *[Local/0] 4d 05:36:29
Local via ge-0/0/0.0
10.209.0.0/16 *[Static/5] 00:08:13
> to 10.204.115.254 via ge-0/0/0.0
11.11.11.0/30 *[Static/5] 00:00:35  <<<<<<<<<<<<<<<<<<<<<<<<<<<
> to 1.1.1.2 via ge-0/0/1.0

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

1.1.1.0/30 *[Direct/0] 00:08:09
> via ge-0/0/1.0
1.1.1.1/32 *[Local/0] 00:08:09
Local via ge-0/0/1.0
11.11.11.0/30 *[Static/5] 00:08:09
> to 1.1.1.2 via ge-0/0/1.0

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

2.2.2.0/30 *[Direct/0] 00:08:09
> via ge-0/0/2.0
2.2.2.1/32 *[Local/0] 00:08:09
Local via ge-0/0/2.0
12.12.12.0/30 *[Static/5] 00:08:09
> to 2.2.2.2 via ge-0/0/2.0

In the above output, the static route from Test1 is visible and not from other routing instance.


CAUSE:

This issue is related to the reject statement at the end of policy statement configuration

root@240-HM-5# show policy-options
policy-statement test1-to-def {
    term 1 {
        from {
            instance test1;
            protocol static;
        }
        then accept;
    }
    term 2 {
        then reject; <<<<<<<<<<<<<<<<<<<<<
    }
}

The reject statement stops the process of the next policy statement configured for the instance import here:

root@240-HM-5# show routing-options
static {
    route 10.209.0.0/16 next-hop 10.204.115.254;
}
instance-import [ test1-to-def test2-to-def ];
<<<<<<<<<<<<<<<<<<<<<<<

The reject statement prevents the device from processing 'test2-to-def' policy statement.


SOLUTION:

Replace the reject statement in the first policy with next policy statement.

Note: In case of policy chaining (calling more than one policy ininstance-import or instance-export) all the policy-statements except the last policy-statement should not have a terminating action like "accept" or "reject".
All policy-statement preceding the last policy-statement in a policy-chain should have the "next-policy" as the action statement. This would ensure that all the policy-statements in the chain are processed.


For example:

Configuration:

policy-statement test1-to-def {
    term 1 {
        from {
            instance test1;
            protocol static;
        }
    then accept;
    }
    term 2 {
        then next policy; <<<<<<<<<<<<<<<<<<<<<<<
    }
}

Routing Table:

root@240-HM-5# run show route

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

10.204.115.0/24 *[Direct/0] 4d 05:49:22
> via ge-0/0/0.0
10.204.115.123/32 *[Local/0] 4d 05:49:34
Local via ge-0/0/0.0
10.209.0.0/16 *[Static/5] 00:21:18
> to 10.204.115.254 via ge-0/0/0.0
11.11.11.0/30 *[Static/5] 00:13:40      <<<<<<<<<<<<<<<<<<<
> to 1.1.1.2 via ge-0/0/1.0
12.12.12.0/30 *[Static/5] 00:00:27      <<<<<<<<<<<<<<<<<<<
> to 2.2.2.2 via ge-0/0/2.0

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

1.1.1.0/30 *[Direct/0] 00:08:09
> via ge-0/0/1.0
1.1.1.1/32 *[Local/0] 00:08:09
Local via ge-0/0/1.0
11.11.11.0/30 *[Static/5] 00:08:09
> to 1.1.1.2 via ge-0/0/1.0

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

2.2.2.0/30 *[Direct/0] 00:08:09
> via ge-0/0/2.0
2.2.2.1/32 *[Local/0] 00:08:09
Local via ge-0/0/2.0
12.12.12.0/30 *[Static/5] 00:08:09
> to 2.2.2.2 via ge-0/0/2.0


In the above output, static routes from both routing instances are visible in the default routing-instance.