示例:VPN 的 BGP 路由目标过滤
通过在相应的 BGP 层次结构级别配置 family route-target 语句来启用 BGP 路由目标过滤。此语句支持交换存储在 bgp.rtarget.0 路由表中的新 route-target 地址族。
以下配置说明了如何为标题为的 to_vpn04BGP 组配置 BGP 路由目标过滤:
[edit]
protocols {
bgp {
group to_vpn04 {
type internal;
local-address 10.255.14.182;
peer-as 200;
neighbor 10.255.14.174 {
family inet-vpn {
unicast;
}
family route-target;
}
}
}
}
以下配置说明了如何配置几个本地 VPN 路由和转发 (VRF) 路由实例,以利用 BGP 路由目标过滤提供的功能。根据此配置,BGP 将自动生成与 VRF 导入策略中引用的路由目标对应的本地路由(请注意语句定义 vrf-target 的目标)。
[edit]
routing-instances {
vpn1 {
instance-type vrf;
interface t1-0/1/2.0;
vrf-target target:200:101;
protocols {
ospf {
export bgp-routes;
area 0.0.0.0 {
interface t1-0/1/2.0;
}
}
}
}
vpn2 {
instance-type vrf;
interface t1-0/1/2.1;
vrf-target target:200:102;
protocols {
ospf {
export bgp-routes;
area 0.0.0.0 {
interface t1-0/1/2.1;
}
}
}
}
}
发出 show route table bgp.rtarget.0 show 命令以验证 BGP 路由目标过滤配置:
user@host> show route table bgp.rtarget.0
bgp.rtarget.0: 4 destinations, 6 routes (4 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
200:200:101/96
*[RTarget/5] 00:10:00
Local
200:200:102/96
*[RTarget/5] 00:10:00
Local
200:200:103/96
*[BGP/170] 00:09:48, localpref 100, from 10.255.14.174
AS path: I
> t3-0/0/0.0
200:200:104/96
*[BGP/170] 00:09:48, localpref 100, from 10.255.14.174
AS path: I
> t3-0/0/0.0
show路由目标前缀的命令显示格式为:
AS number:route target extended community/length
第一个数字表示发送此播发的路由器的自治系统 (AS)。显示的剩余部分遵循扩展社区的 Junos show 命令约定。
命令的 show route table bgp-rtarget.0 输出显示本地生成和远程生成的路由。
前两个条目对应于为两个本地 VRF 路由实例(vpn1 和 vpn2)配置的路由目标:
200:200:101/96—路由实例中的vpn1社区200:101200:200:102/96—路由实例中的vpn2社区200:102
最后两个条目是从 BGP 对等方接收的前缀:
200:200:103/96-通知本地路由器,应将此社区 (200:103) 标记的路由播发至对等方10.255.14.174t3-0/0/0.0200:200:104/96-通知本地路由器,应将此社区 (200:104) 标记的路由播发至对等方10.255.14.174t3-0/0/0.0