BGP & Route Maps
router map 与BGP一起使用时可控制路由信息,并可定义路由再分配的条件: route-map map-tag [[permit|deny]|[sequence-number]], map-tag是route-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