BGP & Route Maps

router map BGP一起使用时可控制路由信息,并可定义路由再分配的条件: route-map map-tag [[permit|deny]|[sequence-number]], map-tagroute-map的标识号,sequence-number是每一个route map 条件的标识号。


BGP 使用 route-map 时,从最小的 sequence-number 开始对应。
Match
用于定义一些必须符合的条件, set 是定义当符合 match 中的条件时所采取的一些动作。如:
route-map mymap permit 10
match ip address 1.1.1.1
set metric 5
例: route A route B RIP route A route C BGP Route A 对从 170.10.0.0 来的路由设 metric 2, 其他为 5:
!router A
router rip
network 3.0.0.0
network 2.0.0.0
network 150.10.0.0
passive-interface serial 0
redistribute bgp 100 route-map setmetric
!
router bgp 100
neighbor 2.2.2.3 remote-as 300
network 150.10.0.0
!
route-map setmetric permit 10
match ip-address 1
set metric 2
!
route-map setmetric permit 20
set metric 5
!
access-list 1 permit 170.10.0.0 0.0.255.255
若在 router C 上对 170.10.0.0 outgoing 包设 community attribute 300:
!router C
router bgp 300
network 170.10.0.0
neighbor 2.2.2.2 remote-as 100
neighbor 2.2.2.2 route-map setcommunity out
!
route-map setcommunity permit 10
match ip address 1
set community 300
!
access-list 1 permit 0.0.0.0 255.255.255.255
Advertising Networks
BGP
通过三种方法对外广播其 AS 内的路由信息 : 重分配静态路由、重分配动态路由、用 network 命令。
redistributing static routes
!router c
router bgp 200
neighbor 1.1.1.1 remote-as 300
redistribute static
!
ip route 175.220.0.0 0.0.255.255 null 0
redistribute dynamic routes
有些 IGP 路由是通过 BGP 学到的,因此需用 access list 阻止这些路由被再分配回 BGP router c
router eigrp 10
network 175.220.0.0
redistribute bgp 200
redistributed connected
default-metric 1000 100 250 100 1500
!
router bgp 200
neighbor 1.1.1.1 remote-as 300
neighbor 2.2.2.2 remote-as 200
neighbor 1.1.1.1 distribute-list 1 out
redistribute eigrp 10
!
access-list 1 permit 175.220.0.0 0.0.255.255
通常应避免将 BGP 再分配入 IGP ,因为这样会导致太多的路由注入 AS 中。
use the network command
BGP 中使用 network 命令定义 AS 的起始处,而在 IGP 中, network 命令则指定起 IGP 的端口。 router c
router bgp 200
neighbor 1.1.1.1 remote-as 300
network 175.220.0.0