华为 BGP原理概述以及实验基础配置命令

华为 BGP原理概述以及实验基础配置命令

一、拓扑
在这里插入图片描述
[AR-6]bgp 100 //本设备创建BGP AS,所属AS 100

IBGP邻居关系

[AR-6-bgp]router-id 6.6.6.6 //设置本设备的BGP的R-ID为6.6.6.6
[AR-6-bgp]peer 67.1.1.7 as-number 100 //手动指定与对等体的接口地址67.1.1.7建立IBGP邻居

EBGP邻居关系

[AR-8]bgp 200
[AR-8-bgp]router-id 8.8.8.8
[AR-8-bgp]peer 78.1.1.7 as-number 100 //手动指定与对等体的接口地址78.1.1.7建立EBGP邻居

到达对方Loopback 0接口的静态路由

[AR-6]ip route-static 7.7.7.7 32 67.1.1.7

基础基于单一密钥的BGP认证功能

[AR-6-bgp]peer 67.1.1.7 password cipher Huawei //与邻居67.1.1.7 建立认证密钥

[AR-6-bgp]undo peer 67.1.1.7 password //执行删除动作

配置基于 keychain的BGP认证

[AR-6]keychain key mode periodic daily //生效时间模式为周期形式生效
[AR-6-keychain]key-id 1 //创建一个新的key-id 1
[AR-6-keychain-keyid-1]algorithm md5 //配置key采用的认证算法为md5
[AR-6-keychain-keyid-1]key-string huawei //key的密钥huawei
[AR-6-keychain-keyid-1]send-time daily 08:00 to 20:00 //key的发送时间每天8:00 to 20:00
[AR-6-keychain-keyid-1]receive-time daily 08:00 to 20:00 //key的接收时间每天 08:00 to 20:00
[AR-6-keychain-keyid-1]bgp 100
[AR-6-bgp]peer 67.1.1.7 keychain key

接收容忍时间

[AR-6-keychain]receive-tolerance infinite

BGP自动路由聚合

[AR-6-bgp]ipv4-family unicast //建立普通的BGP对等体关系
[AR-6-bgp-af-ipv4]summary automatic //开启自动路由聚合功能
[AR-6-bgp-af-ipv4]network 6.6.6.6 32 //将AR-6的loopback 0 接口所在网段宣告进入bgp进程
[AR-6-bgp-af-ipv4]import-route direct //引入自连的路由

BGP手动路由聚合

手动路由聚合具有更高的灵活性和可控性;使用aggregate命令进行聚合

[AR-6-bgp]aggregate 67.1.1.0 24 //发布所有聚合路由和被聚合的路由

[AR-6]ip ip-prefix no-adver permit 7.7.7.7 32 //指定地址前缀列表名为no-adver,配置模式为允许模式
[AR-6]route-policy no-adver permit node 10
Info: New Sequence of this List.
[AR-6-route-policy]if-match ip-prefix no-adver //匹配IPv4的路由信息
[AR-6-route-policy]apply community no-advertise //调整的策略为不公告给邻居
[AR-6-route-policy]route-policy no-adver permit node 20
Info: New Sequence of this List.
[AR-6-route-policy]bgp 100
[AR-6-bgp]peer 67.1.1.7 route-policy no-adver export //针对邻居来应用route-policy,而不是network时调用
[AR-6-bgp]peer 67.1.1.7 advertise-community //团体属性传递给邻居67.1.1.7对等体

[AR-6-bgp]aggregate 67.1.1.0 24 detail-suppressed //实现对明细路由的抑制,只将集合后的路由发送出去

[AR-6-bgp]aggregate 67.1.1.0 21 suppress-policy no-adver
//控制路由聚合 只发布聚合路由和通过router-policy被聚合的子路由

[AR-6-bgp]aggregate 67.1.1.0 21 ?
as-set Generate the route with AS-SET path-attribute
//创建拥有AS-SET属性的聚合路由,用于环路检测
attribute-policy Set aggregation attributes
//通过route-policy指定聚合路由的属性,后面是router-policy的编号
detail-suppressed Filter more detail route from updates
//实现对明细路由的抑制,只将集合后的路由发送出去
origin-policy Filter the originate routes of the aggregate
//只将router-policy中指定路由策略的路由进行聚合,后面是router-policy的编号
suppress-policy Filter more detail route from updates through a Routing policy
//只发布聚合路由和通过router-policy策略被聚合的子路由
Please press ENTER to execute command

BGP路径选择-Preferred Value

路由信息的首选值Preferred Value的取值范围是0~65535,取值越大,优先级越高。
缺省情况下,Preferred Value取值为0。

修改referred Value

[AR-6]ip ip-prefix 1 index 10 permit 7.7.7.7 32 // …指定本匹配项在地址前缀列表中的序号为10
[AR-6]route-policy 1 permit node 10
Info: New Sequence of this List.
[AR-6-route-policy]if-match ip-prefix 1
[AR-6-route-policy]apply preferred-value 100 //路由策略中配置改变BGP路由的首选值为100
[AR-6-route-policy]quit
[AR-6]bgp 100
[AR-6-bgp]peer 7.7.7.7 route-policy 1 import //调用路由策略

BGP路径选择-Local Pregerence

如果Preferred Value相同,就会比较本地优先级Local Pregerence属性。
Local Pregerence只在IBGP对等体之间进行通告,EBGP对等体之间传递路由时,不携带Local Pregerence属性。

[AR-6-route-policy]apply local-preference 500 //在路由策略中配置改变BGP路由信息的本地优先级为500

BGP路径选择-Next Hop

Next Hop属性对BGP路由协议选路的影响;通信双方的往返选用不同路径的现象称为不对称路由。

[AR-6-GigabitEthernet0/0/0]ospf cost 200 //修改接口g0/0/0d 开销值为200;越小越优先

BGP路径选择-AS_Path

当一台BGP路由器中存在多条去往同一目标网络的BGP路由时,BGP协议会对这些BGP路由的属性进比较,以确定去往该目标网络的最优BGP路由。首先要比较的是属性是Preferred Value,然后是Local preference ,再次是路由生成方式,如果在比较了这几个属性之后还是无法确定出最优路由,则将进行AS_Path属性的比较。BGP在比较了AS_Path属性之后,会优先选AS_Path长度最短的那条路有。

[AR-6]ip ip-prefix as_path permit 7.7.7.7 32
[AR-6]route-policy as_path permit node 10
[AR-6-route-policy]if-match ip-prefix as_path //匹配前缀列表名称as_path扑捉理由
[AR-6-route-policy]apply as-path 500 500 additive //在原有的路径前面添加as号
[AR-6-route-policy]route-policy as_path permit node 20 //创建名称为as_path,执行允许动作,节点为20
[AR-6-route-policy]bgp 100
[AR-6-bgp]peer 67.1.1.7 route-policy as_path import //调用路由策略

[AR-6-route-policy]apply as-path 300 400 500 100 overwrite
//意味着将用300 400 500 100 覆盖路由信息原有的AS_Path属性
在这里插入图片描述

BGP路径选择-MED

当一台BGP路由器中存在多条去往同一目标网络的BGP路由时,BGP协议会对这些BGP路由的属性进比较,以确定去往该目标网络的最优BGP路由。BGP路由属性的比较顺序为,Preferred Value 属性,Loacl preference属性,路由生成方式,AS_Path属性,Origin属性,MED属性,BGP对等体类型等。

EMD的数值越小,表明相应的路由优先级越高,因此MED也常被称为Cost。

[AR-8]ip ip-prefix 1 permit 7.7.7.0 24
[AR-8-route-policy]if-match ip-prefix 1
[AR-8-route-policy]apply cost 100 //MED配置为1000
[AR-8-bgp]peer 78.1.1.7 route-policy 1 export //在传递路由给AR-7调用route-policy

[AR-8-bgp]compare-different-as-med //让AR-8强制比较来自不同AS且去玩同一目标网络的路由的MED属性值

二、拓扑
在这里插入图片描述

BGP路径选择-Community

BGP路由的团体属性Community主要作用是简化路由策略的实现过程。

FRC1997中定义了几个特殊的团体,也被称为Well-known团体,它们是Internet、No-Export、No-Advertise、No-Export-Subconfed。路由器接收到属于这些团体的路由时,将会之间执行相应的动作。

Internet团体属性没有一个特定的值,所有路由都默认为属于该团体,路由器可以向任何BGP对等体发布所收到的属于Internet团体的路由。

No-Export团体属性的值为4294967041,路由器接收到一条携带No-Export团体属性的路由后,不会将它发布给EBGP对等体,但可以发布给联盟EBGP对等体。

No-Advertise团体属性的值为4294967042,路由器接收到一条携带No-Advertise团体属性的路由后,不会将它发布给任何对等体。

No-Export-Subconfed团体属性的值为4294967043,路由器接收到一条携带No-Export-Subconfed团体属性的路由后,不会将它发布给EBGP对等体,也不会将它发布给联盟EBGP对等体。

[AR-9]bgp 3002
[AR-9-bgp]router-id 9.9.9.9
[AR-9-bgp]confederation id 300 //联盟AS 300的成员AS 3002
[AR-9-bgp]peer 79.1.1.7 as-number 3003
[AR-9-bgp]peer 79.1.1.7 next-hop-local

[AR-6]bgp 100
[AR-6-bgp]peer 67.1.1.7 route-policy 1 export //AR-6上调用route-policy

No_Export团体属性控制路由信息传递

[AR-6]ip ip-prefix 10 permit 67.1.1.7 32
[AR-6]route-policy 1 permit node 10
[AR-6-route-policy]if-match ip-prefix 1
[AR-6-route-policy]apply community no-export //收到具有此属性的路由后,不能发布到本地AS之外
[AR-6-route-policy]route-policy 15 permit node 20

[AR-6-bgp]peer 67.1.1.7 advertise-community //AR-6在向AR-7传递BGP路由信息时携带团体属性

no-export-subconfed团体属性控制路由信息传递

[AR-6]ip ip-prefix 1 permit 7.7.7.7 32
[AR-6]route-policy 1 permit node 10
[AR-6-route-policy]if-match ip-prefix 1
[AR-6-route-policy]apply community no-export-subconfed*//收到具有此属性的路由后,不能发布给任何其他的子自治系统*

No-Advertise团体属性控制路由信息传递

[AR-6-route-policy]apply community no-advertise //收到具有此属性的路由后,不能发布给任何其他的BGP对等体

自定义团体属性控制路由信息传递

[AR-6-route-policy]apply community 100:9 //前两个字节是AA为AS号,后两个是NN为团体编号

[AR-6]ip community-filter 1 permit 100:9
[AR-6]route-policy 1 deny node 10
[AR-6-route-policy]if-match community-filter 1
[AR-6-route-policy]route-policy 1 permit node 20

BGP路由反射器
下回总结…

发布了29 篇原创文章 · 获赞 72 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/HYD696/article/details/105330228