Navigation
Guide That Contains This Content
[+] Expand All
[-] Collapse All

    Example: Applying Routing Policies at Different Levels of the BGP Hierarchy

    This example shows BGP configured in a simple network topology and explains how routing polices take effect when they are applied at different levels of the BGP configuration.

    Requirements

    No special configuration beyond device initialization is required before configuring this example.

    Overview

    For BGP, you can apply policies as follows:

    • BGP global import and export statements—Include these statements at the [edit protocols bgp] hierarchy level (for routing instances, include these statements at the [edit routing-instances routing-instance-name protocols bgp] hierarchy level).
    • Group import and export statements—Include these statements at the [edit protocols bgp group group-name] hierarchy level (for routing instances, include these statements at the [edit routing-instances routing-instance-name protocols bgp group group-name] hierarchy level).
    • Peer import and export statements—Include these statements at the [edit protocols bgp group group-name neighbor address] hierarchy level (for routing instances, include these statements at the [edit routing-instances routing-instance-name protocols bgp group group-name neighbor address] hierarchy level).

    A peer-level import or export statement overrides a group import or export statement. A group-level import or export statement overrides a global BGP import or export statement.

    In this example, a policy named send-direct is applied at the global level, another policy named send-192.168.0.1 is applied at the group level, and a third policy named send-192.168.20.1 is applied at the neighbor level.

    user@host# show protocols
    bgp {local-address 1.1.1.1;export send-direct;group internal-peers {type internal;export send-192.168.0.1;neighbor 2.2.2.2 {export send-192.168.20.1;}neighbor 3.3.3.3;}group other-group {type internal;neighbor 4.4.4.4;}}

    A key point, and one that is often misunderstood and that can lead to problems, is that in such a configuration, only the most explicit policy is applied. A neighbor-level policy is more explicit than a group-level policy, which in turn is more explicit than a global policy.

    The neighbor 2.2.2.2 is subjected only to the send-192.168.20.1 policy. The neighbor 3.3.3.3, lacking anything more specific, is subjected only to the send-192.168.0.1 policy. Meanwhile, neighbor 4.4.4.4 in group other-group has no group or neighbor-level policy, so it uses the send-direct policy.

    If you need to have neighbor 2.2.2.2 perform the function of all three policies, you can write and apply a new neighbor-level policy that encompasses the functions of the other three, or you can apply all three existing policies, as a chain, to neighbor 2.2.2.2.

    Figure 1 shows the sample network.

    Figure 1: Applying Routing Policies to BGP

    Applying Routing Policies
to BGP

    CLI Quick Configuration shows the configuration for all of the devices in Figure 1.

    The section Step-by-Step Procedure describes the steps on Device R1.

    Configuration

    CLI Quick Configuration

    To quickly configure this example, copy the following commands, paste them into a text file, remove any line breaks, change any details necessary to match your network configuration, and then copy and paste the commands into the CLI at the [edit] hierarchy level.

    Device R1

    set interfaces fe-1/2/0 unit 0 description to-R2set interfaces fe-1/2/0 unit 0 family inet address 10.10.10.1/30set interfaces lo0 unit 0 family inet address 1.1.1.1/32set protocols bgp local-address 1.1.1.1set protocols bgp export send-directset protocols bgp group internal-peers type internalset protocols bgp group internal-peers export send-static-192.168.0set protocols bgp group internal-peers neighbor 2.2.2.2 export send-static-192.168.20set protocols bgp group internal-peers neighbor 3.3.3.3set protocols bgp group other-group type internalset protocols bgp group other-group neighbor 4.4.4.4set protocols ospf area 0.0.0.0 interface lo0.0 passiveset protocols ospf area 0.0.0.0 interface fe-1/2/0.0set policy-options policy-statement send-direct term 1 from protocol directset policy-options policy-statement send-direct term 1 then acceptset policy-options policy-statement send-static-192.168.0 term 1 from protocol staticset policy-options policy-statement send-static-192.168.0 term 1 from route-filter 192.168.0.0/24 orlongerset policy-options policy-statement send-static-192.168.0 term 1 then acceptset policy-options policy-statement send-static-192.168.20 term 1 from protocol staticset policy-options policy-statement send-static-192.168.20 term 1 from route-filter 192.168.20.0/24 orlongerset policy-options policy-statement send-static-192.168.20 term 1 then acceptset routing-options static route 192.168.0.1/32 discardset routing-options static route 192.168.20.1/32 discardset routing-options router-id 1.1.1.1set routing-options autonomous-system 17

    Device R2

    set interfaces fe-1/2/0 unit 0 description to-R1set interfaces fe-1/2/0 unit 0 family inet address 10.10.10.2/30set interfaces fe-1/2/1 unit 0 description to-R3set interfaces fe-1/2/1 unit 0 family inet address 10.10.10.5/30set interfaces lo0 unit 0 family inet address 2.2.2.2/32set protocols bgp group internal-peers type internalset protocols bgp group internal-peers local-address 2.2.2.2set protocols bgp group internal-peers neighbor 3.3.3.3set protocols bgp group internal-peers neighbor 1.1.1.1set protocols bgp group internal-peers neighbor 4.4.4.4set protocols ospf area 0.0.0.0 interface lo0.0 passiveset protocols ospf area 0.0.0.0 interface fe-1/2/0.0set protocols ospf area 0.0.0.0 interface fe-1/2/1.0set routing-options router-id 2.2.2.2set routing-options autonomous-system 17

    Device R3

    set interfaces fe-1/2/1 unit 0 description to-R2set interfaces fe-1/2/1 unit 0 family inet address 10.10.10.6/30set interfaces fe-1/2/2 unit 0 description to-R4set interfaces fe-1/2/2 unit 0 family inet address 10.10.10.9/30set interfaces lo0 unit 0 family inet address 3.3.3.3/32set protocols bgp group internal-peers type internalset protocols bgp group internal-peers local-address 3.3.3.3set protocols bgp group internal-peers neighbor 2.2.2.2set protocols bgp group internal-peers neighbor 1.1.1.1set protocols bgp group internal-peers neighbor 4.4.4.4set protocols ospf area 0.0.0.0 interface lo0.0 passiveset protocols ospf area 0.0.0.0 interface fe-1/2/1.0set protocols ospf area 0.0.0.0 interface fe-1/2/2.0set routing-options router-id 3.3.3.3set routing-options autonomous-system 17

    Device R4

    set interfaces fe-1/2/2 unit 0 description to-R3set interfaces fe-1/2/2 unit 0 family inet address 10.10.10.10/30set interfaces lo0 unit 0 family inet address 4.4.4.4/32set protocols bgp group internal-peers type internalset protocols bgp group internal-peers local-address 4.4.4.4set protocols bgp group internal-peers neighbor 2.2.2.2set protocols bgp group internal-peers neighbor 1.1.1.1set protocols bgp group internal-peers neighbor 3.3.3.3set protocols ospf area 0.0.0.0 interface lo0.0 passiveset protocols ospf area 0.0.0.0 interface fe-1/2/2.0set routing-options router-id 4.4.4.4set routing-options autonomous-system 17

    Step-by-Step Procedure

    The following example requires you to navigate various levels in the configuration hierarchy. For information about navigating the CLI, see Using the CLI Editor in Configuration Mode in the CLI User Guide.

    To configure an IS-IS default route policy:

    1. Configure the device interfaces.
      [edit interfaces]user@R1# set fe-1/2/0 unit 0 description to-R2user@R1# set fe-1/2/0 unit 0 family inet address 10.10.10.1/30
      user@R1# set lo0 unit 0 family inet address 1.1.1.1/32
    2. Enable OSPF, or another interior gateway protocols (IGP), on the interfaces.
      [edit protocols OSPF area 0.0.0.0]user@R1# set interface lo0.0 passiveuser@R1# set interface fe-1/2/0.0
    3. Configure static routes.

      [edit routing-options]user@R1# set static route 192.168.0.1/32 discarduser@R1# set static route 192.168.20.1/32 discard
    4. Enable the routing policies.
      [edit protocols policy-options]user@R1# set policy-statement send-direct term 1 from protocol directuser@R1# set policy-statement send-direct term 1 then accept
      user@R1# set policy-statement send-static-192.168.0 term 1 from protocol staticuser@R1# set policy-statement send-static-192.168.0 term 1 from route-filter 192.168.0.0/24 orlongeruser@R1# set policy-statement send-static-192.168.0 term 1 then accept
      user@R1# set policy-statement send-static-192.168.20 term 1 from protocol staticuser@R1# set policy-statement send-static-192.168.20 term 1 from route-filter 192.168.20.0/24 orlongeruser@R1# set policy-statement send-static-192.168.20 term 1 then accept
    5. Configure BGP and apply the export policies.

      [edit protocols bgp]user@R1# set local-address 1.1.1.1user@R1# set group internal-peers type internaluser@R1# set group internal-peers export send-static-192.168.0user@R1# set group internal-peers neighbor 2.2.2.2 export send-static-192.168.20user@R1# set group internal-peers neighbor 3.3.3.3user@R1# set group other-group type internaluser@R1# set group other-group neighbor 4.4.4.4
    6. Configure the router ID and autonomous system (AS) number.
      [edit routing-options]user@R1# set router-id 1.1.1.1user@R1# set autonomous-system 17
    7. If you are done configuring the device, commit the configuration.

      [edit]user@R1# commit

    Results

    From configuration mode, confirm your configuration by issuing the show interfaces, show protocols, show policy-options, and show routing-options commands. If the output does not display the intended configuration, repeat the instructions in this example to correct the configuration.

    user@R1# show interfaces
    fe-1/2/0 {unit 0 {description to-R2;family inet {address 10.10.10.1/30;}}}
    lo0 {unit 0 {family inet {address 1.1.1.1/32;}}}
    user@R1# show protocols
    bgp {local-address 1.1.1.1;export send-direct;group internal-peers {type internal;export send-static-192.168.0;neighbor 2.2.2.2 {export send-static-192.168.20;}neighbor 3.3.3.3;}group other-group {type internal;neighbor 4.4.4.4;}}
    ospf {area 0.0.0.0 {interface lo0.0 {passive;}interface fe-1/2/0.0;}}
    user@R1# show policy-options
    policy-statement send-direct {term 1 {from protocol direct;then accept;}}
    policy-statement send-static-192.168.0 {term 1 {from {protocol static;route-filter 192.168.0.0/24 orlonger;}then accept;}}
    policy-statement send-static-192.168.20 {term 1 {from {protocol static;route-filter 192.168.20.0/24 orlonger;}then accept;}}
    user@R1# show routing-options
    static {route 192.168.0.1/32 discard;route 192.168.20.1/32 discard;}
    router-id 1.1.1.1;autonomous-system 17;

    Verification

    Confirm that the configuration is working properly.

    Verifying BGP Route Learning

    Purpose

    Make sure that the BGP export policies are working as expected by checking the routing tables.

    Action

    user@R1> show route protocol direct
    inet.0: 11 destinations, 11 routes (11 active, 0 holddown, 0 hidden)
    + = Active Route, - = Last Active, * = Both
    
    1.1.1.1/32         *[Direct/0] 1d 22:19:47
                        > via lo0.0
    10.10.10.0/30      *[Direct/0] 1d 22:19:47
                        > via fe-1/2/0.0
    

    user@R1> show route protocol static
    inet.0: 11 destinations, 11 routes (11 active, 0 holddown, 0 hidden)
    + = Active Route, - = Last Active, * = Both
    
    192.168.0.1/32     *[Static/5] 02:20:03
                          Discard
    192.168.20.1/32    *[Static/5] 02:20:03
                          Discard

    user@R2> show route protocol bgp
    inet.0: 11 destinations, 11 routes (11 active, 0 holddown, 0 hidden)
    + = Active Route, - = Last Active, * = Both
    
    192.168.20.1/32    *[BGP/170] 02:02:40, localpref 100, from 1.1.1.1
                          AS path: I, validation-state: unverified
                        > to 10.10.10.1 via fe-1/2/0.0

    user@R3> show route protocol bgp
    inet.0: 11 destinations, 11 routes (11 active, 0 holddown, 0 hidden)
    + = Active Route, - = Last Active, * = Both
    
    192.168.0.1/32     *[BGP/170] 02:02:51, localpref 100, from 1.1.1.1
                          AS path: I, validation-state: unverified
                        > to 10.10.10.5 via fe-1/2/1.0

    user@R4> show route protocol bgp
    inet.0: 9 destinations, 11 routes (9 active, 0 holddown, 0 hidden)
    + = Active Route, - = Last Active, * = Both
    
    1.1.1.1/32          [BGP/170] 1d 20:38:54, localpref 100, from 1.1.1.1
                          AS path: I, validation-state: unverified
                        > to 10.10.10.9 via fe-1/2/2.0
    10.10.10.0/30       [BGP/170] 1d 20:38:54, localpref 100, from 1.1.1.1
                          AS path: I, validation-state: unverified
                        > to 10.10.10.9 via fe-1/2/2.0

    Meaning

    On Device R1, the show route protocol direct command displays two direct routes: 1.1.1.1/32 and 10.10.10.0/30. The show route protocol static command displays two static routes: 192.168.0.1/32 and 192.168.20.1/32.

    On Device R2, the show route protocol bgp command shows that the only route that Device R2 has learned through BGP is the 192.168.20.1/32 route.

    On Device R3, the show route protocol bgp command shows that the only route that Device R3 has learned through BGP is the 192.168.0.1/32 route.

    On Device R4, the show route protocol bgp command shows that the only routes that Device R4 has learned through BGP are the 1.1.1.1/32 and 10.10.10.0/30 routes.

    Verifying BGP Route Receiving

    Purpose

    Make sure that the BGP export policies are working as expected by checking the BGP routes received from Device R1.

    Action

    user@R2> show route receive-protocol bgp 1.1.1.1
    inet.0: 11 destinations, 11 routes (11 active, 0 holddown, 0 hidden)
      Prefix                  Nexthop              MED     Lclpref    AS path
    * 192.168.20.1/32         1.1.1.1                      100        I

    user@R3> show route receive-protocol bgp 1.1.1.1
    inet.0: 11 destinations, 11 routes (11 active, 0 holddown, 0 hidden)
      Prefix                  Nexthop              MED     Lclpref    AS path
    * 192.168.0.1/32          1.1.1.1                      100        I

    user@R4> show route receive-protocol bgp 1.1.1.1
    inet.0: 9 destinations, 11 routes (9 active, 0 holddown, 0 hidden)
      Prefix                  Nexthop              MED     Lclpref    AS path
      1.1.1.1/32              1.1.1.1                      100        I
      10.10.10.0/30           1.1.1.1                      100        I

    Meaning

    On Device R2, the route receive-protocol bgp 1.1.1.1 command shows that Device R2 received only one BGP route, 192.168.20.1/32, from Device R1.

    On Device R3, the route receive-protocol bgp 1.1.1.1 command shows that Device R3 received only one BGP route, 192.168.0.1/32, from Device R1.

    On Device R4, the route receive-protocol bgp 1.1.1.1 command shows that Device R4 received two BGP routes, 1.1.1.1/32 and 10.10.10.0/30, from Device R1.

    In summary, when multiple policies are applied at different CLI hierarchies in BGP, only the most specific application is evaluated, to the exclusion of other, less specific policy applications. Although this point might seem to make sense, it is easily forgotten during router configuration, when you mistakenly believe that a neighbor-level policy is combined with a global or group-level policy, only to find that your policy behavior is not as anticipated.

    Published: 2013-07-31