BGP的基本配置:
拓扑见QQ收藏
R1配置:
[R1]bgp 1000
[R1-bgp]router-id 1.1.1.1
[R1-bgp]peer 4.4.4.4 as-number 1000
[R1-bgp]peer 4.4.4.4 connect-interface LoopBack 0 修改更新源地址
[R1-bgp]peer 13.1.1.3 as-number 2000
[R1-bgp]address-family ipv4
[R1-bgp-ipv4]peer 4.4.4.4 enable 激活邻居,不管是IBGP还是EBGP都需要激活
[R1-bgp-ipv4]peer 4.4.4.4 next-hop-local next-hop-self
[R1-bgp-ipv4]peer 13.1.1.3 enable
R2配置:
[R2]bgp 1000
[R2-bgp]router-id 2.2.2.2
[R2-bgp]peer 23.1.1.3 as-number 2000
[R2-bgp]peer 4.4.4.4 as-number 1000
[R2-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[R2-bgp]address-family ipv4
[R2-bgp-ipv4]peer 4.4.4.4 enable
[R2-bgp-ipv4]peer 4.4.4.4 next-hop-local
[R2-bgp-ipv4]peer 23.1.1.3 enable
R3配置:
[R3]bgp 2000
[R3-bgp]router-id 3.3.3.3
[R3-bgp]peer 13.1.1.1 as-number 1000
[R3-bgp]peer 23.1.1.2 as-number 1000
[R3-bgp]address-family ipv4
[R3-bgp-ipv4]peer 13.1.1.1 enable
[R3-bgp-ipv4]peer 23.1.1.2 enable
[R3-bgp-ipv4]network 3.3.3.3 32
R4配置:
[R4]bgp 1000
[R4-bgp]peer 1.1.1.1 as-number 1000
[R4-bgp]peer 1.1.1.1 connect-interface LoopBack 0
[R4-bgp]peer 2.2.2.2 as-number 1000
[R4-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[R4-bgp]address-family ipv4
[R4-bgp-ipv4]network 4.4.4.4 32
[R4-bgp-ipv4]peer 2.2.2.2 enable
[R4-bgp-ipv4]peer 1.1.1.1 enable
查看BGP邻居的命令:
<R1>dis bgp peer ipv4
查看BGP路由表的命令:
<R1>dis bgp routing-table ipv4
指定源和目的ping: ping -a 4.4.4.4 3.3.3.3 4.4.4.4为源,3.3.3.3为目的
BGP的负载均衡:
[R4]bgp 1000
[R4-bgp]address-family ipv4
[R4-bgp-ipv4]balance 2 可以负载两条路由
BGP路由的聚合:
[R2]bgp 1000
[R2-bgp]address-family ipv4
[R2-bgp-ipv4]aggregate 172.16.10.0 24 detail-suppressed (抑制明细路由)
BGP路由属性:
本地优先级:(只在本地AS内有意义)越大越好,默认为100
[R1]acl basic 2000
[R1-acl-ipv4-basic-2000]rule permit source 3.3.3.3 0
[R1]route-policy 1 permit node 1
[R1-route-policy-1-1]if-match ip address acl 2000
[R1-route-policy-1-1]apply local-preference 200 修改本地优先级为200
[R1-route-policy-1-1]quit
[R1]route-policy 1 permit node 2 route-map的空语句放行
[R1-route-policy-1-2]quit
[R1]bgp 1000
[R1-bgp]address-family ipv4
[R1-bgp-ipv4]peer 4.4.4.4 route-policy 1 export 出接口修改
注意:
[R1]bgp 1
[R1-bgp]address-family ipv4
[R1-bgp-ipv4]default local-preference 110 (这条命令会修改所有的路由条目优先级)
MED:(在直连邻居的一跳AS内传递)越小越好,默认为0
[R3]acl basic 2000
[R3-acl-ipv4-basic-2000]rule permit source 3.3.3.3 0
[R3-acl-ipv4-basic-2000]quit
[R3]route-policy 1 permit node 1
[R3-route-policy-1-1]if-match ip address acl 2000
[R3-route-policy-1-1]apply cost 50
[R3-route-policy-1-1]quit
[R3]route-policy 1 permit node 2 空语句放行
[R3-route-policy-1-2]quit
[R3]route-policy 2 permit node 1
[R3-route-policy-2-1]if-match ip address acl 2000
[R3-route-policy-2-1]apply cost 100
[R3-route-policy-2-1]quit
[R3]route-policy 2 permit node 2 空语句放行
[R3-route-policy-2-2]quit
[R3]bgp 2000
[R3-bgp]address-family ipv4
[R3-bgp-ipv4]peer 13.1.1.1 route-policy 1 export
[R3-bgp-ipv4]peer 23.1.1.2 route-policy 2 export 出接口调用
BGP认证:
[R4]bgp 1000
[R4-bgp]peer 1.1.1.1 password simple 123 两端都要配置
路由反射器:
拓扑见QQ收藏:(删除了R2和R3的BGP邻居,其余配置和 上面一样)
[R4]bgp 1000
[R4-bgp]address-family ipv4
[R4-bgp-ipv4]peer 1.1.1.1 reflect-client
[R4-bgp-ipv4]peer 2.2.2.2 reflect-client
注意:该图中R4作为服务端,R1和R2作为客户端
联邦:
拓扑见QQ收藏:
R1配置:
[R1]bgp 15
[R1-bgp]router-id 1.1.1.1
[R1-bgp]confederation id 1000 主AS号
[R1-bgp]confederation peer-as 45 25 子AS号
[R1-bgp]peer 15.1.1.5 as-number 15
[R1-bgp]address-family ipv4
[R1-bgp-ipv4]peer 15.1.1.5 enable
R2配置:
[R2]bgp 25
[R2-bgp]router-id 2.2.2.2
[R2-bgp]confederation id 1000
[R2-bgp]confederation peer-as 15 45
[R2-bgp]peer 25.1.1.5 as-number 15
[R2-bgp]address-family ipv4
[R2-bgp-ipv4]peer 25.1.1.5 enable
R4配置:
[R4]bgp 45
[R4-bgp]router-id 4.4.4.4
[R4-bgp]confederation id 1000
[R4-bgp]peer 45.1.1.5 as-number 15
[R4-bgp]confederation peer-as 15 25
[R4-bgp]address-family ipv4
[R4-bgp-ipv4]peer 45.1.1.5 enable
R5配置:
[R5]bgp 15
[R5-bgp]router-id 5.5.5.5
[R5-bgp]confederation id 1000
[R5-bgp]confederation peer-as 25 45
[R5-bgp]peer 25.1.1.2 as-number 25
[R5-bgp]peer 45.1.1.4 as-number 45
[R5-bgp]peer 15.1.1.1 as-number 15
[R5-bgp]peer 35.1.1.3 as-number 2000
[R5-bgp]address-family ipv4
[R5-bgp-ipv4]peer 25.1.1.2 enable
[R5-bgp-ipv4]peer 45.1.1.4 enable
[R5-bgp-ipv4]peer 15.1.1.1 enable
[R5-bgp-ipv4]peer 15.1.1.1 next-hop-local
[R5-bgp-ipv4]peer 45.1.1.4 next-hop-local
[R5-bgp-ipv4]peer 25.1.1.2 next-hop-local
[R5-bgp-ipv4]peer 35.1.1.3 enable
R3配置:
[R3]bgp 2000
[R3-bgp]router-id 3.3.3.3
[R3-bgp]peer 35.1.1.5 as-number 1000
[R3-bgp]address-family ipv4
[R3-bgp-ipv4]peer 35.1.1.5 enable
向对等体组发送缺省路由:
[R1]bgp 1
[R1-bgp]router-id 1.1.1.1
[R1-bgp]address-family ipv4
[R1-bgp-ipv4]peer 2.2.2.2 default-route-advertise
执行peer default-route-advertise命令后,不论本地路由表中是否存在缺省路由,都将向指定对等体发布一条下一跳地址为本地地址的缺省路由
传播时不携带私有AS号:
[R3]bgp 2
[R3-bgp]address-family ipv4
[R3-bgp-ipv4]peer 13.1.1.1 public-as-only
路由重分发:
[R1]bgp 1
[R1-bgp]address-family ipv4
[R1-bgp-ipv4]import-route direct 缺省情况下,引入的源路由协议的缺省路由不会被引入BGP
允许BGP引入其他路由协议的默认路由:
[R1]bgp 1
[R1-bgp]address-family ipv4
[R1-bgp-ipv4]default-route imported
修改BGP路由的管理距离:
[R1]bgp 1
[R1-bgp]address-family ipv4
[R1-bgp-ipv4]preference 150 160 110 (EBGP IBGP Loacl BGP)
缺省情况下,ebgp-value和ibgp-value都为256,而local-value是130,取值范围都为1~256
修改BGP的计时器:
[R1]bgp 1
[R1-bgp]timer keepalive 50 hold 150
缺省情况下,发送keepalive的时间间隔为60秒;保持定时器时间为180秒
软清进程:
<R1>refresh bgp all export ipv4