示例:为路由过滤器配置第 3 层 VPN 协议系列限定符
此示例说明如何通过为 BGP 导入策略配置家族限定符来控制 BGP 导入策略的范围。族限定符指定 、 inet6inet-vpn、 或 inet6-vpn的inet路由。
要求
此示例使用 Junos OS 10.0 或更高版本。
准备工作:
配置设备接口。
配置内部网关协议。请参阅 Junos OS 路由协议库。
为多种路由类型配置 BGP 会话。例如,为家族
inet路由和系列inet-vpn路由配置会话。请参阅 在 VPN 中的 PE 路由器之间配置 IBGP 会话 和 配置第 3 层 VPN 以传输 IPv6 流量。
概述
家族限定符会导致路由过滤器仅匹配一个特定家族。配置不带家族限定符的 IPv4 路由过滤器时(如此处所示),路由过滤器 inet 匹配和 inet-vpn 路由。
route-filter ipv4-address/mask;
同样,配置不带家族限定符的 IPv6 路由过滤器时(如此处所示),路由过滤器将匹配 inet6 和 inet6-vpn 路由。
route-filter ipv6-address/mask;
考虑为家族 inet 路由和家族 inet-vpn 路由配置 BGP 会话,并为此 BGP 会话配置导入策略的情况。这意味着家庭路由和系列inetinet-vpn路由在收到时共享相同的导入策略。策略期限可能如下所示:
from {
route-filter 0.0.0.0/0 exact;
}
then {
next-hop self;
accept;
}
此路由过滤器逻辑匹配 inet 0.0.0.0 的路由和 inet-vpn IPv4 地址部分为 0.0.0.0 的路由。路由过滤器匹配中不考虑路由的 inet-vpn 8 字节路由识别符部分。这是 Junos OS 10.0 版中引入的 Junos OS 行为更改。
如果您不希望您的保单与两种类型的路由匹配,请在您的保单中添加家庭限定符。要让路由过滤器仅 inet 匹配路由,请添加系列 inet 策略限定符。要让路由过滤器仅 inet-vpn 匹配路由,请添加系列 inet-vpn 策略限定符。
在评估路由过滤器之前评估家族限定符。因此,如果家族匹配失败,则不会评估路由过滤器。同样的逻辑也适用于家庭 inet6 和家庭 inet6-vpn。示例中使用的 inet6 路由过滤器必须使用 IPv6 地址。使用家族限定符可能会提高效率,因为家族限定符在大多数其他限定符之前进行测试,从而快速消除不需要的家族的路由。
配置
程序
CLI 快速配置
要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改与您的网络配置匹配所需的任何详细信息,然后将命令复制并粘贴到层次结构级别的 CLI [edit] 中。
伊内特示例
set policy-options policy-statement specific-family from family inet set policy-options policy-statement specific-family from route-filter 0.0.0.0/0 exact set policy-options policy-statement specific-family then next-hop self set policy-options policy-statement specific-family then accept set protocols bgp import specific-family
Inet-vpn 示例
set policy-options policy-statement specific-family from family inet-vpn set policy-options policy-statement specific-family from route-filter 0.0.0.0/0 exact set policy-options policy-statement specific-family then next-hop self set policy-options policy-statement specific-family then accept set protocols bgp import specific-family
inet6 示例
set policy-options policy-statement specific-family from family inet6 set policy-options policy-statement specific-family from route-filter 0::0/0 exact set policy-options policy-statement specific-family then next-hop self set policy-options policy-statement specific-family then accept set protocols bgp import specific-family
Inet6-vpn 示例
set policy-options policy-statement specific-family from family inet6-vpn set policy-options policy-statement specific-family from route-filter 0::0/0 exact set policy-options policy-statement specific-family then next-hop self set policy-options policy-statement specific-family then accept set protocols bgp import specific-family
分步过程
以下示例要求您在配置层次结构中导航各个级别。有关导航 CLI 的信息,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器。
要配置流图:
配置家族限定符。
[edit policy-options] user@host# set policy-statement specific-family from family inet
配置路由过滤器。
[edit policy-options] user@host# set policy-statement specific-family from route-filter 0.0.0.0/0 exact
配置策略操作。
[edit policy-options] user@host# set policy-statement specific-family then next-hop self user@host# set policy-statement specific-family then accept
应用策略。
[edit protocols bgp] user@host# set import specific-family
结果
在配置模式下,发出 and show protocolsshow policy-options 命令以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。
user@host# show protocols
bgp {
import specific-family;
}
user@host# show policy-options
policy-statement specific-family {
from {
family inet;
route-filter 0.0.0.0/0 exact;
}
then {
next-hop self;
accept;
}
}
如果完成设备配置,请从配置模式输入 commit。
对需要特定路由过滤器策略的每个协议系列重复此过程。
验证
要验证配置,请运行以下命令:
show route advertising-protocol bgp neighbor detailshow route instance instance-name detail