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内有意义)
[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 出接口修改