BGP Attributes ad Path Selectio ISP Traiig Workshops 1
BGP Attributes The tools available for the job 2
What Is a Attribute?... Next Hop AS Path MED...... p Part of a BGP Update p Describes the characteristics of prefix p Ca either be trasitive or o-trasitive p Some are madatory 3
AS-Path p Sequece of ASes a route has traversed p Madatory trasitive attribute p Used for: Loop detectio Applyig policy AS 300 AS 200 AS 100 170.10.0.0/16 180.10.0.0/16 180.10.0.0/16 300 200 100 170.10.0.0/16 300 200 AS 400 150.10.0.0/16 AS 500 180.10.0.0/16 300 200 100 170.10.0.0/16 300 200 150.10.0.0/16 300 400 4
AS-Path (with 16 ad 32-bit ASNs) p Iteret with 16-bit ad 32-bit ASNs 32-bit ASNs are 65536 ad above p AS-PATH legth maitaied AS 300 AS 80000 AS 70000 170.10.0.0/16 180.10.0.0/16 180.10.0.0/16 300 23456 23456 170.10.0.0/16 300 23456 AS 400 150.10.0.0/16 AS 90000 180.10.0.0/16 300 80000 70000 170.10.0.0/16 300 80000 150.10.0.0/16 300 400 5
AS-Path loop detectio AS 200 AS 100 170.10.0.0/16 180.10.0.0/16 AS 300 140.10.0.0/16 140.10.0.0/16 500 300 170.10.0.0/16 500 300 200 180.10.0.0/16 300 200 100 170.10.0.0/16 300 200 140.10.0.0/16 300 AS 500 p 180.10.0.0/16 is ot accepted by AS100 as the prefix has AS100 i its AS-PATH this is loop detectio i actio 6
Next Hop 150.10.1.1 150.10.1.2 AS 200 150.10.0.0/16 A ebgp B ibgp AS 300 C 150.10.0.0/16 150.10.1.1 160.10.0.0/16 150.10.1.1 AS 100 160.10.0.0/16 p p p ebgp address of exteral eighbour ibgp NEXT_HOP from ebgp Madatory o-trasitive attribute 7
ibgp Next Hop 120.1.1.0/24 Loopback 120.1.254.2/32 B AS 300 A ibgp 120.1.2.0/23 C D Loopback 120.1.254.3/32 p p Next hop is ibgp router loopback address Recursive route look-up 120.1.1.0/24 120.1.254.2 120.1.2.0/23 120.1.254.3 8
Third Party Next Hop AS 200 120.68.1.0/24 150.1.1.3 150.1.1.1 150.1.1.2 B AS 205 A C 150.1.1.3 120.68.1.0/24 AS 201 p p p p ebgp betwee Router A ad Router B ebgp betwee Router B ad Router C 120.68.1/24 prefix has ext hop address of 150.1.1.3 this is used by Router A istead of 150.1.1.2 as it is o same subet as Router B More efficiet p No extra cofig eeded 9
Next Hop Best Practice p Cisco IOS default is for exteral ext-hop to be propagated uchaged to ibgp peers This meas that IGP has to carry exteral ext-hops Forgettig meas exteral etwork is ivisible With may ebgp peers, it is uecessary extra load o IGP p ISP Best Practice is to chage exteral ext-hop to be that of the local router eighbor x.x.x.x ext-hop-self 10
Next Hop (Summary) p IGP should carry route to ext hops p Recursive route look-up p Uliks BGP from actual physical topology p Use ext-hop-self for exteral ext hops p Allows IGP to make itelliget forwardig decisio 11
Origi p Coveys the origi of the prefix p Historical attribute Used i trasitio from EGP to BGP p Trasitive ad Madatory Attribute p Iflueces best path selectio p Three values: IGP, EGP, icomplete IGP geerated by BGP etwork statemet EGP geerated by EGP icomplete redistributed from aother routig protocol 12
Aggregator p Coveys the IP address of the router or BGP speaker geeratig the aggregate route p Optioal & trasitive attribute p Useful for debuggig purposes p Does ot ifluece best path selectio p Creatig aggregate usig aggregate-address sets the aggregator attribute: router bgp 100 aggregate-address 100.1.0.0 255.255.0.0 13
Local Preferece AS 100 160.10.0.0/16 AS 200 AS 300 D 500 800 E 160.10.0.0/16 500 > 160.10.0.0/16 800 A AS 400 B C 14
Local Preferece p No-trasitive ad optioal attribute p Local to a AS oly Default local preferece is 100 (IOS) p Used to ifluece BGP path selectio determies best path for outboud traffic p Path with highest local preferece wis 15
Local Preferece p Cofiguratio of Router B: router bgp 400! eighbor 120.5.1.1 remote-as 300 eighbor 120.5.1.1 route-map local-pref i route-map local-pref permit 10 match ip address prefix-list MATCH set local-preferece 800 route-map local-pref permit 20! ip prefix-list MATCH permit 160.10.0.0/16 16
Multi-Exit Discrimiator (MED) 120.68.1.0/24 2000 > 120.68.1.0/24 1000 AS 200 C D 120.68.1.0/24 2000 A B 120.68.1.0/24 1000 120.68.1.0/24 AS 400 17
Multi-Exit Discrimiator p Iter-AS o-trasitive & optioal attribute p Used to covey the relative preferece of etry poits determies best path for iboud traffic p Comparable if paths are from same AS bgp always-compare-med allows comparisos of MEDs from differet ASes p Path with lowest MED wis p Absece of MED attribute implies MED value of zero (RFC4271) 18
Determiistic MED p IOS compares paths i the order they were received Leads to icosistet decisios whe comparig MED p Determiistic MED Cofigure o all bgp speakig routers i AS Orders paths accordig to their eighbourig ASN Best path for each eighbour ASN group is selected Overall bestpath selected from the wiers of each group router bgp 100 bgp determiistic-med 19
MED & IGP Metric p IGP metric ca be coveyed as MED set metric-type iteral i route-map p eables BGP to advertise a MED which correspods to the IGP metric values p chages are moitored (ad re-advertised if eeded) every 600s p bgp dyamic-med-iterval <secs> 20
Multi-Exit Discrimiator p Cofiguratio of Router B: router bgp 400! eighbor 120.5.1.1 remote-as 200 eighbor 120.5.1.1 route-map set-med out route-map set-med permit 10 match ip address prefix-list MATCH set metric 1000 route-map set-med permit 20! ip prefix-list MATCH permit 120.68.1.0/24 21
Weight p Not really a attribute local to router p Highest weight wis p Applied to all routes from a eighbour eighbor 120.5.7.1 weight 100 p Weight assiged to routes based o filter eighbor 120.5.7.3 filter-list 3 weight 50 22
Weight Used to help Deploy RPF AS4 C Lik to use for most traffic from AS1 AS4, LOCAL_PREF 200 B Backup lik, but RPF still eeds to work A AS1 AS4, LOCAL_PREF 100, weight 100 p p Best path to AS4 from AS1 is always via B due to localpref But packets arrivig at A from AS4 over the direct C to A lik will pass the RPF check as that path has a priority due to the weight beig set If weight was ot set, best path back to AS4 would be via B, ad the RPF check would fail 23
Aside: What is urpf? FIB: 172.16.1.0/24 fa0/0 192.168.1.0/24 se0/1 src=172.16.1.1 src=192.168.1.1 fa0/0 router se0/1 p Router compares source address of icomig packet with FIB etry If FIB etry iterface matches icomig iterface, the packet is forwarded If FIB etry iterface does ot match icomig iterface, the packet is dropped 24
Weight Used for traffic policy AS4 C Lik to use for most customer traffic from AS1 AS4, LOCAL_PREF 200 AS7 D A B AS1 Router A customers have best path to AS7 AS4, LOCAL_PREF 100, weight 100 p p Best path to AS4 from AS1 is always via B due to localpref But customers coected directly to Router A use the lik to AS7 as best outboud path because of the high weight applied to routes heard from AS7 If the A to D lik goes dow, the the Router A customers see best path via Router B ad AS4 25
Commuity p Commuities are described i RFC1997 Trasitive ad Optioal Attribute p 32 bit iteger Represeted as two 16 bit itegers (RFC1998) Commo format is <local-asn>:xx 0:0 to 0:65535 ad 65535:0 to 65535:65535 are reserved p Used to group destiatios Each destiatio could be member of multiple commuities p Very useful i applyig policies withi ad betwee ASes 26
Commuity Example (before) Peer AS1 X 100.10.0.0/16 permit 100.10.0.0/16 i permit 160.10.0.0/16 out permit 170.10.0.0/16 out D AS 300 E ISP 1 F Upstream AS 400 permit 160.10.0.0/16 i C permit 170.10.0.0/16 i AS 100 A 160.10.0.0/16 B AS 200 170.10.0.0/16 27
Commuity Example (after) Peer AS1 X 100.10.0.0/16 100.10.0.0/16 300:9 160.10.0.0/16 300:1 170.10.0.0/16 300:1 D AS 300 E ISP 1 F Upstream AS 400 160.10.0.0/16 300:1 C 170.10.0.0/16 300:1 AS 100 A 160.10.0.0/16 B AS 200 170.10.0.0/16 28
Well-Kow Commuities p Several well kow commuities www.iaa.org/assigmets/bgp-well-kow-commuities p o-export 65535:65281 do ot advertise to ay ebgp peers p o-advertise 65535:65282 do ot advertise to ay BGP peer p o-export-subcofed 65535:65283 do ot advertise outside local AS (oly used with cofederatios) p o-peer 65535:65284 do ot advertise to bi-lateral peers (RFC3765) 29
No-Export Commuity 105.7.0.0/16 105.7.X.X o-export 105.7.X.X A D 105.7.0.0/16 AS 100 AS 200 B E G p p p C AS100 aouces aggregate ad subprefixes Itetio is to improve loadsharig by leakig subprefixes Subprefixes marked with o-export commuity Router G i AS200 does ot aouce prefixes with oexport commuity set F 30
No-Peer Commuity 105.7.0.0/16 105.7.X.X o-peer upstream D 105.7.0.0/16 C&D&E are peers e.g. Tier- 1s C A upstream 105.7.0.0/16 E B upstream p Sub-prefixes marked with o-peer commuity are ot set to bi-lateral peers They are oly set to upstream providers 31
What about 4-byte ASNs? p Commuities are widely used for ecodig ISP routig policy 32 bit attribute p RFC1998 format is ow stadard practice ASN:umber p Fie for 2-byte ASNs, but 4-byte ASNs caot be ecoded p Solutios: Use private ASN for the first 16 bits Wait for http://datatracker.ietf.org/doc/draft-ietf-idras4octet-extcomm-geeric-subtype/ to be implemeted 32
Summary Attributes i Actio Router6>sh ip bgp BGP table versio is 16, local router ID is 10.0.15.246 Status codes: s suppressed, d damped, h history, * valid, > best, i - iteral, r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, x best-exteral, a additioal-path, c RIB-compressed, Origi codes: i - IGP, e - EGP,? - icomplete RPKI validatio codes: V valid, I ivalid, N Not foud Network Next Hop Metric LocPrf Weight Path *>i 10.0.0.0/26 10.0.15.241 0 100 0 i *>i 10.0.0.64/26 10.0.15.242 0 100 0 i *>i 10.0.0.128/26 10.0.15.243 0 100 0 i *>i 10.0.0.192/26 10.0.15.244 0 100 0 i *>i 10.0.1.0/26 10.0.15.245 0 100 0 i *> 10.0.1.64/26 0.0.0.0 0 32768 i *>i 10.0.1.128/26 10.0.15.247 0 100 0 i *>i 10.0.1.192/26 10.0.15.248 0 100 0 i *>i 10.0.2.0/26 10.0.15.249 0 100 0 i *>i 10.0.2.64/26 10.0.15.250 0 100 0 i... 33
BGP Path Selectio Algorithm Why is this the best path? 34
BGP Path Selectio Algorithm for Cisco IOS: Part Oe 1. Do ot cosider path if o route to ext hop 2. Do ot cosider ibgp path if ot sychroised (Cisco IOS) 3. Highest weight (local to router) 4. Highest local preferece (global withi AS) 5. Prefer locally origiated route 6. Shortest AS path 35
BGP Path Selectio Algorithm for Cisco IOS: Part Two 7. Lowest origi code IGP < EGP < icomplete 8. Lowest Multi-Exit Discrimiator (MED) If bgp determiistic-med, order the paths by AS umber before comparig If bgp always-compare-med, the compare for all paths Otherwise MED oly cosidered if paths are from the same AS (default) 36
BGP Path Selectio Algorithm for Cisco IOS: Part Three 9. Prefer ebgp path over ibgp path 10. Path with lowest IGP metric to ext-hop 11. For ebgp paths: If multipath is eabled, istall N parallel paths i forwardig table If router-id is the same, go to ext step If router-id is ot the same, select the oldest path 37
BGP Path Selectio Algorithm for Cisco IOS: Part Four 12. Lowest router-id (origiator-id for reflected routes) 13. Shortest cluster-list Cliet must be aware of Route Reflector attributes! 14. Lowest eighbour address 38
BGP Attributes ad Path Selectio ISP Traiig Workshops 39