BGP學習筆記

                                  BGP學習筆記

一,基本概念
1、 路由協議的分類
(1)       IGP:rip、ospf、eigrp、isis等
(2)       EGP:分爲EGP和BGP,BGP是基於EGP開發出來的。
2、 區分IGP和EGP:工作在一個AS內部的就是IGP,工作在AS之間的就是EGP。
(1)       AS(autonomous systems):由統一管理者管理的管理的範圍就是一個AS。
(2)       例如:電信和網通
3、 AS號的範圍
(1)       公有:0~64511
(2)       私有:64512~65535
(3)       查全世界的AS號的網址:http://bgp.potaroo.net
4、 BGP:Path-Vector Routing(路徑矢量協議)
1.         BGP:AS-by-AS
2.         IGP:Hop-by-Hop
5、 BGP Characteristics
(1)       當一個數據包從一個AS穿越另一個AS的時候
(2)       當一個AS連接多個AS的時候
(3)       路由策略(選路)
(4)       在公網選用BGP的優點:
管理不方便
其他協議沒辦法支持那麼多路由(在公網一般有十幾萬條)ospf支持1萬條,isis也就2萬條。
策略方面比IGP更多
擴展性大:可以傳ipv4、ipv6和***v4等。
(5)       公網的虛擬路由器,映射了公網的所有路由。
telnet route-server.ip.att.net
用show ip route summary可以查看公網有多少BGP路由
6、 在什麼情況下不要用BGP
(1)    對BGP不熟悉的時候
(2)    不存在選路的時候
(3)    路由器的性能不夠強的時候
7、 BGP的特徵
(1)       用的協議是:tcp
(2)       端口:179
(3)       更新:觸發更新(rip、ospf、isis是觸發和週期更新,而eigrp是觸發更新)
(4)       通過發keepalive報文維持鄰居的狀態,週期性的發keepalive報文,週期是60秒。如果180秒沒有收到keepalive就認爲鄰居down了
8、 BGP與IGP的不同
(1)       在IGP中hello包上用來建鄰居和keeplive的
(2)       在BGP中,建鄰居用的是open報文,保持連接用的是keepalive報文
9、 IGP是用metrics或者cost來衡量路徑的好壞,而BGP是用attribute(屬性)。
10、              BGP設計是爲了大型網絡的。
 
二、BGP的三張表
1、表的名稱和作用
(1)Neighbor table:用open報文建立鄰居
(2)BGP table(forwarding database):會選出一條最優的路徑放到路由表中。
(3)ip routeing table
2、BGP分IBGP和EBGP,IBGP的管理距離是200,EBGP是20
三、BGP的報文
 1、報文的名稱和作用
(1)Open:用來建立鄰居,報文中包括hold time和router id(router id手工指定,如果沒有手工指定就是loopback口最大的ip地址,或者物理接口最大IP地址)
(2)keepalive:用來維持鄰居關係
(3)Update:傳輸BGP路由,bgp的路由更新
(4)Notification:當錯誤發生的時候會發這個報文
 四、EBGP和IBGP的介紹
1、名詞解釋:
 (1)Peers = Neighbors
 (2)BGP speakers:運行BGP的路由器
2、External BGP:在不同AS之間建立的BGP鄰居關係
3、Internal BGP:在同一AS之間建立的BGP鄰居關係
五、路由黑洞解決方法:
1、物理線路FULL MESH
2、BGP鄰居的FULL MESH
3、將BGP重分佈到IGP中(只用於實驗環境中)
4、最好的解決方法的MPLS
六、水平分割
 1、EBGP的水平分割:主要靠AS號,不接收本AS號的BGP路由。如下圖:
因爲一個AS裏的A1路由器發給下一個AS裏的A2路由器路由的時候,其中字段包含AS號和下一條地址等,當A2發給A3路由的時候,字段裏就帶兩個AS號AS1和AS2,當A3再發給A1的時候,裏面有和A1一樣的AS號。這時候A1就不接收相同AS號的路由。 
 
 
2、IBGP的水平分割:從IBGP鄰居學到的路由,不會再通告給其他的IBGP鄰居。如下圖,D從B學到的路由不會再通告給E.
七.BGP的基本配置
 1、實驗拓撲如下:
    
 2、實驗步驟:
   (1)基本配置:
      R1: interface loopback0
          ip add 1.1.1.1 255.255.255.0
          interface serial 0
           ip address 12.1.1.1 255.255.255.0
           no shut
           interface serial 1
           ip address 13.1.1.1 255.255.255.0
            no shut
            line con 0
             exec-time 0 0
             logging sysncharonous
 
R2:interface loopback0
     ip add 2.2.2.2 255.255.255.0
     interface serial 0
     ip address 12.1.1.2 255.255.255.0
      clockrate 1000000
      no shut
      interface serial 1
      ip address 24.1.1.2 255.255.255.0
      clockrate 1000000
      no shut
R3:interface loopback0
     ip add 3.3.3.3 255.255.255.0
     interface serial 0
     ip address 35.1.1.3 255.255.255.0
      clockrate 1000000
      no shut
      interface serial 1
      ip address 13.1.1.3 255.255.255.0
      clockrate 1000000
      no shut
R4:interface loopback0
     ip add 4.4.4.4 255.255.255.0
     interface serial 0
     ip address 461.1.4 255.255.255.0
      clockrate 1000000
      no shut
      interface serial 1
      ip address 24.1.1.4 255.255.255.0
      clockrate 1000000
      no shut
R5:interface loopback0
     ip add 5.5.5.5 255.255.255.0
     interface serial 0
     ip address 35.1.1.5 255.255.255.0
      clockrate 1000000
      no shut
(2)R2和R4建鄰居
R4的配置
R4(config)#router bgp 4
R4(config-router)#bgp router-id 4.4.4.4(建議和OSPF配成一樣的)
    R4(config-router)#neighbor 24.1.1.2 remote-as 1(與對端建立鄰居,在BGP中用這條命令建立鄰居)
R2的配置
R2(config)#router bgp 1
R2(config-router)#bgp router-id 2.2.2.2(建議和OSPF配成一樣的)
    R2(config-router)#neighbor 24.1.1.4 remote-as 4
(3)R2和R3建立IBGP鄰居()
     首先配置IGP(OSPF)互通路由
R2的配置
R2(config)#router ospf 110
R2(config-router)#router-id 2.2.2.2
R2(config-router)#network 12.1.1.0 0.0.0.255 area 0
         R2(config-router)#network 2.2.2.0 0.0.0.255 area 0
R1的配置
R1(config)#router ospf 110
R1(config-router)#router-id 1.1.1.1
R1(config-router)#network 12.1.1.0 0.0.0.255 area 0
R1(config-router)#network 13.1.1.0 0.0.0.255 area 0
         R2(config-router)#network 1.1.1..0 0.0.0.255 area 0
R3的配置
R3(config)#router ospf 110
R3(config-router)#router-id 3.3.3.3
R3(config-router)#network 13.1.1.0 0.0.0.255 area 0
         R3(config-router)#network 3.3.3.0 0.0.0.255 area 0
     建立IBGP鄰居用R2和R3的環回口
R2的配置
R2(config)#router bgp 1
    R2(config-router)#neighbor 3.3.3.3. remote-as 1
    R2(config-router)#neighbor 3.3.3.3 update-source loopback 0(我和R3建立鄰居的時候,回來的時候是loopback口,不然無法用環回口建立鄰居)
R3的配置
R3(config)#router bgp 1
    R3(config-router)#neighbor 2.2.2.2 remote-as 1
    R3(config-router)#neighbor 2.2.2.2 update-source loopback 0(建議兩邊都做,但一邊做也可以)
(4)如果R3和R5是如下圖所示,要用環回口建立鄰居,能保證冗餘備份
這是建立鄰居關係最麻煩的一種,默認發出來的TTL=1,到了對端就不能再傳了,所以這裏要涉及到ebgp-multihop(多跳),配置爲大於等於2才能到達對端的環回口。配置靜態路由的爲了能跑讓不同的AS有路由。
如上圖的R3和R5建立鄰居如下:
R3的配置
 R3(config)#router bgp 1
R3(config-router)#neighbor 5.5.5.5 remote-as 5
R3(config-router)#neighbor 5.5.5.5 update-source loopback 0
R3(config-router)#neighbor 5.5.5.5 ebgp-multihop 2(ebgp的最大跳數是2,默認回車是最大的255)
R3(config)#ip route 5.5.5.5 255.255.255.255 serial 0
R5的配置
R5(config)#router bgp 5
R3(config-router)#neighbor 3.3.3.3 remote-as 1
R3(config-router)#neighbor 3.3.3.3 update-source loopback 0
R3(config-router)#neighbor 3.3.3.3 ebgp-multihop 2
R5(config)#ip route 3.3.3.3 255.255.255.255 serial 0
 
   (5)宣告路由:
R4的配置
R4(config)#router bgp 4
R4(config-router)#network 4.4.4.0 mask 255.255.255.0(BGP的network可以通告本地路由表所有的路由,而IGP是隻通告本接口的路由)
    (6)當R4的路由傳到R5上的時候,還是不能通信,必須R1和R2、R3都建立BGP鄰居纔可以,配置如下,用peer group技術,如下:
R1(config)#router bgp 1
R1(config-router)#bgp router-id 1.1.1.1
R1(config-router)#neighbor WOLF peer-group(定義一個模板,給peer group啓的名字)
R1(config-router)#neighbor WOLF remote-as 1(模板的命令,與1建立鄰居關係)
R1(config-router)#neighbor WOLF update-source loopback 0(模板的命令,更新源是環回口)
R1(config-router)#neighbor 2.2.2.2 peer-group WOLF(調用peer-group的模板)
R1(config-router)#neighbor 3.3.3.3 peer-group WOLF(調用peer-group的模板)
 
R2(config)#router bgp 1
R2(config-router)#neighbor 1.1.1.1 remote-as 1
R2(config-router)#neighbor 1.1.1.1 update-source loopback 0
R2(config-router)#neighbor 1.1.1.1 next-hop-self
 
R3(config)#router bgp 1
R3(config-router)#neighbor 1.1.1.1 remote-as 1
R3(config-router)#neighbor 1.1.1.1 update-source loopback 0
 
    (7)想要R5和R4互通,需要把R5的路由通告出來
          R5(config)#router bgp 5
          R5(config-router)#network 5.5.5.0 mastk 255.255.255.0
         
          R3(config-router)#neighbor 1.1.1.1 next-hop-self
 R3(config-router)#neighbor 2.2.2.2 next-hop-self
     (8)用R5 ping R4測試
          R5#ping 4.4.4.4 source 5.5.5.5 (否則源地址是R5的S0接口了,沒有宣告路由,所以不同)
 
 
3、查看命令:
 (1)查看鄰居信息的簡表:show ip bgp summary 
    
如果看到state/PfxRcd下面是數字就代表鄰居建立起來了,數字代表學到了多少路由
(2)查看鄰居詳細列表:show ip bgp neighbor
(3)查看鏈接的端口:show tcp brief
(4)查看BGP表:show ip bgp
    
*號代表這條路由可用
>號代表最好的路由,沒有標識>號的路由,認爲不是最優的,所有不放進路由表,也不會給其他BGP鄰居傳
BGP路由優化的條件:
1.         同步:(解放方法:從IGP學到或者關掉同步no syn(在12.2(8)以上的版本開啓BGP後會自動生產的)同步是針對IBGP說的,EBGP傳過來的路由都優化}
2.         下一條:用靜態或IGP學/ next-hop-self(就是我給你發的路由下一條指向我,如上圖在R2的配置:
R2(config-router)#neighbor 3.3.3.3 next-hop-self
八、實驗二
1、實驗拓撲:
      2.實驗目的:如圖所示,A和B,C和D建立的鄰居關係,如果A給D發數據包,先發到B,再發給C,然後到D,所以我們驗證,A先發給C是不是更好。
      3、實驗配置
        (1)基本配置IP地址
       (2)建立BGP關係
R2的配置
R2(config)#router bgp 2
R2(config-router)#bgp router-id 2.2.2.2
R2(config-router)#neighbor 12.1.1.1 remote-as 1
R1的配置
R1(config)#router bgp 1
R1(config-router)#bgp router-id 1.1.1.1
R1(config-router)#neighbor 12.1.1.2 remote-as 2
         (3)R1和R3建立IGP用ripv2,
R1的配置:
R1(config)#router rip
R1(config-router)#version 2
R1(config-router)#no auto-summary
R1(config-router)#network 1.0.0.0
R1(config-router)#network 134.1.0.0
R3的配置:
R3(config)#router rip
R3(config-router)#version 2
R3(config-router)#no auto-summary
R3(config-router)#network 3.0.0.0
R3(config-router)#network 134.1.0.0
          (4)R1、R3、R4建立IBGP關係
R1的配置:
R1(config)#router bgp 1
R1(config-router)#neighbor 3.3.3.3 remote-as 1
R1(config-router)#neighbor 3.3.3.3 update-source loopback 0
R1(config-router)#neighbor 3.3.3.3 next-hop-self (爲了能讓路由變優)
R3的配置:
R3(config)#router bgp 1
R3(config-router)#bgp router-id 3.3.3.3
R3(config-router)#neighbor 1.1.1.1 remote-as 1
R3(config-router)#neighbor 1.1.1.1 update-source loopback 0
R3(config-router)#neighbor 134.1.1.4 remote-as 4
R4的配置:
R4(config)#router bgp 4
R4(config-router)# bgp router-id 4.4.4.4
R4(config-router)#neighbor 134.1.1.3 remote-as 1
(5)在R2上通告路由:
     R2(config)#router bgp 2
     R2(config-router)#network 2.2.2.0 mask 255.255.255.0
4、實驗結論:當R4收到R2宣告的路由,下一條指向是134.1.1.1, 應該是134.1.1.3,所有在MA網絡中,ICMP是開啓的,ICMP的作用是,如果我從這個接口收到的數據包,還從這個接口發出去,這時候R3就像源端R4發一個ICMP重定向的包,報文內容是你R4發包下一條不用指向我R3了,直接把網管指向R1的134.1.1.1
Show ip interface e0 可以看到ICMP是開啓的
Debug ip bgpupdate 查看建立鄰居關係
Clear ip bgp * 清楚BGP鄰居,硬清,這樣重建TCP連接
Clear ip bgp * soft 軟清,不斷開TCP連接。重新發一些update報文
通告debug看是R3判斷出來的
5、BGP States(BGP 的狀態)
   (1)Idle:(空閒狀態)剛配了一條路由,正在查找,這個階段就是Idle
   (2)Connect:本臺路由器已經找到了那個鄰居的路由,而且也完成了三次握手
   (3)Open sent:發送Open報文建鄰居,如果都匹配,進入下一個階段
   (4)Open confirm:確認兩邊收到的Open報文的匹配的,正常就進入下一階段
   (5)Established:建立完成(用show ip bgp summary可以查看學習到的路由)
6、不正常的情況會出現下列幾種狀態
   (1)Idle:本地不能發現鄰居的路由(例如沒有運行IGP)
   (2)Active:
鄰居沒有我本端的路由表
Neighbor 對端的地址錯誤的時候
鄰居沒有配置neighbor本端的命令
AS號配置錯了
7、BGP Neighbor authentication(BGP 鄰居的認證)
   (1)配置命令
R3(config-router)#neighbor 1.1.1.1 password 123456
8、show ip bgp rib-failure:查看bgp的路由信息庫(routing information base)
   (1)如果查看到路由條目前打的是r,說明這條路由即從IGP學到,又從BGP學到,但IGP的AD比BGP的小,最終導致IGP的路由進入路由表,而BGP路由沒有進入,她就會在BGP表中標識一個r。
   (2)標識r的路由:
不放進路由表,
會給其他BGP鄰居傳,是優的路由
9、查看收發給鄰居的路由
(1)show ip bgp neighbors 12.1.1.1 advertised-router:查看我想鄰居12.1.1.1發送了那些路由
   (2)show ip bgp neighbors 12.1.1.2 received-routes (默認是看不到的,必須先配置如下命令)
R1(config-router)#neighbor 12.1.1.2 soft-reconfiguration inbound(這個命令作用就是看我通過自己一些內存保留這個12.1.1.2鄰居給我發了那些路由)
10、auto-summary和no auto-summary的區別和作用
(1)no auto-summary:在BGP裏的這條命令是用作重發布的時候,當任何一種協議重發布進入BGP中的時候,不會發生自動彙總。而且攜帶下一條和metric值
(2)Auto-summary:一種協議重發布到BGP中,執行的操作是不攜帶原有的下一條和metric值,而且會發生自動彙總
 
九、CIDR and Aggregate Addresses
   (1)手工寫一條靜態路由NULL0,network彙總路由
例如:在上面拓撲的R2上有4條明細路由分別爲:200.1.16.0/24、200.1.17.0/24、200.1.18.0/24、200.1.19.0/24、
配置如下:
R2(config)#ip route 200.1.16.0 255.255.252.0 null0
R2(config)#router bgp 2
R2(config-router)#network 200.1.16.0 mask 255.255.252.0
   (2)聚合地址
宣告明細路由
R2(config-router)#network 200.1.16.0
R2(config-router)#network 200.1.17.0
R2(config-router)#network 200.1.18.0
R2(config-router)#network 200.1.19.0
Aggregate-address
R2(config-router)#aggregate-address 200.1.16.0 255.255.252.0 summary-only
(summary-only的意思是僅僅傳聚合路由,這樣做BGP路由表裏會出現s開頭的路由,代表被抑制掉的路由)
(3)       如上,如果想抑制掉16和17,想學習聚合的和18、19的。配置如下:
       R2(config-router)#aggregate-address 200.1.16.0 255.255.252.0 suppress-map SUP
(SUP 是route-map的名字)
       R2(config)#ip prefix-list 1 permit 200.1.16.0/23 ge 24 le 24
       R2(config)#route-map SUP
      R2(config-route-map)#match ip address prefix-list 1
(4)       as-set:當明細路由和聚合路由不在一個路由器上的時候,還原明細路由的屬性,把明細路由的屬性添加到聚合路由上。讓聚合路由也攜帶這個屬性。
例如:在R2上宣告明細路由,在R1的配置如下:
      R1(config-router)#aggregate-address 200.1.16.0 255.255.252.0 summary-only as-set
十、BGP Path Attributes(BGP 路徑屬性)
1、識別
2、遵守和自行決定
 (1)AS path *:防環
 (2)Next-hop *:爲了路由能達到最優
 (3)Origin *:(起源屬性)
I:通過network通告進BGP都是打i
?:重發布過來的路由
E:從EGP重發布到BGP中
修改屬性會從路由看到E,在R1配置如下:
Ip prefix-list 2 permit 2.2.2.2/24
 
Route-map TEST permit 10
Match ip address prefix-list 2
Set origin egp 2     設置起源屬性值
 
Router bgp 1
Neighbor 12.1.1.2 route-map TEST in
3、傳播範圍
4、添加其他類型
十一、選路原則
1、 前提是我的同步都關掉,我的下一條是否可達到情況下去選路,保證路由都達到優化
(1)       比最大的weight值
(2)       比本地優先級
(3)       優先於起源於本地的路由
(4)       經過的AS path越短越好
(5)       起源值越小越好(IGP<EGP<incomplete)
(6)       Metric值越小越好(MED=metric)
(7)       EBGP是由於IBGP的
(8)       優選於最近的IGP鄰居(就是metric最小)
(9)       如果前面都相等,我會比較最小BGP鄰居的router-id
2、 實驗
(1)       實驗拓撲圖
(2)       實驗目的:驗證上面屬性對選路的影響
(3)       Weight值
基本配置以完成,R1、R3和R4運行IGP協議ospf,
在R2上通告路由
R2(config)#network 2.2.2.0 mask 255.255.255.0
R2(config)#network 9.9.9.0 mask 255.255.255.0
默認2.2.2.0和9.9.9.0網段都從R4走,如果想讓這兩個網段都從R1走,修改weight值,如果在我本臺路由器上通告的路由,默認weight值是32768,在R3上修改weight值,配置如下:
R3(config)#router bgp1
R3(config-router)#neighbor 1.1.1.1 weight 1(R3的in方向,意思是所有1.1.1.1發過來的路由我把weight值都調成1,如果沒有變,用clear ip bgp * soft清一下)
到R3訪問2網段從R1走,訪問9網段從R4走,配置如下:
     R3(config)#ip prefix-list 2 permit 2.2.2.0/24(抓2網段的路由)
     R3(config)#router-map W
     R3(config-router-map)#match ip address prefix-list 2 (匹配列表2)
     R3(config-router-map)#set weight 3   (設置weight值爲3)
             R3(config)#router-map W permit 20 (寫一句空的是爲了其他路由能通過)
 R3(config)#router bgp1
R3(config-router)#neighbor 1.1.1.1 router-map W in(在R3的in方向調用W)
(4)       本地優先級(local preference Attribute)
傳播範圍:只能在一個AS內部
默認值是100
越大越優
讓R3訪問這兩個網段從R1走,在R1配置如下:
 R1(config)#router bgp1
R1(config-router)#bgp default local-preference 111
bgp default local-preference 111 這條命令對下面的是否起效
1、 network 對自己的network的路由是否起效
2、 對EBGP傳過來的路由是否起效
3、 對IBGP路由傳過來的路由是否起效
4、 對聚合的路由是否起效
讓2網段走R1,配置如下:
R1(config)#access-list 2 permit 2.2.2.0(抓2網段的路由)
     R1(config)#router-map L
     R1(config-router-map)#match ip address 2 (匹配列表2)
R1(config-router-map)#set local-preference 123
 R1(config)#router-map L permit 20
 R1(config)#router bgp1
R1(config-router)#neighbor 3.3.3.3 router-map L out
(5)       比short 的AS path
R3訪問2網段走R1,在R2配置如下:
R2(config)#ip prefix-list 2 permit 2.2.2.0/24(抓2網段的路由)
     R2(config)#router-map AS
     R2(config-router-map)#match ip address prefix-list 2 (匹配列表2)
     R2(config-router-map)#set as-path prepend 6 7 8   (設置as的長短)
       R2(config)#router-map AS permit 20
 R2(config)#router bgp 2
R2(config-router)#neighbor 24.1.1.4 router-map AS out(在R2的out方向)
R3訪問2網段走R1,在R4配置如下
R4(config)#ip prefix-list 2 permit 2.2.2.0/24(抓2網段的路由)
     R4(config)#router-map AS
     R4(config-router-map)#match ip address prefix-list 2 (匹配列表2)
     R4(config-router-map)#set as-path prepend 7 8 9 (設置as的長短)
       R4(config)#router-map AS permit 20
 R4(config)#router bgp 1
R4(config-router)#neighbor 24.1.1.2 router-map AS in
(6)       lower origin code(IGP<EGP<Incomplete)
IGP:network出來的
把EGP重分佈到BGP中
Incomplete(?):把IGP或者靜態路由重分佈到BGP中
(7)       lower MED(MED相當於IGP的metric值)
傳播範圍
默認值是0
越小越好
實驗:在R3上建立一個環回口並通告出來,配置如下:
R3(config)#interface loopback 8
R3(config-if)#ip address 8.8.8.8 255.255.255.0
R3(config)#router bgp 1
R3(config-router)#network 8.8.8.0 255.255.255.0
默認R2訪問R3的8網段上從R1走,如果想從R4走,配置如下:
R1(config)#router-map MED
 R1(config-router-map)#set metric 8
R1(config)#router bgp1
R1(config-router)#neighbor 12.1.1.2 route-map MED out
用擴展ping可以檢驗配置的效果,最常用的是Local perference(本地優先級)MED
十一、補充知識
   1、解決IBGP的水平分割:
   (1)路由反射器:下圖是C/S模型,R1是RR,是S
a.RR從EBGP收到的路由:即會反射給我的客戶端,也會反射給我的非客戶端
b,RR從client端收到的路由:會反射給我的client,以及我的非client,以及我的EBGP鄰居        
c.RR從非client收到的路由:只會反射給client端和EBGP鄰居,不會反射給非client
 
實驗如圖:默認R3是不會給R4發路由的,因爲IBGP水平分割的,解決方法配置如下:
 
R3(config)#router bgp1
R3(config-router)#neighbor 1.1.1.1 route-reflector-client(這條命令即把R1變成客戶端,也把自己變成server了,也就是RR了)
R3(config-router)#neighbor 4.4.4.4 route-reflector-client  
(2)聯邦
Router bgp 小AS號(私有AS號)
聲明所在的大AS號
小AS號之間互指peer
實驗如上圖,配置如下:
R1(config)#router bgp 64512
R1(config-router)#neighbor 12.1.1.2 remote-as 2
R1(config-router)#neighbor 3.3.3.3 remote-as 64512
         R1(config-router)#neighbor 3.3.3.3 update-source loopback 0
       R1(config-router)#neighbor 3.3.3.3 next-hop-self
 R3(config)#router bgp 64512
R3(config-router)#neighbor 1.1.1.1 remote-as 64512
 R3(config-router)#neighbor 1.1.1.1 update-source loopback 0
R3(config-router)#neighbor 4.4.4.4 remote-as 64513
         R3(config-router)#neighbor 4.4.4.4 update-source loopback 0
         R3(config-router)#neighbor 4.4.4.4 ebgp-multihop
 R4(config)#router bgp 64513
R4(config-router)#neighbor 3.3.3.3 remote-as 64512
 R4(config-router)#neighbor 3.3.3.3 update-source loopback 0
         R4(config-router)#neighbor 3.3.3.3 ebgp-multihop
 
在聯邦中的每臺路由器上聲明大AS號:
R1(config)#router bgp 64512
R1(config-router)#bgp confederation identifier 1(聲明大AS號,聯邦中的每臺路由器都的做)
R3(config-router)#bgp confederation identifier 1
R4(config-router)#bgp confederation identifier 1
在小AS邊界互指peer
R3(config-router)#bgp confederation peers 64513
R4(config-router)#bgp confederation peers 64512
3、 社團屬性:Community:干涉路由傳播範圍
(1)       可選:路由器有可能不識別此屬性(default),如果想識別,做如下配置:neighbor x.x.x.x send-community
(2)       傳遞:社團屬性只在neighbor鄰居有效,如果想往下傳,做如下配置:neighbor x.x.x.x send-community
(3)       屬性no-advertise:攜帶此社團屬性的路由不會通告給任何BGP鄰居
R2(config)#router-map COM
R2(config-router-map)#set community no-advertise
      R2(config)#router bgp 2
      R2(config-router)#neighbor 12.1.1.1 router-map COM out
               R2(config-router)#neighbor 12.1.1.1 send-community
        (4)屬性no-export:攜帶此社團屬性的路由不會傳出大AS
R2(config)#router-map COM
R2(config-router-map)#set community no-export
      R2(config)#router bgp 2
      R2(config-router)#neighbor 12.1.1.1 router-map COM out
               R2(config-router)#neighbor 12.1.1.1 send-community
        (5)屬性local-AS:攜帶此社團屬性的路由不會傳出小AS
R2(config)#router-map COM
R2(config-router-map)#set community local-AS
      R2(config)#router bgp 2
      R2(config-router)#neighbor 12.1.1.1 router-map COM out
               R2(config-router)#neighbor 12.1.1.1 send-community
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章