Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

header-navigation
keyboard_arrow_up
close
keyboard_arrow_left
list Table of Contents
file_download PDF
{ "lLangCode": "en", "lName": "English", "lCountryCode": "us", "transcode": "en_US" }
English
keyboard_arrow_right

Example: Configuring BGP Large Communities

date_range 24-Nov-23

This example shows you to configure optional transitive path attribute - a 12-byte BGP large community that provides the most significant 4-byte value to encode autonomous system number as the global administrator and the remaining two 4-byte assigned numbers to encode the local values as defined in RFC 8092. You can configure BGP large community at [edit policy-options community community-name members] and [edit routing-options static route ip-address community] hierarchy levels. The BGP large community attributes format has four fields: large:global administrator:assigned number:assigned number.

Requirements

This example uses the following hardware and software components:

  • Three MX Series routers

  • Junos OS Release 17.3 or later running on all devices

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

Overview

In this example, Device R1 and Device R2 are OSPF neighbors in autonomous system (AS) 64510. Device R3 has an external BGP (EBGP) connection to Device R1. Device R2 has customer networks in the 172.16/16 address space, simulated with addresses on its loopback interface (lo0). Device R1 has static routes to several 172.16.x/24 networks, and attaches regular community values to these routes. Device R1 then uses an export policy to advertise the routes to Device R3. Device R3 receives these routes and uses an import policy to add large community values to the routes.

Topology

Figure 1 shows the sample network.

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

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 0 family inet address 10.0.0.1/30
set interfaces fe-1/2/3 unit 0 family inet address 10.0.0.14/30
set interfaces lo0 unit 0 family inet address 192.168.0.1/32 primary
set routing-options static route 172.16.1.0/24 next-hop 10.0.0.2
set routing-options static route 172.16.1.0/24 community 64510:1
set routing-options static route 172.16.1.0/24 community large:64510:100:1
set routing-options static route 172.16.2.0/24 next-hop 10.0.0.2
set routing-options static route 172.16.2.0/24 community 64510:2
set routing-options static route 172.16.2.0/24 community large:64510:200:2
set routing-options static route 172.16.3.0/24 next-hop 10.0.0.2
set routing-options static route 172.16.3.0/24 community 64510:3
set routing-options static route 172.16.4.0/24 next-hop 10.0.0.2
set routing-options static route 172.16.4.0/24 community 64510:4
set routing-options router-id 192.168.0.1
set routing-options autonomous-system 64510
set protocols bgp group ext type external
set protocols bgp group ext export send-static
set protocols bgp group ext peer-as 64511
set protocols bgp group ext neighbor 10.0.0.13
set protocols ospf area 0.0.0.0 interface lo0.0 passive
set protocols ospf area 0.0.0.0 interface fe-1/2/0.0
set policy-options policy-statement send-static term 1 from protocol static
set policy-options policy-statement send-static term 1 then accept

Device R2

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 0 family inet address 10.0.0.2/30
set interfaces lo0 unit 0 family inet address 192.168.0.2/32
set interfaces lo0 unit 0 family inet address 172.16.1.1/32
set interfaces lo0 unit 0 family inet address 172.16.2.2/32
set interfaces lo0 unit 0 family inet address 172.16.3.3/32
set interfaces lo0 unit 0 family inet address 172.16.4.4/32
set routing-options router-id 192.168.0.2
set protocols ospf area 0.0.0.0 interface lo0.0 passive
set protocols ospf area 0.0.0.0 interface fe-1/2/0.0

Device R3

content_copy zoom_out_map
set interfaces fe-1/2/3 unit 0 family inet address 10.0.0.13/30
set interfaces lo0 unit 0 family inet address 192.168.0.3/32
set routing-options router-id 192.168.0.3
set routing-options autonomous-system 64511
set protocols bgp group to-R1 type external
set protocols bgp group to-R1 import set-large-comms
set protocols bgp group to-R1 peer-as 64510
set protocols bgp group to-R1 neighbor 10.0.0.14
set policy-options policy-statement set-large-comms term route-1 from route-filter 172.16.1.0/24 exact
set policy-options policy-statement set-large-comms term route-1 then community add large2-as
set policy-options policy-statement set-large-comms term route-1 then accept
set policy-options policy-statement set-large-comms term route-2 from route-filter 172.16.2.0/24 exact
set policy-options policy-statement set-large-comms term route-2 then community add large2-ip
set policy-options policy-statement set-large-comms term route-2 then accept
set policy-options policy-statement set-large-comms term route-3 from route-filter 172.16.3.0/24 exact
set policy-options policy-statement set-large-comms term route-3 then community add large1-as
set policy-options policy-statement set-large-comms term route-3 then accept
set policy-options policy-statement set-large-comms term route-4 from route-filter 172.16.4.0/24 exact
set policy-options policy-statement set-large-comms term route-4 then community add large1-ip
set policy-options policy-statement set-large-comms term route-4 then accept
set policy-options community large1-as members large:64511:3:1
set policy-options community large1-ip members large:7777:4:1
set policy-options community large2-as members large:64511:1:1
set policy-options community large2-ip members large:7777:2:1

Procedure

Step-by-Step Procedure

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

To configure Device R3:

  1. Configure the interfaces.

    content_copy zoom_out_map
    [edit interfaces]
    set fe-1/2/3 unit 0 family inet address 10.0.0.13/30
    set lo0 unit 0 family inet address 192.168.0.3/32
    
  2. Configure the autonomous system (AS) number and router ID.

    content_copy zoom_out_map
    [edit routing-options]
    set router-id 192.168.0.3
    set autonomous-system 64511
    
  3. Configure the EBGP connection to Device R1.

    content_copy zoom_out_map
    [edit protocols bgp group to-R1]
    set type external
    set import set-large-comms
    set peer-as 64510
    set neighbor 10.0.0.14
    
  4. Configure the policy that adds large community values to the routes received from Device R1.

    A large community uses a notation of large:global administrator:assigned number:assigned number. The specific community values can be anything that accomplishes your administrative goals, within certain parameters.

    content_copy zoom_out_map
    [edit policy-options policy-statement set-large-comms]
    set term route-1 from route-filter 172.16.1.0/24 exact
    set term route-1 then community add large2-as
    set term route-1 then accept
    set term route-2 from route-filter 172.16.2.0/24 exact
    set term route-2 then community add large2-ip
    set term route-2 then accept
    set term route-3 from route-filter 172.16.3.0/24 exact
    set term route-3 then community add large1-as
    set term route-3 then accept
    set term route-4 from route-filter 172.16.4.0/24 exact
    set term route-4 then community add large1-ip
    set term route-4 then accept
    
    content_copy zoom_out_map
    [edit policy-options ]
    set community large1-as members large:64511:3:1
    set community large1-ip members large:7777:4:1
    set community large2-as members large:64511:1:1
    set community large2-ip members large:7777:2:1
    

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.

content_copy zoom_out_map
user@R3# show interfaces
fe-1/2/3 {
    unit 0 {
        family inet {
            address 10.0.0.13/30;
        }
    }
}
lo0 {
    unit 0 {
        family inet {
            address 192.168.0.3/32;
        }
    }
}
content_copy zoom_out_map
user@R3# show protocols
bgp {
    group to-R1 {
        type external;
        import set-large-comms;
        peer-as 64510;
        neighbor 10.0.0.14;
    }
}
content_copy zoom_out_map
user@R3# show policy-options
policy-statement set-large-comms {
    term route-1 {
        from {
            route-filter 172.16.1.0/24 exact;
        }
        then {
            community add large2-as;
            accept;
        }
    }
    term route-2 {
        from {
            route-filter 172.16.2.0/24 exact;
        }
        then {
            community add large2-ip;
            accept;
        }
    }
    term route-3 {
        from {
            route-filter 172.16.3.0/24 exact;
        }
        then {
            community add large1-as;
            accept;
        }
    }
    term route-4 {
        from {
            route-filter 172.16.4.0/24 exact;
        }
        then {
            community add large1-ip;
            accept;
        }
    }
  }
community large1-as members large:64511:3:1;
community large1-ip members large:7777:4:1;
community large2-as members large:64511:1:1;
community large2-ip members large:7777:2:1;
content_copy zoom_out_map
user@R3# show routing-options
router-id 192.168.0.3;
autonomous-system 64511;

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

Verification

Confirm that the configuration is working properly.

Verifying R1

Purpose

On Device R1, check the 172.16. routes in the routing table.

Action

content_copy zoom_out_map
user@R1> show route protocol static match-prefix 172.16.* detail
inet.0: 17 destinations, 17 routes (17 active, 0 holddown, 0 hidden)
172.16.1.0/24 (1 entry, 1 announced)
        *Static Preference: 5
                Next hop type: Router, Next hop index: 580
                Address: 0xb7a1270
                Next-hop reference count: 9
                Next hop: 10.0.0.2 via fe-1/2/0.0, selected
                Session Id: 0x140
                State: < Active Int Ext >
                Local AS: 64510 
                Age: 4d 19:02:23 
                Validation State: unverified 
                Task: RT
                Announcement bits (2): 0-KRT 4-BGP_RT_Background 
                AS path: I
                Communities: 64510:1 large:64510:100:1

172.16.2.0/24 (1 entry, 1 announced)
        *Static Preference: 5
                Next hop type: Router, Next hop index: 580
                Address: 0xb7a1270
                Next-hop reference count: 9
                Next hop: 10.0.0.2 via fe-1/2/0.0.0, selected
                Session Id: 0x140
                State: < Active Int Ext >
                Local AS: 64510 
                Age: 4d 19:02:23 
                Validation State: unverified 
                Task: RT
                Announcement bits (2): 0-KRT 4-BGP_RT_Background 
                AS path: I
                Communities: 64510:2 large:64510:200:2

172.16.3.0/24 (1 entry, 1 announced)
        *Static Preference: 5
                Next hop type: Router, Next hop index: 580
                Address: 0xb7a1270
                Next-hop reference count: 9
                Next hop: 10.0.0.2 via fe-1/2/0.0.0, selected
                Session Id: 0x140       
                State: < Active Int Ext > 
                Local AS: 64510         
                Age: 4d 22:17:12        
                Validation State: unverified 
                Task: RT                
                Announcement bits (2): 0-KRT 4-BGP_RT_Background 
                AS path: I              
                Communities: 64510:3    
                                        
172.16.4.0/24 (1 entry, 1 announced)    
        *Static Preference: 5           
                Next hop type: Router, Next hop index: 580
                Address: 0xb7a1270      
                Next-hop reference count: 9
                Next hop: 10.0.0.2 via fe-1/2/0.0.0, selected
                Session Id: 0x140       
                State: < Active Int Ext > 
                Local AS: 64510         
                Age: 4d 22:17:12        
                Validation State: unverified 
                Task: RT                
                Announcement bits (2): 0-KRT 4-BGP_RT_Background 
                AS path: I              
                Communities: 64510:4    
 . . .

Meaning

The output shows that the regular community and large community values are attached to the routes.

Note:

The communities are attached to static routes, thus demonstrating that both regular and large communities can be attached to static routes.

Verifying R3

Purpose

On Device R3, check the 172.16. routes in the routing table.

Action

content_copy zoom_out_map
user@R3> show route protocol bgp match-prefix 172.16.* detail

inet.0: 14 destinations, 14 routes (14 active, 0 holddown, 0 hidden)
172.16.1.0/24 (1 entry, 1 announced)
        *BGP    Preference: 170/-101
                Next hop type: Router, Next hop index: 581
                Address: 0xb7a10f0
                Next-hop reference count: 8
                Source: 10.0.0.14
                Next hop: 10.0.0.14 via fe-1/2/3.0, selected
                Session Id: 0x140
                State: < Active Ext >
                Local AS: 64511 Peer AS: 64510
                Age: 3d 16:36:18 
                Validation State: unverified 
                Task: BGP_64510.10.0.0.14
                Announcement bits (1): 0-KRT 
                AS path: 64510 I
                Communities: 64510:1 large:64510:100:1 large:64511:1:1
                Accepted
                Localpref: 100
                Router ID: 192.168.0.1

172.16.2.0/24 (1 entry, 1 announced)
        *BGP    Preference: 170/-101
                Next hop type: Router, Next hop index: 581
                Address: 0xb7a10f0
                Next-hop reference count: 8
                Source: 10.0.0.14
                Next hop: 10.0.0.14 via fe-1/2/3.0, selected
                Session Id: 0x140
                State: < Active Ext >
                Local AS: 64511 Peer AS: 64510
                Age: 3d 16:36:18 
                Validation State: unverified 
                Task: BGP_64510.10.0.0.14
                Announcement bits (1): 0-KRT 
                AS path: 64510 I
                Communities: 64510:2 large:7777:2:1 large:64510:200:2
                Accepted
                Localpref: 100
                Router ID: 192.168.0.1

172.16.3.0/24 (1 entry, 1 announced)
        *BGP    Preference: 170/-101
                Next hop type: Router, Next hop index: 581
                Address: 0xb7a10f0
                Next-hop reference count: 8
                Source: 10.0.0.14
                Next hop: 10.0.0.14 via fe-1/2/3.0, selected
                Session Id: 0x140
                State: < Active Ext >
                Local AS: 64511 Peer AS: 64510
                Age: 3d 16:36:18 
                Validation State: unverified 
                Task: BGP_64510.10.0.0.14
                Announcement bits (1): 0-KRT 
                AS path: 64510 I        
                Communities: 64510:3 large:64511:3:1
                Accepted                
                Localpref: 100          
                Router ID: 192.168.0.1  
                                        
172.16.4.0/24 (1 entry, 1 announced)    
        *BGP    Preference: 170/-101    
                Next hop type: Router, Next hop index: 581
                Address: 0xb7a10f0      
                Next-hop reference count: 8
                Source: 10.0.0.14       
                Next hop: 10.0.0.14 via fe-1/2/3.0, selected
                Session Id: 0x140       
                State: < Active Ext >     
                Local AS: 64511 Peer AS: 64510
                Age: 3d 16:36:18        
                Validation State: unverified 
                Task: BGP_64510.10.0.0.14
                Announcement bits (1): 0-KRT 
                AS path: 64510 I        
                Communities: 64510:4 large:7777:4:1
                Accepted                
                Localpref: 100          
                Router ID: 192.168.0.1  
. . .

Meaning

The output shows that the advertised regular and large community values remain attached to the routes, and that the new large community values are added when received by R3.

footer-navigation