在逻辑系统上配置 OSPF
对逻辑系统的 OSPF 支持
本主题介绍以下信息:
逻辑系统简介
使用 Junos OS,您可以将单个物理路由器划分为多个逻辑设备,由这些设备执行独立的路由任务。由于逻辑系统只执行由主路由器处理的任务的子集,因此逻辑系统可提供一种有效的方式来最大限度地利用单个路由或交换平台。逻辑系统有自己独特的路由表、接口、策略和路由实例。
OSPF 和逻辑系统
您可以为逻辑系统配置 OSPF 版本 2 (OSPFv2) 和 OSPF 版本 3 (OSPFv3)。如果采用 OSPFv3,您还可以为逻辑系统配置 OSPFv3 领域,这样 OSPFv3 就可以通告单播 IPv6 以外的地址族。
您可以在以下层级为逻辑系统配置 OSPF:
[编辑逻辑系统 logical-system-name 协议 (OSPF | OSPF3)]
[编辑逻辑系统 logical-system-name 协议 OSPF3 领域(IPv4 单播 | IPv4 组播 | IPv6 组播)]
[编辑逻辑系统 logical-system-name 路由实例 routing-instance-name 协议 (OSPF | OSPF3)]
[编辑逻辑系统 logical-system-name 路由实例 routing-instance-name 协议 OSPF3 领域 (IPv4-单播 | IPv4-组播 | IPv6-组播)]
示例:在同一路由器内的逻辑系统上配置 OSPF
此示例说明如何使用在单个物理路由器上运行的多个逻辑系统配置 OSPF 网络。逻辑系统通过逻辑隧道接口进行连接。
要求
您必须使用逻辑隧道 (lt) 接口连接逻辑系统。请参阅 示例:使用 MX 系列路由器和 EX 系列交换机上的逻辑隧道接口连接同一设备内的逻辑系统。
概述
此示例显示了在单个 OSPF 区域的配置,其中三个逻辑系统在一个物理路由器上运行。每个逻辑系统都有自己的路由表。此配置可在参与 OSPF 域的所有逻辑系统接口上启用该协议,并指定接口所在的区域。
配置
CLI 快速配置
要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以便与网络配置匹配,将命令复制并粘贴到 [edit] 层次结构级别的 CLI 中,然后从配置模式进入 commit 。
set logical-systems LS1 interfaces lt-1/2/0 unit 0 description LS1->LS3 set logical-systems LS1 interfaces lt-1/2/0 unit 0 encapsulation ethernet set logical-systems LS1 interfaces lt-1/2/0 unit 0 peer-unit 5 set logical-systems LS1 interfaces lt-1/2/0 unit 0 family inet address 10.0.1.2/30 set logical-systems LS1 interfaces lt-1/2/0 unit 2 description LS1->LS2 set logical-systems LS1 interfaces lt-1/2/0 unit 2 encapsulation ethernet set logical-systems LS1 interfaces lt-1/2/0 unit 2 peer-unit 1 set logical-systems LS1 interfaces lt-1/2/0 unit 2 family inet address 10.0.0.1/30 set logical-systems LS1 protocols ospf area 0.0.0.0 interface lt-1/2/0.0 set logical-systems LS1 protocols ospf area 0.0.0.0 interface lt-1/2/0.2 set logical-systems LS2 interfaces lt-1/2/0 unit 1 description LS2->LS1 set logical-systems LS2 interfaces lt-1/2/0 unit 1 encapsulation ethernet set logical-systems LS2 interfaces lt-1/2/0 unit 1 peer-unit 2 set logical-systems LS2 interfaces lt-1/2/0 unit 1 family inet address 10.0.0.2/30 set logical-systems LS2 interfaces lt-1/2/0 unit 4 description LS2->LS3 set logical-systems LS2 interfaces lt-1/2/0 unit 4 encapsulation ethernet set logical-systems LS2 interfaces lt-1/2/0 unit 4 peer-unit 3 set logical-systems LS2 interfaces lt-1/2/0 unit 4 family inet address 10.0.2.2/30 set logical-systems LS2 protocols ospf area 0.0.0.0 interface lt-1/2/0.1 set logical-systems LS2 protocols ospf area 0.0.0.0 interface lt-1/2/0.4 set logical-systems LS3 interfaces lt-1/2/0 unit 3 description LS3->LS2 set logical-systems LS3 interfaces lt-1/2/0 unit 3 encapsulation ethernet set logical-systems LS3 interfaces lt-1/2/0 unit 3 peer-unit 4 set logical-systems LS3 interfaces lt-1/2/0 unit 3 family inet address 10.0.2.1/30 set logical-systems LS3 interfaces lt-1/2/0 unit 5 description LS3->LS1 set logical-systems LS3 interfaces lt-1/2/0 unit 5 encapsulation ethernet set logical-systems LS3 interfaces lt-1/2/0 unit 5 peer-unit 0 set logical-systems LS3 interfaces lt-1/2/0 unit 5 family inet address 10.0.1.1/30 set logical-systems LS3 protocols ospf area 0.0.0.0 interface lt-1/2/0.5 set logical-systems LS3 protocols ospf area 0.0.0.0 interface lt-1/2/0.3
程序
分步过程
下面的示例要求您在各个配置层级中进行导航。有关 CLI 导航的信息,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器。
要在逻辑系统上配置 OSPF,请执行以下作:
在连接到逻辑系统 LS2 的逻辑系统 LS1 上配置逻辑隧道接口。
[edit] user@host# set logical-systems LS1 interfaces lt-1/2/0 unit 2 description LS1->LS2 user@host# set logical-systems LS1 interfaces lt-1/2/0 unit 2 encapsulation ethernet user@host# set logical-systems LS1 interfaces lt-1/2/0 unit 2 peer-unit 1 user@host# set logical-systems LS1 interfaces lt-1/2/0 unit 2 family inet address 10.0.0.1/30
在连接到逻辑系统 LS3 的逻辑系统 LS1 上配置逻辑隧道接口。
[edit] user@host# set logical-systems LS1 interfaces lt-1/2/0 unit 0 description LS1->LS3 user@host# set logical-systems LS1 interfaces lt-1/2/0 unit 0 encapsulation ethernet user@host# set logical-systems LS1 interfaces lt-1/2/0 unit 0 peer-unit 5 user@host# set logical-systems LS1 interfaces lt-1/2/0 unit 0 family inet address 10.0.1.2/30
在连接到逻辑系统 LS1 的逻辑系统 LS2 上配置逻辑隧道接口。
[edit] user@host# set logical-systems LS2 interfaces lt-1/2/0 unit 1 description LS2->LS1 user@host# set logical-systems LS2 interfaces lt-1/2/0 unit 1 encapsulation ethernet user@host# set logical-systems LS2 interfaces lt-1/2/0 unit 1 peer-unit 2 user@host# set logical-systems LS2 interfaces lt-1/2/0 unit 1 family inet address 10.0.0.2/30
在连接到逻辑系统 LS3 的逻辑系统 LS2 上配置逻辑隧道接口。
[edit] user@host# set logical-systems LS2 interfaces lt-1/2/0 unit 4 description LS2->LS3 user@host# set logical-systems LS2 interfaces lt-1/2/0 unit 4 encapsulation ethernet user@host# set logical-systems LS2 interfaces lt-1/2/0 unit 4 peer-unit 3 user@host# set logical-systems LS2 interfaces lt-1/2/0 unit 4 family inet address 10.0.2.2/30
在连接到逻辑系统 LS2 的逻辑系统 LS3 上配置逻辑隧道接口。
[edit] user@host# set logical-systems LS3 interfaces lt-1/2/0 unit 3 description LS3->LS2 user@host# set logical-systems LS3 interfaces lt-1/2/0 unit 3 encapsulation ethernet user@host# set logical-systems LS3 interfaces lt-1/2/0 unit 3 peer-unit 4 user@host# set logical-systems LS3 interfaces lt-1/2/0 unit 3 family inet address 10.0.2.1/30
在连接到逻辑系统 LS1 的逻辑系统 LS3 上配置逻辑隧道接口。
[edit] user@host# set logical-systems LS3 interfaces lt-1/2/0 unit 5 description LS3->LS1 user@host# set logical-systems LS3 interfaces lt-1/2/0 unit 5 encapsulation ethernet user@host# set logical-systems LS3 interfaces lt-1/2/0 unit 5 peer-unit 0 user@host# set logical-systems LS3 interfaces lt-1/2/0 unit 5 family inet address 10.0.1.1/30
在所有接口上配置 OSPF。
[edit] user@host# set logical-systems LS1 protocols ospf area 0.0.0.0 interface lt-1/2/0.0 user@host# set logical-systems LS1 protocols ospf area 0.0.0.0 interface lt-1/2/0.2 user@host# set logical-systems LS2 protocols ospf area 0.0.0.0 interface lt-1/2/0.1 user@host# set logical-systems LS2 protocols ospf area 0.0.0.0 interface lt-1/2/0.4 user@host# set logical-systems LS3 protocols ospf area 0.0.0.0 interface lt-1/2/0.5 user@host# set logical-systems LS3 protocols ospf area 0.0.0.0 interface lt-1/2/0.3
如果完成设备配置,请提交配置。
[edit] user@host# commit
结果
发出 show logical-systems 命令,确认您的配置。
show logical-systems
LS1 {
interfaces {
lt-1/2/0 {
unit 0 {
description LS1->LS3;
encapsulation ethernet;
peer-unit 5;
family inet {
address 10.0.1.2/30;
}
}
unit 2 {
description LS1->LS2;
encapsulation ethernet;
peer-unit 1;
family inet {
address 10.0.0.1/30;
}
}
}
}
protocols {
ospf {
area 0.0.0.0 {
interface lt-1/2/0.0;
interface lt-1/2/0.2;
}
}
}
}
LS2 {
interfaces {
lt-1/2/0 {
unit 1 {
description LS2->LS1;
encapsulation ethernet;
peer-unit 2;
family inet {
address 10.0.0.2/30;
}
}
unit 4 {
description LS2->LS3;
encapsulation ethernet;
peer-unit 3;
family inet {
address 10.0.2.2/30;
}
}
}
}
protocols {
ospf {
area 0.0.0.0 {
interface lt-1/2/0.1;
interface lt-1/2/0.4;
}
}
}
}
LS3 {
interfaces {
lt-1/2/0 {
unit 3 {
description LS3->LS2;
encapsulation ethernet;
peer-unit 4;
family inet {
address 10.0.2.1/30;
}
}
unit 5 {
description LS3->LS1;
encapsulation ethernet;
peer-unit 0;
family inet {
address 10.0.1.1/30;
}
}
}
}
protocols {
ospf {
area 0.0.0.0 {
interface lt-1/2/0.5;
interface lt-1/2/0.3;
}
}
}
}
验证
确认配置工作正常。
验证逻辑系统是否已启动
目的
请确保接口配置正确。
行动
user@host> show interfaces terse Interface Admin Link Proto Local Remote ... lt-1/2/0 up up lt-1/2/0.0 up up inet 10.0.1.2/30 lt-1/2/0.1 up up inet 10.0.0.2/30 lt-1/2/0.2 up up inet 10.0.0.1/30 lt-1/2/0.3 up up inet 10.0.2.1/30 lt-1/2/0.4 up up inet 10.0.2.2/30 lt-1/2/0.5 up up inet 10.0.1.1/30 ...
验证逻辑系统之间的连通性
目的
请确保通过检查 OSPF 邻居表、检查路由表和对逻辑系统执行 ping 命令来建立 OSPF 邻接。
行动
user@host> show ospf neighbor logical-system LS1 Address Interface State ID Pri Dead 10.0.1.1 lt-1/2/0.0 Full 10.0.1.1 128 37 10.0.0.2 lt-1/2/0.2 Full 10.0.0.2 128 33
user@host> show ospf neighbor logical-system LS2 Address Interface State ID Pri Dead 10.0.0.1 lt-1/2/0.1 Full 10.0.0.1 128 32 10.0.2.1 lt-1/2/0.4 Full 10.0.1.1 128 36
user@host> show ospf neighbor logical-system LS3 Address Interface State ID Pri Dead 10.0.2.2 lt-1/2/0.3 Full 10.0.0.2 128 36 10.0.1.2 lt-1/2/0.5 Full 10.0.0.1 128 37
user@host> show route logical-system LS1
inet.0: 6 destinations, 6 routes (6 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
10.0.0.0/30 *[Direct/0] 00:28:00
> via lt-1/2/0.2
10.0.0.1/32 *[Local/0] 00:28:00
Local via lt-1/2/0.2
10.0.1.0/30 *[Direct/0] 00:28:00
> via lt-1/2/0.0
10.0.1.2/32 *[Local/0] 00:28:00
Local via lt-1/2/0.0
10.0.2.0/30 *[OSPF/10] 00:27:05, metric 2
> to 10.0.1.1 via lt-1/2/0.0
to 10.0.0.2 via lt-1/2/0.2
224.0.0.5/32 *[OSPF/10] 00:28:03, metric 1
MultiRecv
user@host> show route logical-system LS2
inet.0: 6 destinations, 6 routes (6 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
10.0.0.0/30 *[Direct/0] 00:28:31
> via lt-1/2/0.1
10.0.0.2/32 *[Local/0] 00:28:32
Local via lt-1/2/0.1
10.0.1.0/30 *[OSPF/10] 00:27:38, metric 2
> to 10.0.0.1 via lt-1/2/0.1
to 10.0.2.1 via lt-1/2/0.4
10.0.2.0/30 *[Direct/0] 00:28:32
> via lt-1/2/0.4
10.0.2.2/32 *[Local/0] 00:28:32
Local via lt-1/2/0.4
224.0.0.5/32 *[OSPF/10] 00:28:34, metric 1
MultiRecv
user@host> show route logical-system LS3
inet.0: 6 destinations, 6 routes (6 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
10.0.0.0/30 *[OSPF/10] 00:28:23, metric 2
> to 10.0.2.2 via lt-1/2/0.3
to 10.0.1.2 via lt-1/2/0.5
10.0.1.0/30 *[Direct/0] 00:29:13
> via lt-1/2/0.5
10.0.1.1/32 *[Local/0] 00:29:15
Local via lt-1/2/0.5
10.0.2.0/30 *[Direct/0] 00:29:14
> via lt-1/2/0.3
10.0.2.1/32 *[Local/0] 00:29:15
Local via lt-1/2/0.3
224.0.0.5/32 *[OSPF/10] 00:29:16, metric 1
MultiRecv
从 LS1、Ping LS3
user@host> set cli logical-system LS1
user@host:LS1> ping 10.0.2.1 PING 10.0.2.1 (10.0.2.1): 56 data bytes 64 bytes from 10.0.2.1: icmp_seq=0 ttl=64 time=1.215 ms 64 bytes from 10.0.2.1: icmp_seq=1 ttl=64 time=1.150 ms 64 bytes from 10.0.2.1: icmp_seq=2 ttl=64 time=1.134 ms
从 LS3、Ping LS1
user@host> set cli logical-system LS3
user@host:LS3> ping 10.0.0.1 PING 10.0.0.1 (10.0.0.1): 56 data bytes 64 bytes from 10.0.0.1: icmp_seq=0 ttl=64 time=1.193 ms 64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=1.114 ms 64 bytes from 10.0.0.1: icmp_seq=2 ttl=64 time=1.190 ms
