EBGP管理距离20
IBGP管理距离200

一、建邻与宣告

BGP建邻与宣告分离
IBGP一般环回建邻,EBGP一般直连建邻
EBGP邻居关系存在多条路径时,也可以使用环回建邻,此时需要修改跳数(默认情况下跳数唯一)

R1(config)#router bgp 1
R1(config-router)#bgp router-id 1.1.1.1
R1(config-router)#neighbor 3.3.3.3 remote-as 2  
R1(config-router)#neighbor 3.3.3.3 update-source lo 0   
R1(config-router)#neighbor 3.3.3.3 ebgp-multihop //修改跳数为255

BGP的路由传递的是BGP路由表中的信息
查看BGP路由表
R1#show ip bgp
刷新路由表
R1#clear ip bgp * soft

宣告满足:1、被宣告路由必须在路由表中
2、被宣告路由必须和路由表中的前缀掩码一致
宣告必须为精确宣告,宣告的段必须与路由表一致(在路由表出现的路由让BGP传递出去
宣告完成,将生成BGP表:用于装载所有本地发出和接收到的条目
BGP的路由表在收到路由以后需要检查该路由是否可达,如果不可达该路由一定不优,不优了可以人为强制修改下一跳
R1(config-router)#neighbor 3.3.3.3 next-hop-self

建邻的一种简便配置

R1(config)#router bgp 1
R1(config-router)#bgp router-id 1.1.1.1
R1(config-router)#neighbor kkk peer-group  
R1(config-router)#neighbor kkk remote-as 1
R1(config-router)#neighbor kkk update-source lo 0  
R1(config-router)#neighbor 2.2.2.2 peer-group kkk
R1(config-router)#neighbor 3.3.3.3 peer-group kkk

二、属性

1、Weight
思科私有,选路属性,默认此属性不传递,本路由器为32768,学习到的为0,适用于一台路由器选择某条路径的参数,多条路径weight大的优选,无视邻居属性
修改方式:

R1(config)#router bgp 1
R1(config-router)#neighbor 2.2.2.2 weight 1//修改该邻居所有传递过来的路由weight为1

R1(config)#ip prefix-list a permit 2.2.2.2/24
R1(config)#route-map we permit 10            
R1(config-route-map)#match ip address prefix-list a
R1(config-route-map)#set weight 1
R1(config-route-map)#exi
R1(config)#route-map we permit 20
R1(config-route-map)#exi
R1(config)#router bgp 1
R1(config-router)#neighbor 2.2.2.2 route-map we in//只针对一个路由修改weight,只能用in方向

weight的值的修改只能影响本路由器,不能影响到其他路由器,意味着如果AS只有一个出口路由器weight选路是适用的,但是有多个出口路由器的情况下weight就不太适用
2、origin
起源属性,标识该路由的来源方式,0表示宣告,1表示EBGP学到,3表示其他手段学到(重发布?)
i>E>? 选路-----该属性可以选路,但一般不用于选路
修改方式:

R2(config)#ip prefix-list a seq 5 permit 3.3.3.3/32
R2(config)#route-map or permit 10
R2(config-route-map)#match ip address prefix-list a
R2(config-route-map)#set origin ?
  igp         local IGP
  incomplete  unknown heritage
R2(config-route-map)#set origin incomplete

3、AS-path
记录路由穿过了哪些AS(不算自己),顺序是最近进过的AS排前面,一个AS拒绝接收携带有自己AS号的路由,可用来防环,也可以用于选路—AS-path短的优先

R1(config)#ip prefix-list a permit 2.2.2.2/24
R1(config)#route-map ap permit 10            
R1(config-route-map)#match ip address prefix-list a
R1(config-route-map)#set as-path prepend  3 4 5
R1(config-route-map)#exi
R1(config)#route-map we permit 20
R1(config-route-map)#exi
R1(config)#router bgp 1
R1(config-router)#neighbor 2.2.2.2 route-map ap in

我们一般在选路当中添加AS会重复添加已经历的AS,一般不会添加没有经历的AS,适用于任何邻居之间,in和out方向都行

R2(config-router)#nei 3.3.3.3 allowas-in //允许和具有自己相同的AS的路由进入本AS,打破防环,本路由器使用
R2(config-router)#nei 3.3.3.3 as-override //把具有和其他AS相同AS号的路由放入这个AS,邻居路由器使用

4、next-hop
到达路由器的下一跳路由器IP地址,IBGP之间next-hop不变,为0的时候会修改为更新源地址,EBGP之间传路由next-hop需改为更新源地址
选路:下一跳为0的优于其他路径
修改方式:

R2(config)#ip prefix-list a permit 2.2.2.2/24
R2(config)#route-map nh permit 10            
R2(config-route-map)#match ip address prefix-list a
R2(config-route-map)#set ip next-hop 23.1.1.2   
R2(config-route-map)#exi
R2(config)#route-map we permit 20
R2(config-route-map)#exi
R2(config)#router bgp 1
R2(config-router)#neighbor 2.2.2.2 route-map nh in

5、local-pref
与weight一样也是选路属性,不能在EBGP邻居之间传递,可以在IBGP邻居之间传递(AS内),值越高越优(默认100),当本AS有多个出口路由器时,选择拥有local-pref值大的路由器作为出口路由器,也可以时到达一个网段有多个出口路径时,选择local-pref值大的出口路径
修改方式:

修改路由器的默认local-pref值,该路由器通过给IBGP邻居的路由都会携带修改后的local-pref值

R1(config)#router bgp 1
R1(config-router)#bgp default local-preference 120//修改路由器默认的local-pref值


通过route-map修改某路由的local-pref的值,EBGP只能在in方向,IBGP可以在in和out方向

R1(config)#ip prefix-list a permit 2.2.2.2/24
R1(config)#route-map k permit 10            
R1(config-route-map)#match ip address prefix-list a
R1(config-route-map)#set local-preference 120
R1(config-route-map)#exi
R1(config)#route-map we permit 20
R1(config-route-map)#exi
R1(config)#router bgp 1
R1(config-router)#neighbor 2.2.2.2 route-map k in

6、MED
本质就是metric,默认为0,一般只能用于自同一个AS发出路由的不同路径med值比较(用于选择流入AS的入口路由器)只能在两个AS之间传递,不能传给第三个AS
一般用于影响对方AS,如果在本AS使用和local-pref等同(注意med不能在路由器上修改默认值)
修改方式:

R1(config)#ip prefix-list a permit 2.2.2.2/24
R1(config)#route-map k permit 10            
R1(config-route-map)#match ip address prefix-list a
R1(config-route-map)#set metric 10
R1(config-route-map)#exi
R1(config)#route-map we permit 20
R1(config-route-map)#exi
R1(config)#router bgp 1
R1(config-router)#neighbor 2.2.2.2 route-map k in

in方向影响自己,out方向影响别人
*****可以修改使在第三个AS上传递

R1(config)#ip prefix-list a permit 2.2.2.2/24
R1(config)#route-map k permit 10            
R1(config-route-map)#match ip address prefix-list a
R1(config-route-map)#set metric 10
R1(config-route-map)#exi
R1(config)#route-map we permit 20
R1(config-route-map)#exi
R1(config)#router bgp 1
R1(config-router)#neighbor 2.2.2.2 route-map k in
R1(config-router)#bgp always-compare-med //开启不叫不同AS的MED

7、Atomic-aggregate
用来警告下游路由器路由聚合后产生的路由路径丢失
BGP支持向BGP邻居传递重叠路由可以选择多种方式
(1)明细和汇总都存在

R1(config)#router bgp 1
R1(config-router)#aggregate-address 10.0.0.0 255.0.0.0

(2)只存在明细

R1(config-router)#aggregate-address 10.0.0.0 255.0.0.0 suppress-map

(3)只公布汇总后的路由

R1(config-router)#aggregate-address 10.0.0.0 255.0.0.0 summary-only

(4)只公布继承明细的as-path

R1(config-router)#aggregate-address 10.0.0.0 255.0.0.0 summary-only as-set

一些其他配置

R1(config-router)#aggregate-address 10.0.0.0 255.0.0.0 summary-only ?
      advertise-map  通告某些属性(继承明细的属性)
      as-set         使属性消失
      attribute-map  添加明细没有的属性
      route-map      Set parameters of aggregate
      summary-only   从更新中过滤更具体的路径
      suppress-map   放出某些属性
      <cr>

8、aggregator
用来通告汇总后路由的汇聚路由器BGP-ID(Cisco),方便寻找汇总者
9、community
团体属性,为了更好的标识BGP路由,标识格式为X:Y(可读性好),团体值的设置不能在EBGP之间,他的传递可以在IBGP之间和EBGP之间
Standard标准(做路由标识),extended扩展(MPLS VPN)
(1)设置:

R1(config)#ip prefix-list p permit 3.3.3.3/32
R1(config)#route-map con permit 10
R1(config-route-map)#set community 111
R1(config-route-map)#exi
R1(config)#route-map con permit 20
R1(config-route-map)#exi
R1(config)#router bgp 1
R1(config-router)#neighbor 3.3.3.3 route-map con in

设置时必须在IBGP之间可以用in也可以用out
匹配设置:

R1(config)#ip bgp-community new-format /开展扩展格式匹配
R1(config)#ip community-list ?  //专用的community匹配工具
  <1-99>     Community list number (standard)
  <100-500>  Community list number (expanded)
  expanded   Add an expanded community-list entry
  standard   Add a standard community-list entry
  
R1(config)#ip community-list expanded k permit 111

匹配完成后用route-map调用即可

ibgp和ebgp ibgp和ebgp的管理距离分别是_ibgp和ebgp


传递设置:

传递团体属性依赖于识别

R1(config-router)#neighbor 1.1.1.1 send-community both //开启识别开关

(2)查看:

R1#show ip bgp 3.3.3.3//查看路由详情,可以看到团体值
R1#show ip bgp  community//该指令可以查看所有具有团体值的路由
R1#show ip bgp 11//查看某团体值的路由

(3)子属性

属性名

具体作用

no-export

只能在一个AS传送,可以在联盟内传送,限制携带团体值的路由传递给EBGP邻居,本联盟的EBGP除外

no-advertise

不在IBGP,EBGP邻居间传递,禁止传递给任何邻居

local-as

不向任何EBGP邻居发送(包括联盟的EBGP邻居 )

internet

默认属性,可以给任何BGP发送,不对携带团体值的路由做任何限制

10、originator-id
路由反射使用,是路由发起者产生的一个32比特的值,该值是本地路由发起者的RID,如果路由发起者从属性上看到自己的RID,说明有环路就忽略
11、cluster-list
路由反射器使用,是路由进过反射器簇ID的一个序号,如果反射器在属性里看到i自己的族簇就说明有环路忽略

10、11属性可解决下图成环的问题

ibgp和ebgp ibgp和ebgp的管理距离分别是_客户端_02

反射器

R2(config-router)#neighbor 1.1.1.1 route-reflector-client

在反射服务端上指定反射客户端,未指定的就是非客户端
反射器可以反射客户端之间,客户端与非客户端之间的路由,但是不能反射非客户端之间的路由
反射器减少了建邻情况的复杂,但同时打破了水平分割,所以需要属性来防环

缺点
反射器收到两个或两个以上达到同一目标路径事会判断出最优的路由然后反射给客户端和非客户端路由器,这样一来这些设备就丧失了多条路径判断最优的权利