BGP Advanced: Attributes & Path Selection
CCNP ENARSI 300-410 EVE-NG / GNS3
مقصدObjectiveObjective
اس لیب میں آپ BGP کے اہم path attributes (weight، local-preference، AS-path، MED) اور BGP best-path selection کا عمل سیکھیں گے۔Is lab mein aap BGP ke ahem path attributes (weight, local-preference, AS-path, MED) aur BGP best-path selection ka amal seekhenge.In this lab you will learn the key BGP path attributes (weight, local-preference, AS-path, MED) and the BGP best-path selection process.
آسان مثالSimple AnalogySimple Analogy
BGP path selection ایسے ہے جیسے نوکری کے امیدوار چننا — پہلے اندرونی سفارش (weight)، پھر کمپنی کی پالیسی (local-pref)، پھر باہر کے حوالے (AS-path کی لمبائی)، پھر امیدوار کا اپنا دعویٰ (MED) دیکھا جاتا ہے۔ جو پہلے معیار پر جیت جائے، وہی منتخب۔BGP path selection aise hai jaise naukri ke umeedwar chunna — pehle andaruni sifarish (weight), phir company ki policy (local-pref), phir bahar ke hawale (AS-path ki lambai), phir umeedwar ka apna dawa (MED) dekha jata hai. Jo pehle miyar par jeet jaye, wohi muntakhib.BGP path selection is like hiring — first the internal recommendation (weight), then company policy (local-pref), then outside references (AS-path length), then the candidate's own claim (MED). Whoever wins at the earliest criterion is selected.
سیٹ اپLab SetupLab Setup
R1 (AS 65001) کے دو eBGP نیبرز ہیں: R2 (AS 65002) اور R3 (AS 65003)۔ دونوں ایک ہی prefix 10.99.0.0/16 advertise کرتے ہیں۔ مقصد: attributes بدل کر best path کو کنٹرول کرنا۔R1 (AS 65001) ke do eBGP neighbors hain: R2 (AS 65002) aur R3 (AS 65003). Dono ek hi prefix 10.99.0.0/16 advertise karte hain. Maqsad: attributes badal kar best path ko control karna.R1 (AS 65001) has two eBGP neighbors: R2 (AS 65002) and R3 (AS 65003). Both advertise the same prefix 10.99.0.0/16. Goal: control the best path by changing attributes.
اقداماتStepsSteps
Step 1
بنیادی eBGP کنفیگر کریں۔ R1 پر دونوں نیبرز کے ساتھ eBGP پیئرنگ بنائیں۔ show ip bgp summary سے state Established چیک کریں۔Bunyadi eBGP configure karein. R1 par dono neighbors ke saath eBGP peering banayein. show ip bgp summary se state Established check karein.Configure basic eBGP. Build eBGP peering with both neighbors on R1. Check for Established state with show ip bgp summary.
configure terminal router bgp 65001 neighbor 192.168.12.2 remote-as 65002 neighbor 192.168.13.3 remote-as 65003 exit
Step 2
Weight کا اثر دیکھیں۔ Weight صرف local راؤٹر پر اثر ڈالتی ہے (Cisco-specific)۔ R2 سے آنے والے راستے پر زیادہ weight لگائیں اور دیکھیں کہ best path بدل جاتا ہے۔Weight ka asar dekhein. Weight sirf local router par asar dalti hai (Cisco-specific). R2 se aane wale raste par zyada weight lagayein aur dekhein ke best path badal jata hai.See weight in action. Weight affects only the local router (Cisco-specific). Set a higher weight on the route from R2 and watch the best path change.
configure terminal router bgp 65001 neighbor 192.168.12.2 weight 200 exit clear ip bgp * soft
Step 3
Local-preference آزمائیں۔ Local-pref پورے AS میں پھیلتی ہے (iBGP)۔ Route-map سے R3 والے راستے پر local-pref 200 لگائیں — اب یہ weight کو پیچھے چھوڑ دے گا کیونکہ weight ہٹا دیں گے۔Local-preference aazmayein. Local-pref poore AS mein phelti hai (iBGP). Route-map se R3 wale raste par local-pref 200 lagayein — ab ye weight ko peeche chhor dega kyunke weight hata denge.Try local-preference. Local-pref propagates inside the whole AS (iBGP). Use a route-map to set local-pref 200 on the R3 path — it will beat weight once weight is removed.
configure terminal ip prefix-list TEST seq 5 permit 10.99.0.0/16 route-map SET-LP permit 10 match ip address prefix-list TEST set local-preference 200 exit router bgp 65001 no neighbor 192.168.12.2 weight 200 neighbor 192.168.13.3 route-map SET-LP in exit clear ip bgp * soft
Step 4
Best path چیک کریں۔ show ip bgp 10.99.0.0 میں > نشان والا راستہ best path ہے۔ Attributes (LocPrf، Weight) کالم میں نظر آئیں گے۔Best path check karein. show ip bgp 10.99.0.0 mein > nishan wala rasta best path hai. Attributes (LocPrf, Weight) column mein nazar aayenge.Check the best path. In show ip bgp 10.99.0.0 the route marked > is the best path. Attributes appear in the LocPrf and Weight columns.
show ip bgp 10.99.0.0
Step 5
AS-path prepending سمجھیں۔ AS-path جتنا لمبا، راستہ اتنا کم پسندیدہ۔ اپنے AS کو راستے میں کئی بار شامل (prepend) کر کے outbound ٹریفک کو متاثر کیا جا سکتا ہے۔AS-path prepending samjhein. AS-path jitna lamba, rasta utna kam pasandeeda. Apne AS ko raste mein kai baar shamil (prepend) kar ke outbound traffic ko mutasir kiya ja sakta hai.Understand AS-path prepending. The longer the AS-path, the less preferred the route. Prepending your own AS multiple times influences outbound traffic.
configure terminal route-map PREPEND permit 10 set as-path prepend 65001 65001 65001 exit
Step 6
MED کا کردار دیکھیں۔ MED (multi-exit discriminator) پڑوسی AS کو بتاتا ہے کہ ہمارے کئی لنکس میں سے کون سا بہتر ہے۔ کم MED جیتتا ہے، مگر صرف ایک ہی پڑوسی AS کے راستوں کا موازنہ ہوتا ہے۔MED ka kirdar dekhein. MED (multi-exit discriminator) parosi AS ko batata hai ke hamare kai links mein se kaun sa behtar hai. Kam MED jeet-ta hai, magar sirf ek hi parosi AS ke raston ka mawazna hota hai.See MED's role. MED (multi-exit discriminator) tells the neighboring AS which of our multiple links is better. Lowest MED wins, but only routes from the same neighboring AS are compared.
configure terminal route-map SET-MED permit 10 set metric 50 exit show ip bgp 10.99.0.0
Step 7
Best-path ترتیب دہرائیں۔ یاد رکھیں: Weight → Local-pref → locally originated → AS-path length → origin → MED → eBGP over iBGP → IGP metric → router-ID۔ یہ ترتیب انٹرویو میں ضرور پوچھی جاتی ہے۔Best-path tarteeb dohraein. Yaad rakhein: Weight → Local-pref → locally originated → AS-path length → origin → MED → eBGP over iBGP → IGP metric → router-ID. Ye tarteeb interview mein zaroor poochi jati hai.Recap the best-path order. Remember: Weight → Local-pref → locally originated → AS-path length → origin → MED → eBGP over iBGP → IGP metric → router-ID. This order is always asked in interviews.
show ip bgp 10.99.0.0
تصدیقVerifyVerify
show ip bgp میں best path (>) وہی ہو جو آپ نے attribute سے منتخب کیا۔ ہر attribute بدلنے کے بعد soft clear کرنا نہ بھولیں۔show ip bgp mein best path (>) wohi ho jo aap ne attribute se muntakhib kiya. Har attribute badalne ke baad soft clear karna na bhoolein.In show ip bgp the best path (>) should be the one you selected via attributes. Don't forget a soft clear after each attribute change.
show ip bgp show ip bgp 10.99.0.0 show ip bgp summary
خرابی دور کرناTroubleshootingTroubleshooting
⚠️ Attribute بدلنے کے باوجود best path نہیں بدل رہا۔Attribute badalne ke bawajood best path nahi badal raha.Best path isn't changing despite attribute changes.
✅ clear ip bgp * soft (یا hard) کرنا بھول گئے ہوں گے — پالیسی پرانے راستوں پر دوبارہ لاگو نہیں ہوئی۔ Route-map کی سمت (in/out) بھی چیک کریں۔clear ip bgp * soft (ya hard) karna bhool gaye honge — policy purane raston par dobara lagu nahi hui. Route-map ki simt (in/out) bhi check karein.You probably forgot clear ip bgp * soft (or hard) — the policy wasn't reapplied to existing routes. Also check the route-map direction (in/out).
⚠️ MED لگانے کے باوجود کوئی فرق نہیں پڑا۔MED lagane ke bawajood koi farq nahi para.MED made no difference.
✅ MED کا موازنہ صرف ایک ہی پڑوسی AS سے آئے راستوں میں ہوتا ہے۔ مختلف AS سے آئے راستوں پر MED نظرانداز ہو جاتا ہے — یہ ڈیزائن کے مطابق ہے۔MED ka mawazna sirf ek hi parosi AS se aaye raston mein hota hai. Mukhtalif AS se aaye raston par MED nazar-andaz ho jata hai — ye design ke mutabiq hai.MED is only compared between routes from the same neighboring AS. Routes from different ASes ignore MED — that's by design.
انٹرویو سوالاتInterview Q&AInterview Q&A
❓ BGP best-path selection کے پہلے پانچ مراحل بتائیں۔BGP best-path selection ke pehle paanch marahil batayein.Name the first five steps of BGP best-path selection.
1) سب سے زیادہ Weight، 2) سب سے زیادہ Local-preference، 3) locally originated راستہ، 4) سب سے چھوٹا AS-path، 5) سب سے کم origin code (IGP < EGP < incomplete)۔1) Sab se zyada Weight, 2) sab se zyada Local-preference, 3) locally originated rasta, 4) sab se chhota AS-path, 5) sab se kam origin code (IGP < EGP < incomplete).1) Highest Weight, 2) highest Local-preference, 3) locally originated route, 4) shortest AS-path, 5) lowest origin code (IGP < EGP < incomplete).
❓ Weight اور Local-preference میں کیا فرق ہے؟Weight aur Local-preference mein kya farq hai?What is the difference between Weight and Local-preference?
Weight صرف اسی راؤٹر پر اثر ڈالتی ہے (Cisco-specific، کہیں advertise نہیں ہوتی)۔ Local-preference پورے AS میں iBGP کے ذریعے پھیلتی ہے۔ دونوں میں زیادہ قدر جیتتی ہے۔Weight sirf usi router par asar dalti hai (Cisco-specific, kahin advertise nahi hoti). Local-preference poore AS mein iBGP ke zariye phelti hai. Dono mein zyada qadar jeetti hai.Weight affects only the local router (Cisco-specific, never advertised). Local-preference propagates across the whole AS via iBGP. Higher wins in both.