交换机
园区网交换机
数据中心与云计算交换机
行业精选交换系列
意图网络指挥官
无线
放装型无线接入点
墙面型无线接入点
智分无线接入点
室外无线接入点
场景化无线
行业精选无线系列
无线管理与应用
运营商
政府
金融
互联网
制造业
高教/职教
医疗卫生
交通
公共安全
功能介绍:
OSPF(Open Shortest Path First)为 IETF OSPF 工作组开发的一种基于链路状态的内部网关路由协议。OSPF 是专为 IP 开发的路由协议,直接运行在 IP 层上面,协议号为 89,采用组播方式进行 OSPF 包交换,组播地址为 224.0.0.5 (全部 OSPF 设备)和 224.0.0.6(指定设备)。当 OSPF 路由域规模较大时,一般采用分层结构,即将 OSPF 路由域分割成几个区域(AREA),区域之间通过一个骨干区域互联,每个非骨干区域都需要直接与骨干区域连接。
一、组网需求
路由器R1的F0/0、F0/1接口在vrf abc下,路由器R2为普通全局路由器,全网路由器运行ospf协议(全网都在area 0),使全网路由可达。
二、组网拓扑
三、配置要点
1、在R1上配置vrf abc
2、基本ip地址配置
3、在R1上将对应的接口划入vrf
4、全网路由启用ospf,并把对应的接口通告到ospf进程
四、配置步骤
1、在R1上配置vrf abc
注意:
vrf 是本地有效的,在本端起了vrf,只是本路由器上相同vrf下的接口互通,不同vrf的接口逻辑隔离,与对端路由器是否起vrf无关。
Ruijie(config)#hostname R1
R1(config)#ip vrf abc //在路由器上启用vrf abc
R1(config-vrf)#exit
2、基本ip地址配置
R1(config)#interface fastEthernet 0/2
R1(config-if-FastEthernet 0/2)#ip address 192.168.1.1 255.255.255.0
R1(config-if-FastEthernet 0/2)#exit
R1(config)#interface fastEthernet 0/0
R1(config-if-FastEthernet 0/0)#ip address 10.1.1.1 255.255.255.0
R1(config-if-FastEthernet 0/0)#exit
R1(config)#interface loopback 0 //配置loopback 0接口的地址做为ospf 的router-id
R1(config-Loopback 0)#ip address 1.1.1.1 255.255.255.255
R1(config-Loopback 0)#exit
Ruijie(config)#hostname R2
R2(config)#interface fastEthernet 0/0
R2(config-if-FastEthernet 0/0)#ip address 192.168.1.2 255.255.255.0
R2(config-if-FastEthernet 0/0)#exit
R2(config)#interface fastEthernet 0/1
R2(config-if-FastEthernet 0/1)#ip address 10.2.1.1 255.255.255.0
R2(config-if-FastEthernet 0/1)#exit
R2(config)#interface loopback 0
R2(config-if-Loopback 0)#ip address 2.2.2.2 255.255.255.255
R2(config-if-Loopback 0)#exit
3、在R1上将对应的接口划入vrf
注意:
1)将接口划入到vrf时,若该接口有配置ip地址,会将ip地址移除,需要重新配置该接口的ip地址。
2)用loopback接口做为ospf的router-id,无需把loopback接口也加入到对应的vrf
R1(config)#interface fastEthernet 0/2
R1(config-if-FastEthernet 0/2)#ip vrf forwarding abc //将接口划入对应的vrf
% Interface FastEthernet 0/2 IP address 192.168.1.1 removed due to enabling VRF abc
R1(config-if-FastEthernet 0/2)#ip address 192.168.1.1 255.255.255.0 //重新配置F0/2接口的ip地址
R1(config-if-FastEthernet 0/2)#exit
R1(config)#interface fastEthernet 0/0
R1(config-if-FastEthernet 0/0)#ip vrf forwarding abc
% Interface FastEthernet 0/0 IP address 10.1.1.1 removed due to enabling VRF abc
R1(config-if-FastEthernet 0/0)#ip address 10.1.1.1 255.255.255.0
R1(config-if-FastEthernet 0/0)#exit
4、全网路由启用ospf,并把对应的接口通告到ospf进程
注意:
vrf下的ospf配置,只是启用ospf进程时关联到对应的vrf,配置vrf下的ospf注意事项与配置普通ospf一致,请参考 ospf 基础配置 相关章节。
R1(config)#router ospf 1 vrf abc //在vrf abc下启用 ospf 进程1
R1(config-router)#network 192.168.1.1 0.0.0.0 area 0 //将192.168.1.1对应的接口通告到 ospf 区域号为 0
R1(config-router)#network 10.1.1.1 0.0.0.0 area 0
R1(config-router)#exit
R2(config)#router ospf 1
R2(config-router)#network 192.168.1.2 0.0.0.0 area 0
R2(config-router)#network 10.2.1.1 0.0.0.0 area 0
R2(config-router)#exit
五、配置验证
1、查看相邻的路由器之间是否建立ospf邻居关系,及邻居状态。若相邻路由器能够正常建立邻居关系,且状态为full,则ospf运行正常。
R1#show ip ospf neighbor
OSPF process 1, 1 Neighbors, 1 is Full:
Neighbor ID Pri State BFD State Dead Time Address Interface
2.2.2.2 1 Full/BDR - 00:00:36 192.168.1.2 FastEthernet 0/2
2、查看R1对应vrf下的路由表及其它路由器的全局路由表,若每台路由器都能学习到整网的路由,则vrf下的ospf配置正确。
R1#show ip route vrf abc
Routing Table: abc
Codes: C - connected, S - static, R - RIP, B - BGP
O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default
Gateway of last resort is no set
C 10.1.1.0/24 is directly connected, FastEthernet 0/0
C 10.1.1.1/32 is local host.
O 10.2.1.0/24 [110/2] via 192.168.1.2, 00:10:21, FastEthernet 0/2
C 192.168.1.0/24 is directly connected, FastEthernet 0/2
C 192.168.1.1/32 is local host.