示例:配置 BGP 大型社区
此示例说明如何配置可选的传递路径属性 - 一个 12 字节 BGP 大型社区,它提供最重要的 4 字节值以作为全局管理员对自治系统编号进行编码,并提供其余两个 4 字节分配的编号来对 RFC 8092 中定义的本地值进行编码。可以在层次结构级别配置 [edit routing-options static route ip-address community] BGP 大型社区[edit policy-options community community-name members]。BGP 大型社区属性格式有四个字段:large:global administrator:assigned number:assigned number.
要求
此示例使用以下硬件和软件组件:
三个 MX 系列路由器
在所有设备上运行的 Junos OS 17.3 或更高版本
配置此示例之前,不需要除设备初始化之外的特殊配置。
概述
在此示例中,设备 R1 和设备 R2 是自治系统 (AS) 64510 中的 OSPF 邻接方。设备 R3 具有到设备 R1 的外部 BGP (EBGP) 连接。设备 R2 在 172.16/16 地址空间中具有客户网络,使用其环路接口 (lo0) 上的地址进行模拟。设备 R1 具有到多个 172.16.x/24 网络的静态路由,并将常规社区值附加到这些路由。然后,设备 R1 使用导出策略将路由通告到设备 R3。设备 R3 接收这些路由,并使用导入策略向路由添加大型社区值。
拓扑学
图 1 显示了示例网络。

配置
CLI 快速配置
要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改任何必要的详细信息以匹配您的网络配置,然后将命令复制并粘贴到 [edit] 层次结构级别的 CLI 中。
设备 R1
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
设备 R2
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
设备 R3
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
程序
分步过程
以下示例要求您在配置层次结构中导航各个级别。有关导航 CLI 的信息,请参阅 在配置模式下使用 CLI 编辑器Junos OS CLI 用户指南。
要配置设备 R3:
配置接口。
[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
配置自治系统 (AS) 编号和路由器 ID。
[edit routing-options] set router-id 192.168.0.3 set autonomous-system 64511
配置与设备 R1 的 EBGP 连接。
[edit protocols bgp group to-R1] set type external set import set-large-comms set peer-as 64510 set neighbor 10.0.0.14
配置将大型社区值添加到从设备 R1 接收的路由的策略。
大型社区使用 :
global administrator:assigned number:assigned number的large表示法。特定社区值可以是在特定参数内实现管理目标的任何值。[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
[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
结果
在配置模式下,输入 show interfaces 、show protocols、show policy-options 和 show routing-options 命令,以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。
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;
}
}
}
user@R3# show protocols
bgp {
group to-R1 {
type external;
import set-large-comms;
peer-as 64510;
neighbor 10.0.0.14;
}
}
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;
user@R3# show routing-options router-id 192.168.0.3; autonomous-system 64511;
如果完成设备配置,请从配置模式输入 commit。
验证
确认配置工作正常。
验证 R1
目的
在设备 R1 上,检查 172.16。路由表中的路由。
操作
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
. . .
意义
输出显示常规社区和大型社区值附加到路由。
社区附加到静态路由,从而证明常规社区和大型社区都可以附加到静态路由。
验证 R3
目的
在设备 R3 上,检查 172.16。路由表中的路由。
操作
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
. . .
意义
输出显示,播发的常规和大型社区值仍然附加到路由上,并且在 R3 收到时添加了新的大型社区值。