45
© 2007 Cisco Systems, Inc. All rights reserved. UKNOF 8 1 BGP Best Practices Philip Smith <[email protected]> UKNOF 8 17th September 2007 Goodenough College, London

BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

Embed Size (px)

Citation preview

Page 1: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 1

BGP Best Practices

Philip Smith <[email protected]>UKNOF 817th September 2007Goodenough College, London

Page 2: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 2

Deploying BGP

The role of IGPs and iBGP

Aggregation

Receiving Prefixes

Configuration Tips

Page 3: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 3

The role of IGP and iBGP

Ships in the night?OrGood foundations?

Page 4: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 4

BGP versus OSPF/ISIS

Internal Routing Protocols (IGPs)Examples are ISIS and OSPFUsed for carrying infrastructure addressesNOT used for carrying Internet prefixes or customer prefixesISP design goal is to minimise number of prefixes in IGP to aidscalability and rapid convergence

Page 5: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 5

BGP versus OSPF/ISIS

BGP used internally (iBGP) and externally (eBGP) iBGP used to carry

some/all Internet prefixes across backbonecustomer prefixes

eBGP used toexchange prefixes with other ASesimplement routing policy

eBGP is NOT the same as iBGP

Page 6: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 6

BGP/IGP model used in ISP networks

Model representation

IGP

iBGP

IGP

iBGP

IGP

iBGP

IGP

iBGP

eBGP eBGP eBGP

Page 7: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 7

BGP versus OSPF/ISIS

DO NOT:distribute BGP prefixes into an IGPdistribute IGP routes into BGPuse an IGP to carry customer prefixes

YOUR NETWORK WILL NOT SCALE

Page 8: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 8

Injecting prefixes into iBGP

Use iBGP to carry customer prefixesDon’t ever use IGP

Point static route to customer interface Enter network into BGP process

Ensure that implementation options are used so that the prefixalways remains in iBGP, regardless of state of interfacei.e. avoid iBGP flaps caused by interface flaps

Page 9: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 9

Aggregation

Quality or Quantity?

Page 10: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 10

Aggregation

Aggregation means announcing the address blockreceived from the RIR to the other ASes connected toyour network

Subprefixes of this aggregate may be:Used internally in the ISP networkAnnounced to other ASes to aid with multihoming

Unfortunately too many people are still thinking aboutclass Cs, resulting in a proliferation of /24s in theInternet routing table

Page 11: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 11

Aggregation

Address block should be announced to the Internet asan aggregate

Subprefixes of address block should NOT beannounced to Internet unless traffic engineering whenmultihoming

Aggregate should be generated internallyNot on the network borders!

Page 12: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 12

Announcing an Aggregate

ISPs who don’t and won’t aggregate are held in poorregard by community

Registries publish their minimum allocation sizeAnything from a /20 to a /22 depending on RIRDifferent sizes for different address blocks

No real reason to see anything longer than a /22 prefixin the Internet

BUT there are currently >120000 /24s!

Page 13: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 13

AS100customer

100.10.10.0/23Internet

100.10.10.0/23100.10.0.0/24100.10.4.0/22…

Aggregation – Example

Customer has /23 network assigned from AS100’s /19 address block

AS100 announces customers’ individual networks to the Internet

Page 14: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 14

Customer link returnsTheir /23 network is nowvisible to their ISPTheir /23 network is re-advertised to peersStarts rippling through InternetLoad on Internet backbonerouters as network isreinserted into routing tableSome ISP’s suppress the flapsInternet may take 10-20 min orlonger to be visibleWhere is the Quality ofService???

Customer link goes downTheir /23 network becomesunreachable/23 is withdrawn from AS100’siBGP

Their ISP doesn’t aggregate its/19 network block

/23 network withdrawalannounced to peersstarts rippling through theInternetadded load on all Internetbackbone routers as networkis removed from routing table

Aggregation – Bad Example

Page 15: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 15

AS100customer

100.10.10.0/23

100.10.0.0/19aggregate

Internet

100.10.0.0/19

Aggregation – Example

Customer has /23 network assigned from AS100’s /19 address block

AS100 announced /19 aggregate to the Internet

Page 16: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 16

Aggregation – Good Example

Customer link goes downtheir /23 network becomesunreachable/23 is withdrawn from AS100’siBGP

/19 aggregate is still beingannounced

no BGP hold down problemsno BGP propagation delaysno damping by other ISPs

Customer link returns

Their /23 network is visibleagain

The /23 is re-injected intoAS100’s iBGP

The whole Internet becomesvisible immediately

Customer has Quality ofService perception

Page 17: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 17

Aggregation – Summary

Good example is what everyone should do!Adds to Internet stabilityReduces size of routing tableReduces routing churnImproves Internet QoS for everyone

Bad example is what too many still do!Why? Lack of knowledge?Laziness?

Page 18: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 18

The Internet Today (September 2007)

Current Internet Routing Table StatisticsBGP Routing Table Entries 230291Prefixes after maximum aggregation 120032Unique prefixes in Internet 111045Prefixes smaller than registry alloc 122198/24s announced 121356

only 5708 /24s are from 192.0.0.0/8ASes in use 26164

Page 19: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 19

BGP Report(bgp.potaroo.net)

199336 total announcements in October 2006 129795 prefixes

After aggregating including full AS PATH infoi.e. including each ASN’s traffic engineering

35% saving possible

109034 prefixesAfter aggregating by Origin AS

i.e. ignoring each ASN’s traffic engineering10% saving possible

Page 20: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 20

Efforts to Improve Aggregation

The CIDR ReportInitiated and operated for many years by Tony BatesNow combined with Geoff Huston’s routing analysis

www.cidr-report.orgResults e-mailed on a weekly basis to most operations listsaround the worldLists the top 30 service providers who could do better ataggregating

RIPE Routing WG aggregation recommendationRIPE-399 — http://www.ripe.net/ripe/docs/ripe-399.html

Page 21: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 21

Efforts to Improve AggregationThe CIDR Report

Also computes the size of the routing table assumingISPs performed optimal aggregation

Website allows searches and computations ofaggregation to be made on a per AS basis

Flexible and powerful tool to aid ISPsIntended to show how greater efficiency in terms of BGP tablesize can be obtained without loss of routing and policyinformationShows what forms of origin AS aggregation could be performedand the potential benefit of such actions to the total table sizeVery effectively challenges the traffic engineering excuse

Page 22: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 22

Page 23: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 23

Page 24: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 24

Page 25: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 25

Receiving Prefixes

Page 26: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 26

Receiving Prefixes

There are three scenarios for receiving prefixes fromother ASNs

Customer talking BGPPeer talking BGPUpstream/Transit talking BGP

Each has different filtering requirements and need to beconsidered separately

Page 27: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 27

Receiving Prefixes:From Customers

ISPs should only accept prefixes which have beenassigned or allocated to their downstream customer

If ISP has assigned address space to its customer, thenthe customer IS entitled to announce it back to his ISP

If the ISP has NOT assigned address space to itscustomer, then:

Check the five RIR databases to see if this address space reallyhas been assigned to the customerThe tool: whois - look the address up!!

Page 28: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 28

Receiving Prefixes:From Peers

A peer is an ISP with whom you agree to exchangeprefixes you originate into the Internet routing table

Prefixes you accept from a peer are only those they haveindicated they will announcePrefixes you announce to your peer are only those you haveindicated you will announce

Page 29: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 29

Receiving Prefixes:From Peers

Agreeing what each will announce to the other:Exchange of e-mail documentation as part of the peeringagreement, and then ongoing updatesOR

Use of the Internet Routing Registry and configuration toolssuch as the IRRToolSet

www.isc.org/sw/IRRToolSet/

Page 30: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 30

Receiving Prefixes:From Upstream/Transit Provider

Upstream/Transit Provider is an ISP who you pay togive you transit to the WHOLE Internet

Receiving prefixes from them is not desirable unlessreally necessary

Traffic engineering when multihoming

Ask upstream/transit provider to either:originate a default-routeOR

announce one prefix you can use as default

Page 31: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 31

Receiving Prefixes:From Upstream/Transit Provider

If necessary to receive prefixes from any provider, careis required

don’t accept RFC1918 etc prefixesftp://ftp.rfc-editor.org/in-notes/rfc3330.txt

don’t accept your own prefixesdon’t accept default (unless you need it)don’t accept prefixes longer than /24

Check Project Cymru’s list of “bogons”http://www.cymru.com/Documents/bogon-list.html

Page 32: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 32

Receiving Prefixes

Paying attention to prefixes received from customers,peers and transit providers assists with:

The integrity of the local networkThe integrity of the Internet

Responsibility of all ISPs to be good Internet citizens

Page 33: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 33

Configuration Tips

Of passwords, tricks and templates

Page 34: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 34

iBGP and IGPsReminder!

Make sure loopback is configured on routeriBGP between loopbacks, NOT real interfaces

Make sure IGP carries loopback /32 address

Consider the DMZ nets:Use unnumbered interfaces?Use next-hop-self on iBGP neighboursOr carry the DMZ /30s in the iBGPBasically keep the DMZ nets out of the IGP!

Page 35: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 35

iBGP: Next-hop-self

BGP speaker announces external network to iBGPpeers using router’s local address (loopback) as next-hop

Used by many ISPs on edge routersPreferable to carrying DMZ /30 addresses in the IGPReduces size of IGP to just core infrastructureAlternative to using unnumbered interfacesHelps scale networkMany ISPs consider this “best practice”

Page 36: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 36

Limiting AS Path Length

Some BGP implementations have problems with longAS_PATHS

Memory corruptionMemory fragmentation

Even using AS_PATH prepends, it is not normal to seemore than 20 ASes in a typical AS_PATH in theInternet today

The Internet is around 5 ASes deep on averageLargest AS_PATH is usually 16-20 ASNs

Page 37: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 37

Limiting AS Path Length

Some announcements have ridiculous lengths of AS-paths:

*> 3FFE:1600::/24 22 11537 145 12199 1031810566 13193 1930 2200 3425 293 5609 5430 13285 693914277 1849 33 15589 25336 6830 8002 2042 7610 i

This example is an error in one IPv6 implementation*> 194.146.180.0/22 2497 3257 29686 16327 1632716327 16327 16327 16327 16327 16327 16327 1632716327 16327 16327 16327 16327 16327 16327 1632716327 16327 16327 i

This example shows 20 prepends (for no obvious reason)

If your implementation supports it, consider limiting themaximum AS-path length you will accept

Page 38: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 38

BGP TTL “hack”

Implement RFC3682 on BGP peeringsNeighbour sets TTL to 255Local router expects TTL of incoming BGP packets to be 254No one apart from directly attached devices can send BGPpackets which arrive with TTL of 254, so any possible attack bya remote miscreant is dropped due to TTL mismatch

ISP AS 100Attacker

TTL 254

TTL 253 TTL 254R1 R2

Page 39: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 39

BGP TTL “hack”

TTL Hack:Both neighbours must agree to use the featureTTL check is much easier to perform than MD5(Called BTSH – BGP TTL Security Hack)

Provides “security” for BGP sessionsIn addition to packet filters of courseMD5 should still be used for messages which slip through theTTL hackSee www.nanog.org/mtg-0302/hack.html for more details

Page 40: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 40

Templates

Good practice to configure templates for everythingVendor defaults tend not to be optimal or even very useful forISPsISPs create their own defaults by using configuration templates

eBGP and iBGP examples followAlso see Project Cymru’s BGP templates

www.cymru.com/Documents

Page 41: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 41

iBGP TemplateExample

iBGP between loopbacks!

Next-hop-selfKeep DMZ and external point-to-point out of IGP

Always send communities in iBGPOtherwise accidents will happen

Hardwire BGP to version 4Yes, this is being paranoid!

Page 42: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 42

iBGP TemplateExample continued

Use passwords on iBGP sessionNot being paranoid, VERY necessaryIt’s a secret shared between you and your peerIf arriving packets don’t have the correct MD5 hash, they areignoredHelps defeat miscreants who wish to attack BGP sessions

Powerful preventative tool, especially when combinedwith filters and the TTL “hack”

Page 43: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 43

eBGP TemplateExample

BGP dampingDo NOT use it unless you understand the impactDo NOT use the vendor defaults without thinking

Remove private ASes from announcementsCommon omission today

Use extensive filters, with “backup”Use as-path filters to backup prefix filtersKeep policy language for implementing policy, rather than basicfiltering

Use password agreed between you and peer on eBGPsession

Page 44: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 44

eBGP TemplateExample continued

Use maximum-prefix trackingRouter will warn you if there are sudden increases in BGP tablesize, bringing down eBGP if desired

Limit maximum as-path length inbound

Log changes of neighbour state…and monitor those logs!

Make BGP admin distance higher than that of any IGPOtherwise prefixes heard from outside your network couldoverride your IGP!!

Page 45: BGP Best Practices - UKNOF · BGP versus OSPF/ISIS Internal Routing Protocols ... BGP Report (bgp.potaroo.net) ... Check Project Cymru’s list of “bogons

© 2007 Cisco Systems, Inc. All rights reserved.UKNOF 8 45

Summary

Use configuration templates

Standardise the configuration

Be aware of standard “tricks” to avoid compromise ofthe BGP session

Anything to make your life easier, network less prone toerrors, network more likely to scale

It’s all about scaling – if your network won’t scale, thenit won’t be successful