示例:将 OSPF 路由重新分配给 IS-IS
此示例说明如何将 OSPF 路由重新分配到 IS-IS 网络中。
要求
配置此示例之前,不需要除设备初始化之外的特殊配置。
概述
导出策略可应用于 IS-IS,以方便路由重新分配。
Junos OS 不支持为 IS-IS 等链路状态路由协议应用导入策略,因为此类策略会导致链路状态数据库 (LSDB) 条目不一致,进而可能导致路由不一致。
在此示例中,OSPF 路由 192.168.0/24 至 192.168.3/24 将从设备 R2 重新分配到 IS-IS 区域 49.0002。
此外,配置了策略以确保设备 R1 能够到达 10.0.0.44/30 网络上的目标,并且设备 R3 可以到达 10.0.0.36/30 网络上的目标。这样可以实现端到端可达性。
图 1 显示了此示例中使用的拓扑。
CLI 快速配置 显示了 图 1 中所有设备的配置。 第 #configuration759__isis-redist-ospf-step-r2 部分介绍了设备 R2 上的步骤。 #configuration759__isis-redist-ospf-step-by-step-r3 介绍了设备 R3 上的步骤。
拓扑
配置
程序
CLI 快速配置
要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以便与网络配置匹配,然后将命令复制并粘贴到层级的 [edit]
CLI 中。
设备 R1
set interfaces fe-1/2/0 unit 0 description to-R7 set interfaces fe-1/2/0 unit 0 family inet address 10.0.0.38/30 set interfaces fe-1/2/0 unit 0 family iso set interfaces lo0 unit 0 family inet address 172.16.3.5/32 set interfaces lo0 unit 0 family iso address 49.0002.0172.0016.0305.00 set protocols isis interface fe-1/2/0.0 set protocols isis interface lo0.0
设备 R2
set interfaces fe-1/2/1 unit 0 description to-R5 set interfaces fe-1/2/1 unit 0 family inet address 10.0.0.37/30 set interfaces fe-1/2/1 unit 0 family iso set interfaces fe-1/2/0 unit 0 description to-OSPF-network set interfaces fe-1/2/0 unit 0 family inet address 10.0.0.45/30 set interfaces lo0 unit 0 family inet address 172.16.9.7/32 set interfaces lo0 unit 0 family iso address 49.0002.0172.0016.0907.00 set protocols isis export ospf-isis set protocols isis export send-direct-to-isis-neighbors set protocols isis interface fe-1/2/1.0 set protocols isis interface lo0.0 set protocols ospf export send-direct-to-ospf-neighbors set protocols ospf area 0.0.0.1 interface fe-1/2/0.0 set protocols ospf area 0.0.0.1 interface lo0.0 passive set policy-options policy-statement ospf-isis term 1 from protocol ospf set policy-options policy-statement ospf-isis term 1 from route-filter 192.168.0.0/22 longer set policy-options policy-statement ospf-isis term 1 then accept set policy-options policy-statement send-direct-to-isis-neighbors from protocol direct set policy-options policy-statement send-direct-to-isis-neighbors from route-filter 10.0.0.44/30 exact set policy-options policy-statement send-direct-to-isis-neighbors then accept set policy-options policy-statement send-direct-to-ospf-neighbors from protocol direct set policy-options policy-statement send-direct-to-ospf-neighbors from route-filter 10.0.0.36/30 exact set policy-options policy-statement send-direct-to-ospf-neighbors then accept
设备 R3
set interfaces fe-1/2/0 unit 0 family inet address 10.0.0.46/30 set interfaces lo0 unit 0 family inet address 192.168.1.1/32 set interfaces lo0 unit 0 family inet address 192.168.2.1/32 set interfaces lo0 unit 0 family inet address 192.168.3.1/32 set interfaces lo0 unit 0 family inet address 192.168.0.1/32 set protocols ospf export ospf set protocols ospf area 0.0.0.1 interface fe-1/2/0.0 set protocols ospf area 0.0.0.1 interface lo0.0 passive set policy-options policy-statement ospf term 1 from protocol static set policy-options policy-statement ospf term 1 then accept set routing-options static route 192.168.0.0/24 discard set routing-options static route 192.168.1.0/24 discard set routing-options static route 192.168.3.0/24 discard set routing-options static route 192.168.2.0/24 discard
逐步过程
要配置设备 R2:
配置网络接口。
[edit interfaces] user@R2# set fe-1/2/1 unit 0 description to-R5 user@R2# set fe-1/2/1 unit 0 family inet address 10.0.0.37/30 user@R2# set fe-1/2/1 unit 0 family iso user@R2# set fe-1/2/0 unit 0 description to-OSPF-network user@R2# set fe-1/2/0 unit 0 family inet address 10.0.0.45/30 user@R2# set lo0 unit 0 family inet address 172.16.9.7/32 user@R2# set lo0 unit 0 family iso address 49.0002.0172.0016.0907.00
在面向设备 R1 的接口和环路接口上配置 IS-IS。
[edit protocols isis] user@R2# set interface fe-1/2/1.0 user@R2# set interface lo0.0
配置使设备 R1 能够访问 10.0.0.44/30 网络的策略。
[edit policy-options policy-statement send-direct-to-isis-neighbors] user@R2# set from protocol direct user@R2# set from route-filter 10.0.0.44/30 exact user@R2# set then accept
应用使设备 R1 能够到达 10.0.0.44/30 网络的策略。
[edit protocols isis] user@R2# set export send-direct-to-isis-neighbors
在接口上配置 OSPF。
[edit protocols ospf] user@R2# set area 0.0.0.1 interface fe-1/2/0.0 user@R2# set area 0.0.0.1 interface lo0.0 passive
配置 OSPF 路由重新分配策略。
[edit policy-options policy-statement ospf-isis term 1] user@R2# set from protocol ospf user@R2# set from route-filter 192.168.0.0/22 longer user@R2# set then accept
将 OSPF 路由重新分配策略应用于 IS-IS 实例。
[edit protocols isis] user@R2# set export ospf-isis
配置使设备 R3 能够到达 10.0.0.36/30 网络的策略。
[edit policy-options policy-statement send-direct-to-ospf-neighbors] user@R2# set from protocol direct user@R2# set from route-filter 10.0.0.36/30 exact user@R2# set then accept
应用使设备 R3 能够到达 10.0.0.36/30 网络的策略。
[edit protocols ospf] user@R2# set export send-direct-to-ospf-neighbors
逐步过程
以下示例要求您在配置层次结构中的各个级别上导航。有关导航 CLI 的信息,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器。
要配置多级别 IS-IS:
配置网络接口。
环路接口上配置了多个地址,以模拟多个路由目标。
[edit interfaces] user@R3# set fe-1/2/0 unit 0 family inet address 10.0.0.46/30 user@R3# set lo0 unit 0 family inet address 192.168.1.1/32 user@R3# set lo0 unit 0 family inet address 192.168.2.1/32 user@R3# set lo0 unit 0 family inet address 192.168.3.1/32 user@R3# set lo0 unit 0 family inet address 192.168.0.1/32
配置到环路接口地址的静态路由。
这些是重新分配到 IS-IS 中的路由。
[edit routing-options static] user@R3# set route 192.168.0.0/24 discard user@R3# set route 192.168.1.0/24 discard user@R3# set route 192.168.3.0/24 discard user@R3# set route 192.168.2.0/24 discard
在接口上配置 OSPF。
[edit protocols ospf area 0.0.0.1] user@R3# set interface fe-1/2/0.0 user@R3# set interface lo0.0 passive
配置 OSPF 策略以导出静态路由。
[edit policy-options policy-statement ospf term 1] user@R3# set from protocol static user@R3# set then accept
应用 OSPF 导出策略。
[edit protocols ospf] user@R3# set export ospf
结果
在配置模式下,输入 show interfaces
、 show protocols
、 show policy-options
和 show routing-options
命令,以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以更正配置。
设备 R2
user@R2# show interfaces
fe-1/2/1 {
unit 0 {
description to-R5;
family inet {
address 10.0.0.37/30;
}
family iso;
}
}
fe-1/2/0 {
unit 0 {
description to-OSPF-network;
family inet {
address 10.0.0.45/30;
}
}
}
lo0 {
unit 0 {
family inet {
address 172.16.9.7/32;
}
family iso {
address 49.0002.0172.0016.0907.00;
}
}
}
user@R2# show protocols
isis {
export [ ospf-isis send-direct-to-isis-neighbors ];
interface fe-1/2/1.0;
interface lo0.0;
}
ospf {
export send-direct-to-ospf-neighbors;
area 0.0.0.1 {
interface fe-1/2/0.0;
interface lo0.0 {
passive;
}
}
}
user@R2# show policy-options
policy-statement ospf-isis {
term 1 {
from {
protocol ospf;
route-filter 192.168.0.0/22 longer;
}
then accept;
}
}
policy-statement send-direct-to-isis-neighbors {
from {
protocol direct;
route-filter 10.0.0.44/30 exact;
}
then accept;
}
policy-statement send-direct-to-ospf-neighbors {
from {
protocol direct;
route-filter 10.0.0.36/30 exact;
}
then accept;
}
设备 R3
user@R3# show interfaces
fe-1/2/0 {
unit 0 {
family inet {
address 10.0.0.46/30;
}
}
}
lo0 {
unit 0 {
family inet {
address 192.168.1.1/32;
address 192.168.2.1/32;
address 192.168.3.1/32;
address 192.168.0.1/32;
}
}
}
user@R3# show protocols
ospf {
export ospf;
area 0.0.0.1 {
interface fe-1/2/0.0;
interface lo0.0 {
passive;
}
}
}
user@R3# show policy-options
policy-statement ospf {
term 1 {
from protocol static;
then accept;
}
}
user@R3# show routing-options
static {
route 192.168.0.0/24 discard;
route 192.168.1.0/24 discard;
route 192.168.3.0/24 discard;
route 192.168.2.0/24 discard;
}
完成设备配置后,请从配置模式进入 commit
。
验证
确认配置工作正常。
验证 OSPF 路由播发
目的
请确保预期的路由由 OSPF 播发。
行动
在设备 R2 的操作模式下,输入 show route protocol ospf
命令。
user@R2> show route protocol ospf inet.0: 15 destinations, 15 routes (15 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 192.168.0.0/24 *[OSPF/150] 03:54:21, metric 0, tag 0 > to 10.0.0.46 via fe-1/2/0.0 192.168.0.1/32 *[OSPF/10] 03:54:21, metric 1 > to 10.0.0.46 via fe-1/2/0.0 192.168.1.0/24 *[OSPF/150] 03:54:21, metric 0, tag 0 > to 10.0.0.46 via fe-1/2/0.0 192.168.1.1/32 *[OSPF/10] 03:54:21, metric 1 > to 10.0.0.46 via fe-1/2/0.0 192.168.2.0/24 *[OSPF/150] 03:54:21, metric 0, tag 0 > to 10.0.0.46 via fe-1/2/0.0 192.168.2.1/32 *[OSPF/10] 03:54:21, metric 1 > to 10.0.0.46 via fe-1/2/0.0 192.168.3.0/24 *[OSPF/150] 03:54:21, metric 0, tag 0 > to 10.0.0.46 via fe-1/2/0.0 192.168.3.1/32 *[OSPF/10] 03:54:21, metric 1 > to 10.0.0.46 via fe-1/2/0.0 224.0.0.5/32 *[OSPF/10] 03:56:03, metric 1 MultiRecv iso.0: 1 destinations, 1 routes (1 active, 0 holddown, 0 hidden)
意义
192.168/16 路由由 OSPF 播发。
验证路由重新分配
目的
请确保预期的路由已从 OSPF 重新分配到 IS-IS。
行动
在设备 R1 上的操作模式下,输入 show route protocol isis
命令。
user@R1> show route protocol isis inet.0: 13 destinations, 13 routes (13 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 10.0.0.44/30 *[IS-IS/160] 03:45:24, metric 20 > to 10.0.0.37 via fe-1/2/0.0 172.16.9.7/32 *[IS-IS/15] 03:49:46, metric 10 > to 10.0.0.37 via fe-1/2/0.0 192.168.0.0/24 *[IS-IS/160] 03:49:46, metric 10 > to 10.0.0.37 via fe-1/2/0.0 192.168.0.1/32 *[IS-IS/160] 03:49:46, metric 11, tag2 1 > to 10.0.0.37 via fe-1/2/0.0 192.168.1.0/24 *[IS-IS/160] 03:49:46, metric 10 > to 10.0.0.37 via fe-1/2/0.0 192.168.1.1/32 *[IS-IS/160] 03:49:46, metric 11, tag2 1 > to 10.0.0.37 via fe-1/2/0.0 192.168.2.0/24 *[IS-IS/160] 03:49:46, metric 10 > to 10.0.0.37 via fe-1/2/0.0 192.168.2.1/32 *[IS-IS/160] 03:49:46, metric 11, tag2 1 > to 10.0.0.37 via fe-1/2/0.0 192.168.3.0/24 *[IS-IS/160] 03:49:46, metric 10 > to 10.0.0.37 via fe-1/2/0.0 192.168.3.1/32 *[IS-IS/160] 03:49:46, metric 11, tag2 1 > to 10.0.0.37 via fe-1/2/0.0 iso.0: 1 destinations, 1 routes (1 active, 0 holddown, 0 hidden)
意义
192.168/16 路由重新分配给 IS-IS。
验证连接性
目的
检查设备 R1 是否可以到达设备 R3 上的目标。
行动
在操作模式下,输入 ping
命令。
user@R1> ping 192.168.1.1 PING 192.168.1.1 (192.168.1.1): 56 data bytes 64 bytes from 192.168.1.1: icmp_seq=0 ttl=63 time=2.089 ms 64 bytes from 192.168.1.1: icmp_seq=1 ttl=63 time=1.270 ms 64 bytes from 192.168.1.1: icmp_seq=2 ttl=63 time=2.135 ms
意义
这些结果确认设备 R1 可以到达 OSPF 网络中的目标。