加载中…
个人资料
Jackson
Jackson
  • 博客等级:
  • 博客积分:0
  • 博客访问:16,070
  • 关注人气:146
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

操纵BGP路径选择(含distribute-list)

(2005-10-18 11:41:46)
分类: ~~~ BGP ~~~
1、如果下一跳不可达,不考虑下一跳
 
2、优先选取有最大权重的路径   weight
 
3、如果多条路由有同样的权重,优先选取具有最高本地优先级的路径  local preference
 
4、如果多条路由有相同的本地优先级,优先选取具源自于本路由器上的BGP路由
 
5、如果没有路由是源,优先选取具有最短AS的路由
 
6、如果所有路径具有同样AS长度,优先选取最有最低源编码的路由(IGP<EGP<INCOMPLETE)
 
7、如果源编码相同,优先选取具有最低多出口区分的路由(MED)
 
8、如果MED相同,外部路径比内部路径优先选取。
 
9、如果MED都相同,优先选取通过最近IGP邻居的路径。
 
10、如果MED仍然相同,优先选取具有最低BGP路由器ID的路由。
 
操纵BGP路径选择(含distribute-list)
 
 
 
所有的路由器为BGP而配置。AS200中的IGP使用OSPF。A在AS100中,并作为AS200的路由器B和C的BGP邻居。路由器B和C对路由器D运行IBGP,D也在AS200中。
 
//// router a ////
 
int lo0
  ip addr 1.1.1.1 255.255.255.0
int lo1
  ip addr 2.2.2.2 255.255.255.0
 
int s0
  ip addr 192.1.1.1 255.255.255.0
 
int s1
  ip addr 193.1.1.1 255.255.255.0
 
router bgp 100
  neighbor 192.1.1.2 remote-as 200
  neighbor 193.1.1.2 remote-as 200
  netw 1.0.0.0
  netw 2.0.0.0
 
 
 
//// router b ////
 
int s0
  ip addr 192.1.1.2 255.255.255.0
 
int s1
  ip addr 194.1.1.2 255.255.255.0
 
router ospf 64
  passive-interface s0/0
  netw 194.1.1.0 0.0.0.255 area 0
  netw 192.1.1.0 0.0.0.255 area 0
 
router bgp 200
  no synchronization
  neighbor 192.1.1.1 remote-as 100
  neighbor 194.1.1.1 remote-as 200
  neighbor 195.1.1.2 remote-as 200
 
 
//// router c ////
 
int s0
  ip addr 193.1.1.2 255.255.255.0
 
int s1
  ip addr 195.1.1.2 255.255.255.0
 
router ospf 64
  passive-interface s0/0
  netw 195.1.1.0 0.0.0.255 area 0
  netw 193.1.1.0 0.0.0.255 area 0
 
router bgp 200
  no synchronization
  neighbor 193.1.1.1 remote-as 100
  neighbor 194.1.1.2 remote-as 200
  neighbor 195.1.1.1 remote-as 200
 
 
//// router d ////
 
int lo0
  ip addr 4.4.4.4 255.255.255.0
 
int s0
  ip addr 194.1.1.1 255.255.255.0
 
int s1
  ip addr 195.1.1.1 255.255.255.0
 
router ospf 64
  netw 194.1.1.0 0.0.0.255 area 0
  netw 195.1.1.0 0.0.0.255 area 0
  netw 4.4.4.0 0.0.0.255 area 0
 
router bgp 200
  no synchronization
  neighbor 194.1.1.2 remote-as 200
  neighbor 195.1.1.2 remote-as 200
 
 
 
 
//// 监视和测试配置 ////
 
本地优先级属性
 
这是分配给路由的一种优先级度量,以用于和到同一目的地的其他路由相比较。这一属性是在BGP路由处理中使用的第二优先的属性(CISCO私有的权重weight属性是第一优先的)。本地优先属性对AS是局部的,并不传送到EBGP路径上。本地优先级越高,路由优先级越高。
 
//// router c ////
access-list 1 permit 1.0.0.0 0.255.255.255
 
route-map localprefxxxx permit 10
  match ip address 1
  set local-preference 200
route-map localprefxxxx permit 20
  set local-preference 100
 
router bgp 200
  neighbor 193.1.1.1 route-map localprefxxxx in
 
clear ip bgp *
 
以上命令会改变C路由器的LOCAL PREF属性,AS200中的数据将选择C通往A而不是先前的B,之前选择B是因为B的IP地址192.1.1.2较之C的193.1.1.2要小。
 
 
 
 
多出口区分符属性
 
MED是一个路由的外部变量(metric)。与本地优先级属性不同,MED在自治系统间交换
但进入AS的MED不离开该AS。AS使用本地优先级属性来影响它自己的出站选择。MED是用来影响另一个AS的出站选择。MED越小,路由优先级越高。
 
路由器A将网络1.0.0.0的MED属性在通告给路由器C之前设置为50,在通告给路由器B后设为100。
 
操纵BGP路径选择(含distribute-list)
 
AS200中的路由器更会选择通过路由器C的路由,因为该路由有最低的MED。
为操作MED,我们需要通过使用访问表说明什么网各会被操作。我们也需要定义一个策略,这一策略通过一路由映射应用到这些路由上去,然后分配路由映射给BGP邻居。
 
/////////// router c////////////
 
router bgp 200
  no neighbor 193.1.1.1 route-map localprefxxxx in
 
access-list 1 permit 1.0.0.0 0.255.255.255
 
route-map set-med-50xxxx 10
  match ip address 1
  set metric 50
route-map set-med-50xxxx 20
  set metric
 
route-map set-med-100yyyy 10
  match ip address 1
  set metric 100
route-map set-med-100 20
  set metric
 
 
router bgp 100
  neighbor 193.1.1.2 route-map set-med-50xxxx out
  neighbor 192.1.1.2 route-map set-med-100yyyy out
 
clear ip bgp *
 

 
AS路径操作
 
BGP总是选择具有最短AS路径的路由,我们配置A,让它在通告1.0.0.0给C和B之前先增加两个额外的AS路径数到网络1.0.0.0(AS300和as400)。
 
为操作AS路径信息,我们需要通过使用access-list说明什么网络会被操作,也需要定义一个策略,这一策略通过route-map应用到这些路由上去,然后分配route-map给BGP邻居。
 
///// router a /////////
 
access-list 1 permit 1.0.0.0 0.255.255.255
 
route-map as-pathxxxx permit 10
  match ip address 1
  set as-path prepend 300 400
route-map as-pathxxxx permit 20
  set as-path prepend
 
router bgp 200
  neighbor 193.1.1.2 route-map as-pathxxxx out
  neighbor 192.1.1.2 route-map as-pathxxxx out
 
clear ip bgp *
 
 
 
 
基于网络号的路由过滤
 
路由器能够基于网络号过滤某个特定邻居的路由更新。由访问表组成的过滤器被应用到特定邻居的BGP更新上。
 
我们将分配一个access-list,以防止前缀1.0.0.0/8被通告入AS200中
 
为基于网络地址过滤路由,我们需要通过使用访问表来标识网络地址并用一个分配列表将其应用到BGP邻居上。
 
///////////// router a ///////////
 
no access-list 1
access-list 1 deny 1.0.0.0 0.255.255.255
access-list 1 permit any
 
router bgp 100
  neighbor 193.1.1.2 distribute-list 1 out
  neighbor 192.1.1.2 distribute-list 1 out
 
clear ip bgp *
 
 
 
 
BGP软配置
 
BGP软配置使得策略能够在不重设BGP和TCP会话的情况下被配置并生效。此特征使得新策略能在不显式影响网络时生效。如果没有BGP软配置,为使每次新变化生效,都要求重设邻居的TCP连接。此任务通过clear ip bgp 命令完成。
 
有两种类型的BGP软配置,外部重配置不重设BGP会话,使新的本地出站策略生效,内部软配置使新的内部策略生效。
 
内部软配置的问题是为在BGP会话不重设的条件下产生新的内部的更新,所有内部更新(不管接受的或拒绝的)都需要路由器来存储。这一处理是内存密集的,无论如何都应该被避免。
 
为避免内部软配置需要的内存开销,可以通过连接的另一端进行外部软配置来达到同样的交果。
 
外部软配置可用下面命令来触发:
claer ip bgp [*|address | peer-group] [soft out]
 
对内部软配置,需在软配置实行前加一条额外的路由器命令。原因是此命令告诉路由器开始存储接收的更新。
neighbor [address | peer-group] soft-reconfiguration inbound
 
内部软配置可用下面命令来触发:
clear ip bgp [ * |address | peer-group ] [soft in]
 
 
 

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有