FortiGate-v5.2-BGP 协议的条件通告

简介

当前,BGP 已经被广泛应用于大中型的网络世界里,其适用于结构复杂、路
由庞大的网络当中。网络管理员确信使用BGP 协议更简单的管理路由信息交换、
分发、管理和控制。现实BGP 路由控制的方式也多种多样,本文主要介绍BGP
协议中的一种分发和控制路由的方式,条件通告(Conditional Advertising)。在
FortiOS v5.2.x 以后的版本支持。

FortiGate 相关命令介绍

BGP 的条件路由通告可以指定BGP 需要发布的路由由某个路由状态决定其发
布还是撤消。其关键参数为exist 和non-exist。举个例子,比如route-map 定义
了需要发往A 的路由策略,此路由策略匹配了B 的条件路由策略,B 的路由条件
策略决定A 如何发布。当选择exist 参数时,A 的路由发布,只有在B 路由存在
的情况下,A 路由才会进行发布。当选择non-exist 时,只有B 路由不存在时,A
路由才会发布。
FortiOS v5.2.x 上的配置如下:

config router bgp
config neighbor
edit <name>
set remote-as 3
config conditional-advertise
edit <name> //匹配需要发布的策略//
set condition-routemap <name> //匹配条件路由策略//
set condition-type {exist | non-exist} //选择决定发布方式//
end
end
end
end
end

测试拓扑图及内容
在这里插入图片描述
 Router1 和FW1 建立BGP 邻居
 FW1 重分布直连和静态路由、汇总路由
 测试1,non-exist 参数,当20.1.1.0/24 不存在时,才会发布汇总路由20.1.1.0/16
 测试2,exist 参数,当20.1.1.0/24 存在时,才会发布汇总路由 20.1.1.0/16

测试过程

1.Router 1 与FW1 使用直接接口建立 EBGP 邻居,Router 1 的 AS 号为2,FW1的AS 号为1。
FW1 的配置如下:

config router bgp
set as 1
set router-id 192.168.0.20
set log-neighbour-changes enable
config neighbor
edit "192.168.0.50"
set soft-reconfiguration enable
set remote-as 2
next
end

路由器的配置如下:

router bgp 2
no synchronization
bgp router-id 192.168.0.50
bgp log-neighbor-changes
neighbor 192.168.0.20 remote-as 1
neighbor 192.168.0.20 soft-reconfiguration inbound
no auto-summary
!

2.FW1 配置静态路由20.1.1.0/24 和黑洞路由20.0.0.0/16,并将静态路由和直
连接口路由发布置BGP。

config router bgp
config redistribute "connected"
set status enable
end
config redistribute "static"
set status enable
end
FW1 # get router info bgp neighbors 192.168.0.50 advertised-route
BGP table version is 16, local router ID is 192.168.0.20
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 20.1.0.0/16 192.168.0.20 32768 ?
*> 20.1.1.0/24 192.168.0.20 32768 ?
*> 30.1.1.0/24 192.168.0.20 32768 ?
*> 192.168.0.0 192.168.0.20 32768 ?
*> 200.1.1.0 192.168.0.20 32768 ?
Total number of prefixes 5

3.FW1 通过prefix-list 匹配20.1.0.0/16 和20.1.1.0/24 的路由,并且在
Route-map 上定义。如下所示:

config router prefix-list
edit "20.1.0.0/16"
config rule
edit 1
set prefix 20.1.0.0 255.255.0.0
unset ge
unset le
next
end
next
edit "20.1.1.0/24"
config rule
edit 1
set prefix 20.1.1.0 255.255.255.0
unset ge
unset le
next
end
next
end
config router route-map
edit "To_R1"
config rule
edit 1
set match-ip-address "20.1.0.0/16"
next
end
next
edit "Condition-route"
config rule
edit 1
set match-ip-address "20.1.1.0/24"
next
end
next
end
  1. 测试1,non-exist 参数,当20.1.1.0/24 不存在时,才会发布汇总路由。20.1.1.0/16,如下所示:
config router bgp
set as 1
set router-id 192.168.0.20
set log-neighbour-changes enable
config neighbor
edit "192.168.0.50"
set soft-reconfiguration enable
set remote-as 2
config conditional-advertise
edit "To_R1" //匹配20.1.0.0/16 的汇总路由//
set condition-routemap "Condition-route"
//匹配20.1.1.0/24 的条件路由//
set condition-type non-exist
//设置non-exsit 参数//
next
end
next
FW1 # get router info bgp neighbors 192.168.0.50 advertised-routes
//检测FW1 的adj-out 表发现,20.1.0.0/16 并没有通过到Router1//
BGP table version is 17, local router ID is 192.168.0.20
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 20.1.1.0/24 192.168.0.20 32768 ?
*> 30.1.1.0/24 192.168.0.20 32768 ?
*> 192.168.0.0 192.168.0.20 32768 ?
*> 200.1.1.0 192.168.0.20 32768 ?
FW1 # config router static
//当在FW1 上删除20.1.1.0/24 的路由时,20.1.0.0/16 汇总路由能正常通告//
FW1 (static) # delete 2
FW1 (static) # end
FW1 # get router info bgp network
BGP table version is 21, local router ID is 192.168.0.20
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 20.1.0.0/16 0.0.0.0 32768 ?
*> 30.1.1.0/24 0.0.0.0 32768 ?
*> 192.168.0.0 0.0.0.0 32768 ?
*> 200.1.1.0 0.0.0.0 32768 ?
Total number of prefixes 4
  1. 测试2,exist 参数,当20.1.1.0/24 存在时,才会发布汇总路由20.1.1.0/16,
config router bgp
//测试exist 参数,exist 为缺省参数,因此,配置没有显示//
set as 1
set router-id 192.168.0.20
set log-neighbour-changes enable
config neighbor
edit "192.168.0.50"
set soft-reconfiguration enable
set remote-as 2
config conditional-advertise
edit "To_R1"
set condition-routemap "Condition-route"
next
------------------------------------------------------------------------------------------------------------------------------------------
Fortinet 公司www.fortinet.com.cn
1
FortiGate-v5.2-BGP 协议的条件通告
版本1.0
时间20152 月
支持的版本FortiOS v5.2.x 以后版本
作者黄豪赫
状态已审核
反馈support_cn@fortinet.com
------------------------------------------------------------------------------------------------------------------------------------------
Fortinet 公司www.fortinet.com.cn
2
目录
简介.............................................................................................................................................3
相关组件.....................................................................................................................................3
参考文档.....................................................................................................................................3
FortiGate 相关命令介绍.......................................................................................................... 3
测试拓扑图及内容.....................................................................................................................4
测试过程.....................................................................................................................................4
------------------------------------------------------------------------------------------------------------------------------------------
Fortinet 公司www.fortinet.com.cn
3
简介
当前,BGP 已经被广泛应用于大中型的网络世界里,其适用于结构复杂、路
由庞大的网络当中。网络管理员确信使用BGP 协议更简单的管理路由信息交换、
分发、管理和控制。现实BGP 路由控制的方式也多种多样,本文主要介绍BGP
协议中的一种分发和控制路由的方式,条件通告(Conditional Advertising)。在
FortiOS v5.2.x 以后的版本支持。
相关组件
FortiGate 防火墙
参考文档
《FortiOS Handbook What’s New for FortiOS 5.2》
FortiGate 相关命令介绍
BGP 的条件路由通告可以指定BGP 需要发布的路由由某个路由状态决定其发
布还是撤消。其关键参数为exist 和non-exist。举个例子,比如route-map 定义
了需要发往A 的路由策略,此路由策略匹配了B 的条件路由策略,B 的路由条件
策略决定A 如何发布。当选择exist 参数时,A 的路由发布,只有在B 路由存在
的情况下,A 路由才会进行发布。当选择non-exist 时,只有B 路由不存在时,A
路由才会发布。
FortiOS v5.2.x 上的配置如下:
config router bgp
config neighbor
edit <name>
set remote-as 3
config conditional-advertise
edit <name> //匹配需要发布的策略//
set condition-routemap <name> //匹配条件路由策略//
set condition-type {exist | non-exist} //选择决定发布方式//
end
------------------------------------------------------------------------------------------------------------------------------------------
Fortinet 公司www.fortinet.com.cn
4
end
end
end
end
测试拓扑图及内容
 Router1 和FW1 建立BGP 邻居
 FW1 重分布直连和静态路由、汇总路由
 测试1,non-exist 参数,当20.1.1.0/24 不存在时,才会发布汇总路由20.1.1.0/16
 测试2,exist 参数,当20.1.1.0/24 存在时,才会发布汇总路由20.1.1.0/16
测试过程
1.Router 1 与FW1 使用直接接口建立EBGP 邻居,Router 1 的AS 号为2,FW1
的AS 号为1。
FW1 的配置如下:
config router bgp
set as 1
set router-id 192.168.0.20
set log-neighbour-changes enable
config neighbor
edit "192.168.0.50"
set soft-reconfiguration enable
set remote-as 2
next
end
路由器的配置如下:
router bgp 2
no synchronization
------------------------------------------------------------------------------------------------------------------------------------------
Fortinet 公司www.fortinet.com.cn
5
bgp router-id 192.168.0.50
bgp log-neighbor-changes
neighbor 192.168.0.20 remote-as 1
neighbor 192.168.0.20 soft-reconfiguration inbound
no auto-summary
!
2.FW1 配置静态路由20.1.1.0/24 和黑洞路由20.0.0.0/16,并将静态路由和直
连接口路由发布置BGP。
config router bgp
config redistribute "connected"
set status enable
end
config redistribute "static"
set status enable
end
FW1 # get router info bgp neighbors 192.168.0.50 advertised-route
BGP table version is 16, local router ID is 192.168.0.20
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 20.1.0.0/16 192.168.0.20 32768 ?
*> 20.1.1.0/24 192.168.0.20 32768 ?
*> 30.1.1.0/24 192.168.0.20 32768 ?
*> 192.168.0.0 192.168.0.20 32768 ?
*> 200.1.1.0 192.168.0.20 32768 ?
Total number of prefixes 5
3.FW1 通过prefix-list 匹配20.1.0.0/1620.1.1.0/24 的路由,并且在
Route-map 上定义。如下所示:
config router prefix-list
edit "20.1.0.0/16"
config rule
edit 1
set prefix 20.1.0.0 255.255.0.0
unset ge
unset le
next
end
next
edit "20.1.1.0/24"
config rule
------------------------------------------------------------------------------------------------------------------------------------------
Fortinet 公司www.fortinet.com.cn
6
edit 1
set prefix 20.1.1.0 255.255.255.0
unset ge
unset le
next
end
next
end
config router route-map
edit "To_R1"
config rule
edit 1
set match-ip-address "20.1.0.0/16"
next
end
next
edit "Condition-route"
config rule
edit 1
set match-ip-address "20.1.1.0/24"
next
end
next
end
5. 测试1,non-exist 参数,当20.1.1.0/24 不存在时,才会发布汇总路由。
20.1.1.0/16,如下所示:
config router bgp
set as 1
set router-id 192.168.0.20
set log-neighbour-changes enable
config neighbor
edit "192.168.0.50"
set soft-reconfiguration enable
set remote-as 2
config conditional-advertise
edit "To_R1" //匹配20.1.0.0/16 的汇总路由//
set condition-routemap "Condition-route"
//匹配20.1.1.0/24 的条件路由//
set condition-type non-exist
//设置non-exsit 参数//
next
end
------------------------------------------------------------------------------------------------------------------------------------------
Fortinet 公司www.fortinet.com.cn
7
next
FW1 # get router info bgp neighbors 192.168.0.50 advertised-routes
//检测FW1 的adj-out 表发现,20.1.0.0/16 并没有通过到Router1//
BGP table version is 17, local router ID is 192.168.0.20
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 20.1.1.0/24 192.168.0.20 32768 ?
*> 30.1.1.0/24 192.168.0.20 32768 ?
*> 192.168.0.0 192.168.0.20 32768 ?
*> 200.1.1.0 192.168.0.20 32768 ?
FW1 # config router static
//当在FW1 上删除20.1.1.0/24 的路由时,20.1.0.0/16 汇总路由能正常通告//
FW1 (static) # delete 2
FW1 (static) # end
FW1 # get router info bgp network
BGP table version is 21, local router ID is 192.168.0.20
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 20.1.0.0/16 0.0.0.0 32768 ?
*> 30.1.1.0/24 0.0.0.0 32768 ?
*> 192.168.0.0 0.0.0.0 32768 ?
*> 200.1.1.0 0.0.0.0 32768 ?
Total number of prefixes 4
6. 测试2,exist 参数,当20.1.1.0/24 存在时,才会发布汇总路由20.1.1.0/16,
config router bgp
//测试exist 参数,exist 为缺省参数,因此,配置没有显示//
set as 1
set router-id 192.168.0.20
set log-neighbour-changes enable
config neighbor
edit "192.168.0.50"
set soft-reconfiguration enable
set remote-as 2
config conditional-advertise
edit "To_R1"
set condition-routemap "Condition-route"
next
------------------------------------------------------------------------------------------------------------------------------------------
Fortinet 公司www.fortinet.com.cn
8
end
next
FW1 # get router info bgp neighbors 192.168.0.50 advertised-routes
//从FW1 的adj-out 表可以看出,当20.1.1.0/24 时,20.1.0.0/16 的路由正常通//
BGP table version is 23, local router ID is 192.168.0.20
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 20.1.0.0/16 192.168.0.20 32768 ?
*> 20.1.1.0/24 192.168.0.20 32768 ?
*> 30.1.1.0/24 192.168.0.20 32768 ?
*> 192.168.0.0 192.168.0.20 32768 ?
*> 200.1.1.0 192.168.0.20 32768 ?
Total number of prefixes 5
FW1 # config router static //删除20.1.1.0/24 的路由//
FW1 (static) # delete 2
FW1 (static) # end
FW1 # get router info bgp neighbors 192.168.0.50 advertised-routes
//删除20.1.1.0/24 路由后,汇总路由也随之消失//
BGP table version is 24, local router ID is 192.168.0.20
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 30.1.1.0/24 192.168.0.20 32768 ?
*> 192.168.0.0 192.168.0.20 32768 ?
*> 200.1.1.0 192.168.0.20 32768 ?
Total number of prefixes 3

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Aggy阿吉

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值