BGP的基本配置:node
拓撲見QQ收藏app
R1配置:
[R1]bgp 1000負載均衡
[R1-bgp]router-id 1.1.1.1ide
[R1-bgp]peer 4.4.4.4 as-number 1000
[R1-bgp]peer 4.4.4.4 connect-interface LoopBack 0 修改更新源地址oop
[R1-bgp]peer 13.1.1.3 as-number 2000ui
[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配置:spa
[R2]bgp 1000router
[R2-bgp]router-id 2.2.2.2xml
[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