BGP路由属性和选路原则以及应用

属性的特点
1、weight:cisco私有属性,单纯的用于选路,本路由产生的值为32768,只限于本路由器不能传递
使用的情况:一台路由器有多个出口时使用
修改的方式:
修改邻居传递过来所有路由的weight值
Router(config)#router bgp 1
Router(config-router)#neighbor 2.2.2.2 weight 1
针对某一条路由传递过来的weight值进行修改(只能在in方向上修改)
Router(config)#ip prefix-list a permit 4.4.4.4/32
Router(config)#route-map a permit 10
Router(config-route-map)#match ip address prefix-list a
Router(config-route-map)#set weight 1
Router(config)#route-map a permit 20
Router(config)#router bgp 1
Router(config-router)#neighbor 24.1.1.2 route-map a in
2、origin标识该路由时则么学到的-----0表示宣告(i),1表示EGP学到(E),3表示其他手段得到(重发布),i>E>?
使用的情况:可以进行选路,但是一般不使用
修改的方式:
Router(config)#ip prefix-list or permit 4.4.4.4/32
Router(config)#route-map or permit 10
Router(config-route-map)#match ip address prefix-list or
Router(config-route-map)#set origin incomplete
Router(config)#route-map or permit 20
Router(config)#router bgp 1
Router(config-router)#neighbor 24.1.1.2 route-map or in
3、AS path:就是记录路由经过哪些as,在EBGP间可以用来防环,也可以用来选路,一般优先选择记录的越短越好;as的顺序是经过最近的as排在前面,建议修改时,最好是添加已经经过的as,防止下次遇到真实的as号进不去;
使用的环境:若是去a要走R2,你可在R3上多加经过的几个as
在这里插入图片描述
修改的方法:
Router(config)#ip prefix-list as permit 4.4.4.4/32
Router(config)#route-map as permit 10
Router(config-route-map)#match ip address prefix-list as
Router(config-route-map)#set as-path prepend 200 100
Router(config)#route-map as permit 20
Router(config)#router bgp 1
Router(config-router)#neighbor 24.1.1.2 route-map as in(在in和out方向都可以)
4、next hop:到达路由的下一跳路由器的ip地址,IBGP之间传递下一跳不变,EBGP之间传递路由修改下一跳为更新源地址,下一跳为0的路由最优;
修改方法:
Router(config)#ip prefix-list n permit 4.4.4.4/32
Router(config)#route-map n permit 10
Router(config-route-map)#match ip address prefix-list n
Router(config-route-map)#set ip next-hop 3.3.3.3
Router(config)#route-map n permit 20
Router(config)#router bgp 1
Router(config-router)#neighbor 2.2.2.2 route-map n in
5、local pref:一般用于选路,不能在EBGP之间传递,只能在IBGP之内传递(在IBGP内传递并且携带本地优先级),默认值为100,值越高越优;
使用的情况:一般一个路由器连接一个EBGP邻居还连接一个IBGP邻居时,优先选择EBGP,你可以通过修改本地优先级,将优先选择IBGP邻居
在这里插入图片描述
修改方法:
全局修改:修改从本路由传出的所有路由
Router(config)#router bgp 1
Router(config-router)#bgp default local-preference 150
精确修改:
Router(config)#ip prefix-list lp permit 4.4.4.4/32
Router(config)#route-map lp permit 10
Router(config-route-map)#match ip address prefix-list lp
Router(config-route-map)#set local-preference 150
Router(config)#route-map lp permit 20
Router(config)#router bgp 1
Router(config-router)#neighbor 24.1.1.2 route-map lp in (在EBGP邻居之间修改只能在in方向上做,在IBGP邻居之间都可以)
6、MED:metric一般用于选路,只能在两个as之间传递,不能传给第三个as;
使用情况:一般用于流入as的入口路由器,和本地优先级的区别是本地优先级只能影响as内的,对于其他as传递过来的不好影响,只能修改metric来影响别人传递过来的路由,这样做的好处就是,管理员不用亲自去别人设备上修改选路了;
在这里插入图片描述
Router(config)#ip prefix-list med permit 4.4.4.4/32
Router(config)#route-map med permit 10
Router(config-route-map)#match ip address prefix-list med
Router(config-route-map)#set metric 40
Router(config)#route-map med permit 20
Router(config-router)#neighbor 34.1.1.2 route-map med in
7、atomic aggregate标识汇总路由,可以告诉汇总后的下一个路由器是汇总路由,一般情况下,如果做了汇总,就会把明细路由携带的属性给丢掉,产生新的汇总路由,在这种情况下,可以使用一些命令,将汇总后的路由携带一些属性
比如:as-set命令会使得通告后AS-PATH携带as号
8、aggregator cisco是私有 作用:就是通告是哪台路由器做的汇总,方便找到;

9、community:为了更好的识别BGP路由,扩展标识格式x:y,想要识别X:Y格式就必须开启格式扩展匹配(IBGP和EBGP都可实现)
Router(config)#ip bgp-community new-format
子属性
internet默认属性,可以给任何bgp发送
no_export只能在as内传递,可以在联盟内传递
no_advertise不在IBGP邻居之间传递
local-as不向任何EBGP邻居发送包括联盟的EBGP邻居
修改方法:
Router(config)#ip prefix-list c permit 4.4.4.4/32
Router(config)#route-map c permit 10
Router(config-route-map)#match ip address prefix-list c
Router(config-route-map)#set community 100:100
Router(config)#route-map c permit 20
Router(config)#router bgp 1
Router(config-router)#neighbor 24.1.1.2 route-map c in (in和out都可以)
Router(config)#ip bgp-community new-format
Router#show ip bgp 4.4.4.4//查看具体的
Community: 100:100
Router#show ip bgp community//查看所有具有团体值的路由

10、originator_id:起源者ID,一般在路由反射器的时候使用,用来防环
一般在这种情况下使用:一般非客户端将路由a传递给RR,RR又将路由传递给另一个RR,另一个RR又将a路由传递非客户端,此时originator_id就会记录经过的路由器,看到一样的就不会在传回去;
在这里插入图片描述
11、Cluster_list簇id,也是用于防环
使用的情况
在这里插入图片描述
反射器
作用:中转站
规则:非客户端之间不能反射
反射器的缺点:反射器收到两个或两个以上到达同一个目标路径时,会判断出最优的路由然后反射给客户端与非客户端的路由器,这样一来这些设备丧失了多条路径判断最优的权力;
Router(config-router)#neighbor 3.3.3.3 route-reflector-client //在反射服务端上指定反射客户端,未指定的就是非客户端

联盟:把一个大的as拆分为若干个小的私有as;联盟的as必须带,进入联盟内部的as带有大阔号,出去丢弃
只要有ebgp邻居关系都需申明大as号,对内需要申明as
优点:减少建邻数量方便管理和ospf化区域
有EBGP关系的情况下必须声明大as号,有联盟间的ebgp关系必须声明对方的as号;
Router(config)#router bgp 64513
Router(config-router)#bgp confederation identifier 1//大as号
Router(config-router)#bgp confederation peers 64512

选路原则
选路的前提是路由必须是优的
BGP路由表不优的情况
1、BGP路由表中路由的下一跳不可达(递归失败)
2、如果开启了bgp同步,在没有同步的情况下bgp的路由不由(同步默认关闭,检查bgp路由在不在IGP里边,同步时将bgp重发布进入igp,避免黑洞)
R标记的路由,标识在路由表中不优
选路顺序
1、weight
2、local preference
3、next hop
4、as path
5、origin
6、med
7、EBGP>IBGP
8、最近的IGP邻居
9、EBGP之间建邻的时间,时间越久越稳定
10、比较邻居的router-id,在建邻时间相等情况下才比较第10个
在这里插入图片描述
11、比较建邻的地址大小,越小越优
在这里插入图片描述
Bgp默认负载均衡条目数是1,也就意味着默认它没有负载均衡,可以修改max-path参数来改变负载均衡条目,一旦大于1,那么选路原则只会工作到第8条

过滤
Bgp路由传递的流程:bgp路由表----发送策略----发送路由表----接收路由表—接受策略—接收路由表—bgp路由表
1、 针对邻居的前缀列表
Router(config-router)#neighbor 3.3.3.3 prefix-list a ?
in Filter incoming updates
out Filter outgoing updates
2、 全局的分发列表
Router(config-router)#distribute-list ?
<1-199> IP access list number
<1300-2699> IP expanded access list number
WORD Access-list name
gateway Filtering incoming updates based on gateway
prefix Filter prefixes in routing updates
3、重发布
默认路由
1、 针对单个邻居的默认路由
Router(config-router)#neighbor 2.2.2.2 default-originate
2、针对所有邻居的默认路由(全局)
全局路由表必须有默认路由
Router(config)#ip route 0.0.0.0 0.0.0.0 null 0
Router(config)#router bgp 1
Router(config-router)#network 0.0.0.0 mask 0.0.0.0
Router(config-router)#default-information originate

浮动惩罚:当一条路由出现后又消失,经过一次惩罚值加1000,当达到上限时,就会一致该路由的发送,经过15min惩罚值就会减半,知道小于下限罚值,才能转发
作用:强化路由的稳定性
下限罚值:750
每次惩罚值:1000
上限罚值2000 大于2000就会抑制
最大值12000
最长惩罚时间60min
半衰期15min 5s清算一次

路由后门路由
R1(config)#routerbgp1
R1(config-router)#network2.2.2.0mask255.255.255.0backdoor
Network对端建立邻居关系的地址, 使通过bgp学习到其他路由的AD为200就不会挤掉IGP 学习的路由,这条路由不会加表(AD 值小)但会传递,这样就不会出现邻居翻滚
EBGP邻居间非直连建邻(假如说使用环回),使用动态路由协议产生到达对放建立邻居关 系的地址路由(到达环回的路由),建立后使用 network 宣告到 BGP中,则其 BGP 产生的 路由 AD 值为 20(EBGP 关系)这样会覆盖 IGP 学习到的路由表,然后 IGP 路由没有到达对 方建立邻居关系地址的路由(到达环回的路由)则邻居关系会 down 掉,然后通过 BGP 学 习的路由在路由表消失,则通过 IGP 学习的路由又会加表,这样会出现邻居翻滚的现象

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值