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

    Example: Defining a Routing Policy That Removes BGP Communities

    This example shows how to create a policy that accepts BGP routes, but removes BGP communities from the routes.

    Requirements

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

    Overview

    This example shows two routing devices with an external BGP (EBGP) connection between them. Device R2 uses the BGP session to send two static routes to Device R1. On Device R1, an import policy specifies that all BGP communities must be removed from the routes.

    By default, when communities are configured on EBGP peers, they are sent and accepted. To suppress the acceptance of communities received from a neighbor, you can remove all communities or a specified set of communities. When the result of a policy is an empty set of communities, the community attribute is not included. To remove all communities, first define a wildcard set of communities (here, the community is named wild):

    [edit policy-options]community wild members "* : *";

    Then, in the routing policy statement, specify the community delete action:

    [edit policy-options]
    policy-statement policy-name {term term-name {then community delete wild;}}

    To suppress a particular community from any autonomous system (AS), define the community as community wild members "*:community-value".

    Topology

    Figure 1 shows the sample network.

    Figure 1: BGP Policy That Removes Communities

    BGP Policy That Removes
Communities

    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/1/0 unit 0 description to-R2set interfaces fe-1/1/0 unit 0 family inet address 10.0.0.1/30set interfaces lo0 unit 0 family inet address 192.168.0.1/32set protocols bgp group external-peers type externalset protocols bgp group external-peers peer-as 2set protocols bgp group external-peers neighbor 10.0.0.2 import remove-communitiesset policy-options policy-statement remove-communities term 1 from protocol bgpset policy-options policy-statement remove-communities term 1 then community delete wildset policy-options policy-statement remove-communities term 1 then acceptset policy-options policy-statement remove-communities term 2 then rejectset policy-options community wild members *:*set routing-options router-id 192.168.0.1set routing-options autonomous-system 1

    Device R2

    set interfaces fe-1/1/0 unit 0 description to-R1set interfaces fe-1/1/0 unit 0 family inet address 10.0.0.2/30set interfaces lo0 unit 0 family inet address 192.168.0.2/32set protocols bgp group external-peers type externalset protocols bgp group external-peers export staticsset protocols bgp group external-peers peer-as 1set protocols bgp group external-peers neighbor 10.0.0.1set policy-options policy-statement statics from protocol staticset policy-options policy-statement statics then community add 1set policy-options policy-statement statics then acceptset policy-options community 1 members 2:1set policy-options community 1 members 2:2set policy-options community 1 members 2:3set policy-options community 1 members 2:4set policy-options community 1 members 2:5set policy-options community 1 members 2:6set policy-options community 1 members 2:7set policy-options community 1 members 2:8set policy-options community 1 members 2:9set policy-options community 1 members 2:10set routing-options static route 10.2.0.0/16 rejectset routing-options static route 10.2.0.0/16 installset routing-options static route 10.3.0.0/16 rejectset routing-options static route 10.3.0.0/16 installset routing-options router-id 192.168.0.3set routing-options autonomous-system 2

    Step-by-Step Procedure

    The following example requires that you 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 Device R1:

    1. Configure the interfaces.
      [edit interfaces]user@R1# set fe-1/1/0 unit 0 description to-R2user@R1# set fe-1/1/0 unit 0 family inet address 10.0.0.1/30
      user@R1# set lo0 unit 0 family inet address 192.168.0.1/32
    2. Configure BGP.

      Apply the import policy to the BGP peering session with Device R2.

      [edit protocols bgp group external-peers]user@R1# set type externaluser@R1# set peer-as 2user@R1# set neighbor 10.0.0.2 import remove-communities
    3. Configure the routing policy that deletes communities.
      [edit policy-options policy-statement remove-communities]user@R1# set term 1 from protocol bgpuser@R1# set term 1 then community delete wilduser@R1# set term 1 then acceptuser@R1# set term 2 then reject
    4. Configure the autonomous system (AS) number and the router ID.
      [edit routing-options ]user@R1# set router-id 192.168.0.1user@R1# set autonomous-system 1

    Step-by-Step Procedure

    The following example requires that you 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 Device R2:

    1. Configure the interfaces.
      [edit interfaces]user@R2# set fe-1/1/0 unit 0 description to-R1user@R2# set fe-1/1/0 unit 0 family inet address 10.0.0.2/30
      user@R2# set lo0 unit 0 family inet address 192.168.0.2/32
    2. Configure the router ID and the autonomous system (AS) number.
      [edit routing-options]user@R2# set router-id 192.168.0.3user@R2# set autonomous-system 2
    3. Configure BGP.
      [edit protocols bgp group external-peers]user@R2# set type externaluser@R2# set peer-as 1user@R2# set neighbor 10.0.0.1
    4. Configure multiple communities, or configure a single community with multiple members.
      [edit policy-options community 1]user@R2# set members 2:1user@R2# set members 2:2user@R2# set members 2:3user@R2# set members 2:4user@R2# set members 2:5user@R2# set members 2:6user@R2# set members 2:7user@R2# set members 2:8user@R2# set members 2:9user@R2# set members 2:10
    5. Configure the static routes.
      [edit routing-options static]user@R2# set route 10.2.0.0/16 rejectuser@R2# set route 10.2.0.0/16 installuser@R2# set route 10.3.0.0/16 rejectuser@R2# set route 10.3.0.0/16 install
    6. Configure a routing policy that advertises static routes into BGP and adds the BGP community to the routes.
      [edit policy-options policy-statement statics]user@R2# set from protocol staticuser@R2# set then community add 1user@R2# set then accept
    7. Apply the export policy.
      [edit protocols bgp group external-peers]user@R2# set export statics

    Results

    From configuration mode, confirm your configuration by entering 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.

    Device R1

    user@R1# show interfaces
    fe-1/1/0 {unit 0{description to-R2;family inet {address 10.0.0.1/30;}}}
    lo0 {unit 0 {family inet {address 192.168.0.1/32;}}}
    user@R1# show protocols
    bgp {group external-peers {type external;peer-as 2;neighbor 10.0.0.2 {import remove-communities;}}}
    user@R1# show policy-options
    policy-statement remove-communities {term 1 {from protocol bgp;then {community delete wild;accept;}}term 2 {then reject;}}
    community wild members *:*;
    user@R1# show routing-optionsrouter-id 192.168.0.1;autonomous-system 1;

    Device R2

    user@R2# show interfaces
    fe-1/1/0 {unit 0 {description to-R1;family inet {address 10.0.0.2/30;}}}
    lo0 {unit 0 {family inet {address 192.168.0.2/32;}}}
    user@R2# show protocols
    bgp {group external-peers {type external;export statics;peer-as 1;neighbor 10.0.0.1;}}
    user@R2# show policy-options
    policy-statement statics {from protocol static;then {community add 1;accept;}}
    community 1 members [ 2:1 2:2 2:3 2:4 2:5 2:6 2:7 2:8 2:9 2:10 ];
    user@R2# show routing-options
    static {route 10.2.0.0/16 {reject;install;}route 10.3.0.0/16 {reject;install;}}
    router-id 192.168.0.3;autonomous-system 2;

    If you are done configuring the devices, enter commit from configuration mode.

    Verification

    Confirm that the configuration is working properly.

    Verifying the BGP Routes

    Purpose

    Make sure that the routing table on Device R1 does not contain BGP communities.

    Action

    1. On Device R1, run the show route protocols bgp extensive command.
      user@R1> show route protocols bgp extensive
      inet.0: 5 destinations, 5 routes (5 active, 0 holddown, 0 hidden)
      10.2.0.0/16 (1 entry, 1 announced)
      TSI:
      KRT in-kernel 10.2.0.0/16 -> {10.0.0.2}
              *BGP    Preference: 170/-101
                      Next hop type: Router, Next hop index: 671
                      Address: 0x9458270
                      Next-hop reference count: 4
                      Source: 10.0.0.2
                      Next hop: 10.0.0.2 via lt-1/1/0.5, selected
                      Session Id: 0x100001
                      State: <Active Ext>
                      Local AS:     1 Peer AS:     2
                      Age: 20:39:01 
                      Validation State: unverified 
                      Task: BGP_2.10.0.0.2+179
                      Announcement bits (1): 0-KRT 
                      AS path: 2 I
                      Accepted
                      Localpref: 100
                      Router ID: 192.168.0.3
      
      10.3.0.0/16 (1 entry, 1 announced)
      TSI:
      KRT in-kernel 10.3.0.0/16 -> {10.0.0.2}
              *BGP    Preference: 170/-101
                      Next hop type: Router, Next hop index: 671
                      Address: 0x9458270
                      Next-hop reference count: 4
                      Source: 10.0.0.2
                      Next hop: 10.0.0.2 via lt-1/1/0.5, selected
                      Session Id: 0x100001
                      State: <Active Ext>
                      Local AS:     1 Peer AS:     2
                      Age: 20:39:01 
                      Validation State: unverified 
                      Task: BGP_2.10.0.0.2+179
                      Announcement bits (1): 0-KRT 
                      AS path: 2 I
                      Accepted
                      Localpref: 100
                      Router ID: 192.168.0.3
    2. On Device R1, deactivate the community remove configuration in the import policy.
      [edit policy-options policy-statement remove-communities term 1]user@R1# deactivate then community delete wilduser@R1# commit
    3. On Device R1, run the show route protocols bgp extensive command to view the advertised communities.
      user@R1> show route protocols bgp extensive
      inet.0: 5 destinations, 5 routes (5 active, 0 holddown, 0 hidden)
      10.2.0.0/16 (1 entry, 1 announced)
      TSI:
      KRT in-kernel 10.2.0.0/16 -> {10.0.0.2}
              *BGP    Preference: 170/-101
                      Next hop type: Router, Next hop index: 671
                      Address: 0x9458270
                      Next-hop reference count: 4
                      Source: 10.0.0.2
                      Next hop: 10.0.0.2 via lt-1/1/0.5, selected
                      Session Id: 0x100001
                      State: <Active Ext>
                      Local AS:     1 Peer AS:     2
                      Age: 20:40:53 
                      Validation State: unverified 
                      Task: BGP_2.10.0.0.2+179
                      Announcement bits (1): 0-KRT 
                      AS path: 2 I
                      Communities: 2:1 2:2 2:3 2:4 2:5 2:6 2:7 2:8 2:9 2:10
                      Accepted
                      Localpref: 100
                      Router ID: 192.168.0.3
      
      10.3.0.0/16 (1 entry, 1 announced)
      TSI:
      KRT in-kernel 10.3.0.0/16 -> {10.0.0.2}
              *BGP    Preference: 170/-101
                      Next hop type: Router, Next hop index: 671
                      Address: 0x9458270
                      Next-hop reference count: 4
                      Source: 10.0.0.2
                      Next hop: 10.0.0.2 via lt-1/1/0.5, selected
                      Session Id: 0x100001
                      State: <Active Ext>
                      Local AS:     1 Peer AS:     2
                      Age: 20:40:53 
                      Validation State: unverified 
                      Task: BGP_2.10.0.0.2+179
                      Announcement bits (1): 0-KRT 
                      AS path: 2 I
                      Communities: 2:1 2:2 2:3 2:4 2:5 2:6 2:7 2:8 2:9 2:10
                      Accepted
                      Localpref: 100
                      Router ID: 192.168.0.3
      
      

    Meaning

    The output shows that in Device R1’s routing table, the communities are suppressed in the BGP routes sent from Device R2. When the community remove setting in Device R1’s import policy is deactivated, the communities are no longer suppressed.

    Published: 2013-07-31