Posts

'bgp always-compare-med' vs 'bgp deterministic-med'

這兩個指令看似大同小異,分開使用有不同的結果,合併使用也有不同結果,著實讓人摸不清楚,就算是很有經驗的BGP網管人員可能也無法完全說明白這兩個指令共同運作的來龍去脈,因此我希望可以留下一些個人的見解留在網路上給大家參考: bgp always-compare-med Enabling the bgp always-compare-med command ensures the comparison of the MED for paths from neighbors in different autonomous systems. 在預設情況下,MED只用於比較來自相同來源AS路由的優劣;透過這個"bgp always-compare-med"指令的啟用,MED也可以被用來在不同來源的AS之間加以比較路由的好壞。如果使用這個指令的話,同一個AS裏面所有的路由器都應該要啟用這個特色,不然的話,有可能會發生loop的情況。 bgp deterministic-med Enabling the bgp deterministic-med command ensures the comparison of the MED variable when choosing routes advertised by different peers in the same autonomous system. The bgp always-compare-med command is useful when multiple service providers or enterprises agree on a uniform policy for setting MED. 如果使用了"bgp deterministic-med"這個指令,路由器將會先將BGP路由根據來源AS加以分組之後,分別選出best route然後再將這些各分組選出的best route依序兩兩比較,依此原則選出最終的best route。 Note: The bgp deterministic-med and bgp always-compare-med commands are not enabled by default. Also, the two comman...

BGP Regular Expression

在學習BGP的過程中,在Cisco官網及相關Document CD中最缺乏的就是Regular Expression明確的範例解說,大都只有文字說明,實際的應用及解釋相對來說比較不容易看到,因此我趁此機會將部份的Regular Expression加註中文說明,希望對於我們這種非英語系國家的同學來說可以比較容易了解每個符號的意義。 ^436 : 緊接在"^"之後的數字436表示AS-Path中若是以436為起始就會被符合 如: 436 123 456, 436 12, 436 100 100 200 436$ : 在"$"之前的436表示AS-Path中若是以436為結尾就會被符合 如: 100 200 436, 12 436, 120 320 41 436 ^$ : 代表Local送出的BGP路由,因為路由在尚未被BGP Boundary Router送出之前,AS-Path是空的,因此可以利用"^$"來代表 _436_ : 表示AS-Path中若是有字串為436(前後有空白),而且可能是以436為起始或是以436為結尾就會被符合(_可代表空白、起始、結尾或是逗號",") 如: 436 100, 100 436, 102 436 200 [1-5] : 表示單一字元的範圍如果是1~5都符合條件,也可以表示成[12345] (_436)? : 在"?"之前的元素(ATOM),也就是小括弧內的字串包含" "(在這樣的Regular Expression中,通常"_"會用來代表空白)+"436"可以出現0次或1次 (_436)* : 在"*"之前的元素(ATOM),也就是小括弧內的字串包含" "(在這樣的Regular Expression中,通常"_"會用來代表空白)+"436"可以出現0次或連續多次 (_436)+ : 在"+"之前的元素(ATOM),也就是小括弧內的字串包含" "(...

BGP Dual AS Configuration : neighbor local-as 參數釋疑(Part 4)

Image
replace-as Prepends only the local AS number to the AS-path attribute. The AS number from the local BGP routing process is not prepended. 基本上我覺得這一段話真的很像英文文言文,我看了很久還是看不懂它所要表達的意義…我看我們還是來看看實際實驗結果來檢查AS-Path的變化吧。 網路架構圖: 在R2上直接再加上replace-as這個參數: R2#conf t Enter configuration commands, one per line. End with CNTL/Z. R2(config)#router bgp 100 R2(config-router)# neighbor 192.168.1.10 local-as 200 no-prepend replace-as 00:16:35: %SYS-5-CONFIG_I: Configured from console by console 00:16:35: %BGP-5-ADJCHANGE: neighbor 192.168.1.10 Down Local AS change[OK] 00:17:14: %BGP-5-ADJCHANGE: neighbor 192.168.1.10 Up R2# 接著我們來看看每個Router上的BGP Table R1#sh ip bgp BGP table version is 8, local router ID is 10.3.3.11 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 10.3.3.11/32 0.0.0.0 0 32768 i ...

BGP Dual AS Configuration : neighbor local-as 參數釋疑(Part 3)

Image
no-prepend Does not prepend the local AS number to any routes recevied from the EBGP neighbor. 網路架構圖: 根據我們Part 2的實驗結果我們可以知道,當我們加上local-as之後,不論是接收到的EBGP或是轉送出去的IBGP都會被prepend上local-as(在本例中為200)。而在local-as之後再接著no-prepend這個參數的話,則是當接收到EBGP路由時不再prpepdn local-as,我想透過我的中文說明大家會比較了解Cisco的文言文在說些什麼,多說無益,直接作Lab來看結果,大家就可以了解了! 以下是我們在R2上設定步驟: R2#conf t Enter configuration commands, one per line. End with CNTL/Z. R2(config)#router bgp 100 R2(config-router)#nei R2(config-router)#neighbor 192.168.1.10 local-as 200 no-pre R2(config-router)#neighbor 192.168.1.10 local-as 200 no-prepend R2(config-router)#00:53:03: %BGP-5-ADJCHANGE: neighbor 192.168.1.10 Down Local A S change => 即使只是修改local-as之後的參數也會導致BGP session中斷喔,所以請小心!!! 接著我們再來看看各個Router上的BGP Table: R1#sh ip bgp BGP table version is 20, local router ID is 10.3.3.11 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale Origin codes: i - IGP, e - EGP, ? - incomplete Network N...

BGP Dual AS Configuration : neighbor local-as 參數釋疑(Part 2)

Image
Neighbor local-as The neighbor local-as command is used to customize the AS-path attribute by adding and removing AS numbers for routes recevied from EBGP neighbors. 網路架構圖: 現在我們假設ISP A(R1/AS100)併購了ISP B(R2/AS200),因此ISP B(R2)原來的AS200將要改變成為AS100,但是為了不影響客戶的連線及BGP設定,我們必須使用BGP local-as這個參數來使用客戶受影響的層面減到最少的程度,但是Cisco對於R2修改BGP AS number時,跟客戶之間的BGP session至少會中斷40秒至1分鐘左右(假設你copy & paste的速度很快的話)避而不談,所以請各位不要以為可以神不知鬼不覺地轉換BGP AS,事情可是沒有想像中這麼完美的… 因此,我們知道大概在ISP B(R2)上至少有兩個動作要作: 1.修改BGP AS Number(同時ISP A(R1)上也要修改相對應的BGP neighbor config) 2.針對Customer(R3)的BGP neighbor中要加上local-as參數 設定如下: R1#conf t Enter configuration commands, one per line. End with CNTL/Z. R1(config)#router bgp 100 R1(config-router)#neighbor 192.168.1.2 remote-as 100 R2#conf t Enter configuration commands, one per line. End with CNTL/Z. R2(config)#no router bgp 200 R2(config)#router bgp 100 00:28:43: %BGP-5-ADJCHANGE: neighbor 192.168.1.10 Down BGP protocol initializati on => 修改BGP AS Number一定會使得BGP session重啟 R2(config-router)# ...

BGP Dual AS Configuration : neighbor local-as 參數釋疑(Part 1)

Image
Cisco現在的教材真的是愈來愈難懂,文字一大堆卻又捨不得多放一些Figure或是每個Router的Routing Table來輔助說明,我花了一個晚上的時間才把neighbor local-as後面的幾個參數搞清楚…希望我的努力可以減少各位在學習上的挫折。 首先我利用了Dynamips來架設一個Virtual Lab來加以說明,各位有興趣的話,可以把以下的內容存成一個.net檔案之後來啟動dynamips(請切記要修改IOS實際的存在絕對目錄位址): =============================================================== [localhost] [[7200]] image = C:\Program Files\Dynamips\images\c7200-k91p-mz.122-25.S9.extracted.bin idlepc = 0x60843c10 npe = npe-400 ram = 128 ghostios = true # Enable or disable IOS ghosting globally for this lab. Can be overridden at the device defaults sections, or the device sections. Defaults to False. mmap = false # mmap = true(use disk for ghost memory) or false(use real memory) disk0 = 0 disk1 = 0 confreg = 0x2102 [[ROUTER R1]] s1/0 = R2 s1/0 s1/1 = R3 s1/0 [[router R2]] s1/1 = R3 s1/1 [[ROUTER R3]] =============================================================== 網路架構圖: 以下是R1(AS100), R2(原本屬於AS2...

ATOMIC_AGGREGATE vs AGGREGATOR

在剛開始接觸BGP時,常常會因為英文單字的相似而被混淆,我想是大家共同的感覺,因此我將兩個很接近的屬性列出來加以比較給大家介紹一下。 ATOMIC_AGGREGATE ATOMIC_AGGREGATE is a well-known discretionary attribute. When a BGP speaker aggregates several routes for the purpose of advertisement to a particular peer, the AS_PATH of the aggregated route normally includes an AS_SET formed from the set of ASes from which the aggregate was formed. In many cases, the network administrator can determine if the aggregate can safely be advertised without the AS_SET, and without forming route loops. If an aggregate excludes at least some of the AS numbers present in the AS_PATH of the routes that are aggregated as a result of dropping the AS_SET, the aggregated route, when advertised to the peer, SHOULD include the ATOMIC_AGGREGATE attribute. ATOMIC_AGGREGATE這個屬性一旦存在(並無內含任何的數值,僅僅為一個指標意義而已)就代表這筆路由中可能發生了AS-Path Information Lost的情況,比如將AS123, AS321的路由合併之後只留下|123|的AS-Path;因此ATOMIC_AGGREGATE跟BGP command中的AS-SET這個參數互斥,只要設定了AS-SET這個參數,AS123, AS321的路由合併之後,AS-Path會變成|{1...