89ou 发表于 2012-11-16 08:57:49

BGP基本属性配置总结

本帖最后由 89ou 于 2012-11-16 08:58 编辑

BGP基本属性配置总结
1、本地优先级(local-preference)
默认值100,较高值的路径会被优先选择。
作用:决定离开本自制系统的最佳路径。
配置方法一:
R4(config)#router bgp 64513
R4(config-router)#bgp default local-preference 200
这样,R4的BGP邻居从R4学习到的路由的本地优先级均为200
缺点是针对性差。要针对某条路由进行配置的话可使用route-map的方法。
配置方法二:
R4(config)#access-list 1 permit 130.130.1.0 0.0.0.255
R4(config)#
R4(config)#route-map set_lp permit 10
R4(config-route-map)#match ip address 1
R4(config-route-map)#set local-preference 200
R4(config-route-map)#exit
R4(config)#
R4(config)#route-map set_lp permit 20
R4(config-route-map)#exit
R4(config)#
R4(config)#router bgp 64513
R4(config-router)#neighbor 192.168.2.2 route-map set_lp in

2、MED(Multi-Exit Discriminator)
默认值0,较低值的路径将被优先选择。
作用:影响其他自制系统的数据流如何进入本地自制系统。
配置:
R2(config)#access-list 1 permit 130.130.1.0 0.0.0.255
R2(config)#
R2(config)#route-map set_med permit 10
R2(config-route-map)#match ip address 1
R2(config-route-map)#set metric 100
R2(config-route-map)#exit
R2(config)#
R2(config)#route-map set_med permit 20
R2(config-route-map)#exit
R2(config)#
R2(config)#router bgp 64512
R2(config-router)#neighbor 192.168.1.2 route-map set_med out
R2(config-router)#exit

3、权重(weight)
当本地出口路由器有多条外出自制系统的链路时,权重可决定从哪里出去。
cisco私有属性。本地路由默认值32768,其他默认值0。
配置方法一:
R1(config)#router bgp 64512
R1(config-router)#neighbor 192.168.4.1 weight 100
R1(config-router)#neighbor 192.168.1.2 weight 50
这样就将邻居4.1发过来的路由的权重设置为100,邻居1.2发过来的路由权重设置为50。
配置方法二:
R1(config)#access-list 1 permit 150.150.1.0 0.0.0.255
R1(config)#
R1(config)#route-map set_weight permit 10
R1(config-route-map)#match ip address 1
R1(config-route-map)#set weight 100
R1(config-route-map)#exit
R1(config)#
R1(config)#route-map set_weight permit 20
R1(config-route-map)#exit
R1(config)#
R1(config)#router bgp 64512
R1(config-router)#neighbor 192.168.4.1 route-map set_weight in
R1(config-router)#exit

4、AS-PATH
(1)路径欺骗(path prepend)
配置:
R3(config)#access-list 1 permit 150.150.1.0 0.0.0.255
R3(config)#
R3(config)#route-map set_prepend permit 10
R3(config-route-map)#match ip address 1
R3(config-route-map)#set as-path prepend 64514 64514
添加在尾部的AS最好是本地自治系统号,否则可能会产生无效路由。
R3(config-route-map)#exit
R3(config)#
R3(config)#route-map set_prepend permit 20
R3(config-route-map)#exit
R3(config)#
R3(config)#router bgp 64514
R3(config-router)#neighbor 192.168.2.1 route-map set_prepend out

(2)利用tap存储路径信息(Using Route Tag to Store BGP AS-Path)。
解决BGP与IGP在做路由重发布时,BGP AS-PATH属性丢失的问题。
由于路由标记tag可以被所有的路由协议识别,因此,可以在重发布前将BGP的AS-PATH转存到路由标记中,然后在R4路由器上再把路由标识中存储的AS-PATH取出来还原到BGP的路由中。
配置(R2、R3为重发布点):
R2(config)#route-map SET_TAG permit 10
R2(config-route-map)#set automatic-tag
先在重发布点设置自动计算路由标记
R2(config-route-map)#exit
R2(config)#
R2(config)#router bgp 64513
R2(config-router)#table-map SET_TAG
配置将BGP的扩展属性,映射到路由表中。其主要目的是通过SET_TAG的路由图的过滤,将AS-PATH将属性存储到标记中。

R3(config)#route-map GET_TAG permit 10
R3(config-route-map)#set as-path tag
将AS-PATH属性从路由标记中取出,并还原到BGP的路由数据库中。
R3(config-route-map)#exit
R3(config)#router bgp 64513
R3(config-router)#redistribute ospf 1match external internal route-map GET_TAG
在路由重发布时,完成AS-PATH的转存工作。

5、源属性(origin)
重发布也会导致起源信息不完整,即标记为?(incomplete)。
R3(config)#route-map SET_ORIGIN permit 10
R3(config-route-map)#set origin igp
R3(config-route-map)#exit
R3(config)#
R3(config)#router bgp 64513
R3(config-router)#neighbor 192.168.2.2 route-map SET_ORIGIN out
R3(config-router)#exit

wfkjxy 发表于 2013-3-18 10:59:34

谢谢楼主,共同发展

云深处 发表于 2013-5-16 21:07:17

走,MM,咱们化蝶去……

jason0401 发表于 2013-5-19 07:39:05

我喜欢孩子,更喜欢造孩子的过程!

坏气十足 发表于 2013-5-22 09:12:39

沙发!沙发!

zhangbinmy 发表于 2013-5-26 04:47:02

我喜欢孩子,更喜欢造孩子的过程!

q66262 发表于 2013-5-30 23:02:31

路边的野花不要,踩。
页: [1]
查看完整版本: BGP基本属性配置总结