步骤 2 配置OSPF路由控制
在R1、R2上均创建Loopback2接口,IP地址为172.16.2.1/24,均在Loopback2接口上激活OSPF,在R3上限制等价路由数目为1。
在R4上创建Loopback3接口,IP地址为172.16.3.1/24,修改OSPF接口类型为Broadcast,在Loopback3接口上激活OSPF,在ABR R3上执行区域间Type-3 LSA过滤,限制OSPF区域间路由172.16.3.0/24向区域0传递。
#在R1、R2上创建Loopback2接口
[R1]interface LoopBack2
[R1-LoopBack2] ip address 172.16.2.1 255.255.255.0
[R1-LoopBack2] quit
[R2]interface LoopBack2
[R2-LoopBack2] ip address 172.16.2.1 255.255.255.0
[R2-LoopBack2] quit
#在R1、R2的Loopback2接口上激活OSPF
[R1]ospf 1
[R1-ospf-1]area 0.0.0.0
[R1-ospf-1-area-0.0.0.0] network 172.16.2.1 0.0.0.0
[R1-ospf-1-area-0.0.0.0] quit
[R1-ospf-1] quit
[R2]ospf 1
[R2-ospf-1]area 0.0.0.0
[R2-ospf-1-area-0.0.0.0] network 172.16.2.1 0.0.0.0
[R2-ospf-1-area-0.0.0.0] quit
[R2-ospf-1]quit
#重新打开R3的GE0/0/1接口
[R3]interface GigabitEthernet0/0/1
[R3-GigabitEthernet0/0/1] undo shutdown
#等待R1、R3之间的OSPF邻居关系重新建立后,查看R3的OSPF路由表
[R3-ospf-1]display ospf routing
此时R3上OSPF路由 172.16.2.1/32 形成了负载分担,下一跳分别为R1、R2。
#R3限制负载分担的等价路由的最大数量为1
[R3]ospf 1
[R3-ospf-1] maximum load-balancing 1
#再次查看R3的OSPF路由表
[R3]display ospf routing
R3上OSPF路由 172.16.2.1/32此时只存在一条,下一跳为R2。
当组网中存在的等价路由数量大于maximum load-balancing命令配置的等价路由数量时,按照下面原则选取有效路由进行负载分担:
1) 路由优先级:负载分担选取优先级小的路由进行负载分担。
2) 接口索引:如果接口的优先级相同,则比较接口的索引,负载分担选取接口索引大的路由进行负载分担。
3) 下一跳IP地址:如果接口的优先级和接口索引都相同,则比较下一跳IP地址,负载分担选取IP地址大的路由进行负载分担。
R3连接R2的接口(GE0/0/3)索引值大于连接R1的接口(GE0/0/1)索引值,因此来自R2的OSPF路由172.16.2.1/32成为有效路由。 #在R4上创建Loopback3,并激活OSPF
[R4]interface LoopBack 3
[R4-LoopBack3] ip address 172.16.3.1 24
[R4-LoopBack3] ospf network-type broadcast
[R4-LoopBack3] quit
[R4]ospf 1
[R4-ospf-1]area 1
[R4-ospf-1-area-0.0.0.1] network 172.16.3.1 0.0.0.0
[R4-ospf-1-area-0.0.0.1] quit
[R4-ospf-1] quit
#在R1上查看OSPF路由
display ospf routing
此时R1已经学习到R4的Loopback3接口路由。
#在R3上查看OSPF LSDB
[R3]display ospf lsdb
ABR R3上Area 0的LSDB中可以观察到Type-3 LSA 172.16.3.0。
#在ABR R3上配置Type-3 LSA过滤,限制OSPF区域间路由172.16.3.0/24向区域0的传递
[R3]ip ip-prefix 1 index 10 deny 172.16.3.0 24 greater-equal 24 less-equal 24
[R3]ip ip-prefix 1 index 20 permit 0.0.0.0 0 less-equal 32
[R3]ospf 1
[R3-ospf-1] area 1
[R3-ospf-1-area-0.0.0.1] filter ip-prefix 1 export
#再次在R3上查看OSPF LSDB
[R3]display ospf lsdb
此时R3的Area 0 LSDB中无法观察到Type-3 LSA 172.16.3.0。
#在R1上查看OSPF路由172.6.3.1/24
display ospf routing 172.16.3.1 24
OSPF Process 1 with Router ID 10.0.1.1
并不存在OSPF路由172.6.3.1/24。
步骤 3 IS-IS缺省路由控制 在IS-IS Level-1-2设备R4上发布缺省路由,在IS-IS Level-1设备R5上观察缺省路由生成情况。
#在R4上发布缺省路由
[R4]isis 1
[R4-isis-1] default-route-advertise always level-1-2
#在R5上查看IS-IS路由
display isis route
R5上已经成功学习到由R4发布的默认路由。
#R5上查看IS-IS LSDB
display isis lsdb verbose
来自R4的LSP 0000.0000.0004.00-01携带了默认路由。
思考题
为什么可以在ABR上通过filter ip-prefix ip-prefix-name export命令过滤OSPF区域间路由,而无法通过在OSPF区域内部路由器执行该命令过滤区域内部路由?
配置参考
R1设备配置
#
sysname R1
#
bfd
#
interface GigabitEthernet0/0/1
ip address 10.0.13.1 255.255.255.0
ospf bfd enable
ospf bfd min-tx-interval 500 min-rx-interval 500 detect-multiplier 4
#
interface GigabitEthernet0/0/2
ip address 10.0.12.1 255.255.255.0
ospf bfd enable
ospf bfd min-tx-interval 500 min-rx-interval 500 detect-multiplier 4
#
interface LoopBack1
ip address 10.0.1.1 255.255.255.0
#
interface LoopBack2
ip address 172.16.2.1 255.255.255.0
#
ospf 1 router-id 10.0.1.1
bfd all-interfaces enable
frr
loop-free-alternate
area 0.0.0.0
network 10.0.13.1 0.0.0.0
network 10.0.12.1 0.0.0.0
network 10.0.1.1 0.0.0.0
network 172.16.2.1 0.0.0.0
#
return
R2设备配置
#
sysname R2
#
bfd
#
interface GigabitEthernet0/0/2
ip address 10.0.23.2 255.255.255.0
ospf bfd enable
ospf bfd min-tx-interval 500 min-rx-interval 500 detect-multiplier 4
#
interface GigabitEthernet0/0/3
ip address 10.0.12.2 255.255.255.0
ospf bfd enable
ospf bfd min-tx-interval 500 min-rx-interval 500 detect-multiplier 4
#
interface LoopBack0
ip address 10.0.2.2 255.255.255.0
#
interface LoopBack2
ip address 172.16.2.1 255.255.255.0
#
ospf 1 router-id 10.0.2.2
bfd all-interfaces enable
area 0.0.0.0
network 10.0.12.2 0.0.0.0
network 10.0.23.2 0.0.0.0
network 10.0.2.2 0.0.0.0
network 172.16.2.1 0.0.0.0
#
return
R3设备配置
#
sysname R3
#
bfd
#
interface GigabitEthernet0/0/1
ip address 10.0.13.3 255.255.255.0
ospf bfd enable
ospf bfd min-tx-interval 500 min-rx-interval 500 detect-multiplier 4
#
interface GigabitEthernet0/0/2
ip address 10.0.34.3 255.255.255.0
ospf bfd enable
ospf bfd min-tx-interval 500 min-rx-interval 500 detect-multiplier 4
#
interface GigabitEthernet0/0/3
ip address 10.0.23.3 255.255.255.0
ospf bfd enable
ospf bfd min-tx-interval 500 min-rx-interval 500 detect-multiplier 4
#
interface LoopBack0
ip address 10.0.3.3 255.255.255.0
#
ospf 1 router-id 10.0.3.3
bfd all-interfaces enable
maximum load-balancing 1
area 0.0.0.0
network 10.0.13.3 0.0.0.0
network 10.0.23.3 0.0.0.0
network 10.0.3.3 0.0.0.0
area 0.0.0.1
filter ip-prefix 1 export
network 10.0.34.3 0.0.0.0
#
ip ip-prefix 1 index 10 deny 172.16.3.0 24 greater-equal 24 less-equal 24
ip ip-prefix 1 index 20 permit 0.0.0.0 0 less-equal 32
#
return
R4设备配置
#
sysname R4
#
bfd
#
isis 1 network-entity 49.0001.0000.0000.0004.00
default-route-advertise always level-1-2
#
interface GigabitEthernet0/0/2
ip address 10.0.45.4 255.255.255.0
isis enable 1
#
interface GigabitEthernet0/0/3
ip address 10.0.34.4 255.255.255.0
ospf bfd enable
ospf bfd min-tx-interval 500 min-rx-interval 500 detect-multiplier 4
#
interface LoopBack0
ip address 10.0.4.4 255.255.255.0
#
interface LoopBack3
ip address 172.16.3.1 255.255.255.0
ospf network-type broadcast
#
ospf 1 router-id 10.0.4.4
bfd all-interfaces enable
area 0.0.0.1
network 10.0.34.4 0.0.0.0
network 10.0.4.4 0.0.0.0
network 172.16.3.1 0.0.0.0
#
return
R5设备配置
#
sysname R5
#
isis 1
is-level level-1
network-entity 49.0001.0000.0000.0005.00
#
interface GigabitEthernet0/0/3
ip address 10.0.45.5 255.255.255.0
isis enable 1
#
interface LoopBack0
ip address 10.0.5.5 255.255.255.0
isis enable 1
#
return
关键词:设置OSPF路由控制(路由器设置OSPF)