示例:配置路由策略以优先考虑 IS-IS 路由
在具有大量 IS-IS 路由的网络中,控制为响应网络拓扑更改而更新路由的顺序会很有用。此示例说明如何定义路由策略,以便将某些 IS-IS 路由优先于其他路由。如果发生 IS-IS 拓扑更改,将首先在路由表中更新高优先级前缀,然后是中等优先级前缀,然后是低优先级前缀。互联网服务提供商 (ISP) 可以使用此功能来确保重要客户更快地融合。
要求
配置此示例之前,不需要除设备初始化之外的特殊配置。
此示例使用以下硬件和软件组件:
三台路由器
在所有设备上运行的 Junos OS
概述
您可以优先或拒绝安装在路由表中的 IS-IS 路由。使用策略 reject 选项拒绝来自特定前缀的路由或标有特定标记的路由。
您可以排定 IS-IS 路由的优先级,以实现更好的融合并提供差异化服务。在具有大量 IGP 前缀且在某些 IGP 前缀之上建立BGP第 3 层 VPN 或基于标签的伪线服务的网络中,控制路由在转发表中的更新顺序非常重要。您可以配置导入策略并使用路由标记,或根据路由的前缀过滤路由,然后再将优先级 high设置为 、 medium,或 low 根据您的网络要求。IS-IS 协议根据配置的优先级将路由下载到 rpd 路由表。如果未配置导入策略,则默认情况下所有路由都设置为中等优先级。
IS-IS 导入策略可用于根据以下条件设置优先级或过滤 IS-IS 外部路由:
| Prefix | 使用 |
| Route Tag | 使用 |
如果应用 reject 的 IS-IS 导入策略导致对非外部路由执行终止作, reject 则该作将被忽略,并且路由仍会被接受。默认情况下,此类路由现在安装在路由表中,优先级为低。这种行为通过确保路由的一致性来防止流量黑洞,即静默丢弃的流量。但是,您可以使用 reject 策略选项根据前缀或配置的标记拒绝路由。
随着路由下载顺序的更改,您可能会看到微环路流量有所增加。
拓扑学
在 图 1 中,路由器 R1 通过路由器 R2 连接到路由器 R3。我们需要将路由设置为路由器 R3 的高优先级,以确保更快的融合。路由器 R1 上配置了导入路由策略,用于为连接到路由器 R3 的路由设置高优先级。首先安装与 203.0.113.3/32 匹配的路由,因为它们的优先级为高。LDP 从 IS-IS 导入路由及其配置优先级。如果网络拓扑发生更改,将首先恢复此路由。
的优先级
配置
CLI 快速配置
要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以便与网络配置匹配,将命令复制并粘贴到层次结构级别的 [edit] CLI 中,然后从配置模式进入 commit。
路由器 R1
set interfaces ge-1/0/1 unit 0 description R1->R2 set interfaces ge-1/0/1 unit 0 family inet address 192.0.2.1/24 set interfaces ge-1/0/1 unit 0 family iso set interfaces ge-1/0/1 unit 0 family inet6 address 2001:db8:1:2::1/64 set interfaces ge-1/0/1 unit 0 family mpls set interfaces ge-5/0/9 unit 0 description R1->R2 set interfaces ge-5/0/9 unit 0 family inet address 192.0.10.1/24 set interfaces ge-5/0/9 unit 0 family iso set interfaces ge-5/0/9 unit 0 family inet6 address 2001:db8:1:1::1/64 set interfaces ge-5/0/9 unit 0 family mpls set interfaces lo0 unit 0 family inet address 203.0.113.1/32 set interfaces lo0 unit 0 family iso address 49.0002.0103.0000.0010.00 set interfaces lo0 unit 0 family inet6 address 2001:db8:1:1::1/128 set interfaces lo0 unit 0 family mpls set protocols mpls ipv6-tunneling set protocols mpls interface ge-5/0/9.0 set protocols mpls interface ge-1/0/1.0 set protocols isis level 1 disable set protocols isis interface ge-1/0/1.0 set protocols isis interface ge-5/0/9.0 set protocols isis interface lo0.0 passive set protocols ldp interface ge-1/0/1.0 set protocols ldp interface ge-5/0/9.0 set protocols ldp interface lo0.0 set policy-options policy-statement test_rf term t1 from route-filter 203.0.113.3/32 exact set policy-options policy-statement test_rf term t1 then priority high set protocols isis import test_rf set routing-options router-id 203.0.113.1 set routing-options autonomous-system 64496
路由器 R2
set interfaces ge-0/0/1 unit 0 description R2->R1 set interfaces ge-0/0/1 unit 0 family inet address 192.0.2.2/24 set interfaces ge-0/0/1 unit 0 family iso set interfaces ge-0/0/1 unit 0 family inet6 address 2001:db8:1:2::2/64 set interfaces ge-0/0/1 unit 0 family mpls set interfaces ge-0/0/7 unit 0 description R2->R3 set interfaces ge-0/0/7 unit 0 family inet address 198.0.2.1/24 set interfaces ge-0/0/7 unit 0 family iso set interfaces ge-0/0/7 unit 0 family inet6 address 2001:db8:1:2::1/64 set interfaces ge-0/0/7 unit 0 family mpls set interfaces ge-1/0/5 unit 0 description R2->R1 set interfaces ge-1/0/5 unit 0 family inet address 192.0.10.2/24 set interfaces ge-1/0/5 unit 0 family iso set interfaces ge-1/0/5 unit 0 family inet6 address 2001:db8:1:1::2/64 set interfaces ge-1/0/5 unit 0 family mpls set interfaces ge-1/1/0 unit 0 family inet address 198.0.10.1/24 set interfaces ge-1/1/0 unit 0 family iso set interfaces ge-1/1/0 unit 0 family inet6 address 2001:db8:::1::1/64 set interfaces ge-1/1/0 unit 0 family mpls set interfaces lo0 unit 0 family inet address 203.0.113.2/32 set interfaces lo0 unit 0 family iso address 49.0002.0103.0000.0030.00 set interfaces lo0 unit 0 family inet6 address 2001:db8:2:2::1/128 set interfaces lo0 unit 0 family mpls set protocols mpls interface ge-1/0/5.0 set protocols mpls interface ge-0/0/1.0 set protocols mpls interface ge-1/1/0.0 set protocols mpls interface ge-0/0/7.0 set protocols isis level 1 disable set protocols isis interface ge-0/0/1.0 set protocols isis interface ge-0/0/7.0 set protocols isis interface ge-1/0/5.0 set protocols isis interface ge-1/1/0.0 set protocols isis interface lo0.0 passive set protocols ldp interface ge-0/0/1.0 set protocols ldp interface ge-0/0/7.0 set protocols ldp interface ge-1/0/5.0 set protocols ldp interface ge-1/1/0.0 set protocols ldp interface lo0.0 set routing-options router-id 203.0.113.2 set routing-options autonomous-system 64496
路由器 R3
set interfaces ge-2/0/3 unit 0 description R3->R2 set interfaces ge-2/0/3 unit 0 family inet address 198.1.2.2/24 set interfaces ge-2/0/3 unit 0 family iso set interfaces ge-2/0/3 unit 0 family inet6 address 2001:db8:1:2::2/64 set interfaces ge-2/0/3 unit 0 family mpls set interfaces ge-3/0/10unit 0 description R3->R4 set interfaces ge-3/0/0 unit 0 family inet address 198.0.1.2/24 set interfaces ge-3/0/0 unit 0 family iso set interfaces ge-3/0/0 unit 0 family inet6 address 2001:db8::1:1::2/64 set interfaces ge-3/0/0 unit 0 family mpls set interfaces lo0 unit 0 family inet address 203.0.113.3/32 set interfaces lo0 unit 0 family iso address 49.0002.0103.0000.0020.00 set interfaces lo0 unit 0 family inet6 address 2001:db8:3:3::3/128 set interfaces lo0 unit 0 family mpls set protocols mpls ipv6-tunneling set protocols mpls interface ge-3/0/0.0 set protocols mpls interface ge-2/0/3.0 set protocols isis level 1 disable set protocols isis interface ge-2/0/3.0 set protocols isis interface ge-3/0/0.0 set protocols isis interface lo0.0 passive set protocols ldp interface ge-2/0/3.0 set protocols ldp interface ge-3/0/0.0 set protocols ldp interface lo0.0 set policy-options policy-statement add_tag term t1 from route-filter 203.0.113.3/32 exact set policy-options policy-statement add_tag term t1 then tag 18 set protocols isis export add_tag set routing-options router-id 203.0.113.3 set routing-options autonomous-system 64496
配置路由器 R1
分步程序
下面的示例要求您在各个配置层级中进行导航。有关导航 CLI 的信息,请参阅 《CLI 用户指南》中的在配置模式下使用 CLI 编辑器。
要配置路由器 R1,请执行以下作:
修改相应的接口名称、地址和其他参数后,对其他路由器重复此过程。
使用 IPv4 和 IPv6 地址配置接口。
[edit interfaces] user@R1# set ge-1/0/1 unit 0 description R1->R2 user@R1# set ge-1/0/1 unit 0 family inet address 192.0.2.1/24 user@R1# set ge-1/0/1 unit 0 family iso user@R1# set ge-1/0/1 unit 0 family inet6 address 2001:db8:1:2::1/64 user@R1# set ge-1/0/1 unit 0 family mpls user@R1# set ge-1/0/1 unit 0 description R1->R2 user@R1# set ge-5/0/9 unit 0 family inet address 192.0.10.1/24 user@R1# set ge-5/0/9 unit 0 family iso user@R1# set ge-5/0/9 unit 0 family inet6 address 2001:db8:1:1::1/64 user@R1# set ge-5/0/9 unit 0 family mpls
配置环路地址。
[edit interfaces] user@R1# set lo0 unit 0 family inet address 203.0.113.1/32 user@R1# set lo0 unit 0 family iso address 49.0002.0103.0000.0010.00 user@R1# set lo0 unit 0 family inet6 address 2001:db8:1:1::1/128 user@R1# set lo0 unit 0 family mpls
配置 MPLS。
[edit protocols] user@R1# set mpls ipv6-tunneling user@R1# set mpls interface ge-5/0/9.0 user@R1# set mpls interface ge-1/0/1.0
在接口上启用 IS-IS 协议。
[edit protocols] user@R1# set isis level 1 disable user@R1# set isis interface ge-1/0/1.0 user@R1# set isis interface ge-5/0/9.0 user@R1# set isis interface lo0.0 passive user@R1# set isis import test_rf
在接口上配置 LDP 协议。
[edit protocols] user@R1# set ldp interface ge-1/0/1.0 user@R1# set ldp interface ge-5/0/9.0 user@R1# set ldp interface lo0.0
定义一个策略,以优先排定到路由器 R3 的 IS-IS 路由。.
[edit policy-options] user@R1# set policy-statement test_rf term t1 from route-filter 203.0.113.3/32 exact user@R1# set policy-statement test_rf term t1 then priority high
配置路由器 ID 和自治系统 (AS) 编号。
[edit routing--options] user@R1# set routing-options router-id 203.0.113.1 user@R1# set routing-options autonomous-system 64496
结果
在配置模式下,输入 show interfaces、 show protocolsshow policy-options 和 show routing-options 命令以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明以更正配置。
[edit]
user@R1> show interfaces
ge-1/0/1 {
unit 0 {
family inet {
address 192.0.2.1/24;
}
family iso;
family inet6 {
address 2001:db8:1:2::1/64;
}
family mpls;
}
}
ge-5/0/9 {
unit 0 {
family inet {
address 192.0.2.1/24;
}
family iso;
family inet6 {
address 2001:db8:1:1::1/64;
}
family mpls;
}
}
lo0 {
unit 0 {
family inet {
address 203.0.113.1/32;
}
family iso {
address 49.0002.0103.0000.0010.00;
}
family inet6 {
address 2001:db8:1:1::1/128;
}
family mpls;
}
}
[edit]
user@R1> show protocols
mpls {
ipv6-tunneling;
interface ge-5/0/9.0;
interface ge-1/0/1.0;
}
isis {
import test_rf;
level 1 disable;
interface ge-1/0/1.0;
interface ge-5/0/9.0;
interface lo0.0 {
passive;
}
}
ldp {
interface ge-1/0/1.0;
interface ge-5/0/9.0;
interface lo0.0;
}
[edit] user@R1> show routing-options router-id 203.0.113.1; autonomous-system 64496;
user@R1> sshow configuration policy-options
policy-statement test_rf {
term t1 {
from {
route-filter 203.0.113.3/32 exact;
}
then priority high;
}
}
验证
验证 LDP 路由的优先级
目的
验证 LDP 是否继承了 IS-IS 协议的路由 203.0.113.3。
行动
在作模式下,对路由器 R1 运行 show route extensive 命令。
user@R1> show route 203.0.113.3 extensive
inet.0: 26 destinations, 26 routes (26 active, 0 holddown, 0 hidden)
203.0.113.3/32 (1 entry, 1 announced)
State: <FlashAll>
TSI:
KRT in-kernel 203.0.113.3/32 -> {16.1.2.2}
*IS-IS Preference: 18
Level: 2
Next hop type: Router, Next hop index: 0
Address: 0x4a1f43c
Next-hop reference count: 4
Next hop: 16.1.2.2 via ge-1/0/1.0, selected
Session Id: 0x0
Next hop: 16.1.1.2 via ge-5/0/9.0
Session Id: 0x0
State: <Active Int HighPriority>
Local AS: 64496
Age: 59 Metric: 20
Validation State: unverified
ORR Generation-ID: 0
Tag: 18
Task: IS-IS
Announcement bits (2): 0-KRT 4-LDP
AS path: I
inet.3: 2 destinations, 2 routes (2 active, 0 holddown, 0 hidden)
203.0.113.3/32 (1 entry, 1 announced)
State: <FlashAll>
*LDP Preference: 9
Next hop type: Router, Next hop index: 0
Address: 0x4a1e55c
Next-hop reference count: 2
Next hop: 16.1.2.2 via ge-1/0/1.0, selected
Label operation: Push 299776
Label TTL action: prop-ttl
Load balance label: Label 299776: None;
Label element ptr: 0x4b99100
Label parent element ptr: 0x0
Label element references: 2
Label element child references: 0
Label element lsp id: 0
Session Id: 0x0
Next hop: 16.1.1.2 via ge-5/0/9.0
Label operation: Push 299776
Label TTL action: prop-ttl
Load balance label: Label 299776: None;
Label element ptr: 0x4b99100
Label parent element ptr: 0x0
Label element references: 2
Label element child references: 0
Label element lsp id: 0
Session Id: 0x0
State:<Active Int HighPriority>
Local AS: 64496
Age: 59 Metric: 1
Validation State: unverified
Task: LDP
Announcement bits (1): 2-Resolve tree 1
AS path: I
Secondary Tables: inet6.3
意义
输出显示 LDP 继承路由 203.0.113.3,优先级 high 来自 IS-IS。
验证 IS-IS 路由的优先级
目的
验证是否已为 IS-IS 中的路由 203.0.113.3 设置优先级。
行动
user@R1> show isis route download-priority
IS-IS routing table Current version: L1: 0 L2: 122
IPv4/IPv6 Routes
----------------
Prefix L Version Metric Type Interface NH Via Backup Score
203.0.113.3/32 2 122 20 int ge-1/0/1.0 IPV4 R2
ge-5/0/9.0 IPV4 R2
203.0.113.2/32 2 122 10 int ge-1/0/1.0 IPV4 R2
ge-5/0/9.0 IPV4 R2
198.1.1.0/24 2 122 20 int ge-1/0/1.0 IPV4 R2
ge-5/0/9.0 IPV4 R2
198.1.2.0/24 2 122 20 int ge-1/0/1.0 IPV4 R2
ge-5/0/9.0 IPV4 R2
2001:db8:2:2::1/128 2 122 10 int ge-1/0/1.0 IPV6 R2
ge-5/0/9.0 IPV6 R2
2001:db8:3:3::3/128 2 122 20 int ge-1/0/1.0 IPV6 R2
ge-5/0/9.0 IPV6 R2
2001:db8:1:1::/64 2 122 20 int ge-1/0/1.0 IPV6 R2
ge-5/0/9.0 IPV6 R2
2001:db8:1:2::/64 2 122 20 int ge-1/0/1.0 IPV6 R2
ge-5/0/9.0 IPV6 R2
意义
路径将按设置的优先级的顺序显示。设置为优先级的路由 203.0.113.3 high 显示在最顶部,然后是具有中或低优先级的路由。