177
Intro to BGP Intro to BGP All-Day All-Day Tutorial Tutorial Avi Freedman Avi Freedman [email protected] [email protected]

Intro to BGP All-Day Tutorial Avi Freedman [email protected]

Embed Size (px)

Citation preview

Page 1: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Intro to BGPIntro to BGPAll-DayAll-DayTutorialTutorial

Avi FreedmanAvi Freedman

[email protected]@netaxs.com

Page 2: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Index

• Internet Connectivity Overview

• Multihoming Concepts

• Multihoming Without BGP

• Multihoming - Address Space Complications

Page 3: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Index

• Basic BGP - The BGP Route

• Basic BGP - Inserting Routes into BGP

• Basic BGP - Advertising Routes

• Basic BGP - Other BGP Route Attributes

• Basic BGP - Selecting Routes

Page 4: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Index

• Multihoming with BGP - an Introduction

• Interlude - Hardware for BGP

• Multihoming with BGP with a Cheap Router

• Multihoming with BGP - Taking Just Customer Routes

• Multihoming with BGP - Taking Full Routes

• Default Routing in BGP

Page 5: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Internet Internet ConnectivityConnectivity

OverviewOverview

Page 6: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Having Internet ConnectivityHaving Internet Connectivity

• To have complete Internet connectivity you must be able to reach all destinations on the net.

• Your packets have to get delivered to every destination. This is easy (default routes).

• Packets from everywhere else have to “find you”. This is done by having your ISP(s) advertise routes for you.

Page 7: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Multihoming Multihoming WithoutWithout

BGPBGP

Page 8: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Multihoming Without BGPMultihoming Without BGP

• To get Internet connectivity, you can just default route your traffic to your upstream providers.

• To get traffic back from the Internet, you need to have your providers tell all of the rest of the Internet “where you are”.

Page 9: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

BGP Route Advertisement (1)BGP Route Advertisement (1)

• Think of a BGP route as a “promise”.• If I advertise 207.8.128.0/17, I promise that if

you deliver traffic to me for anywhere in 207.8.128.0/17, I know how to deliver it at least as well as anyone else.

• If my customer has 207.8.140.0/24, I generally will not announce that route separately since it is covered by my 207.8.128.0/17 aggregate route.

Page 10: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

BGP Route Advertisement (2)BGP Route Advertisement (2)

• By making sure these routes, or “promises”, are heard by ALL providers on the ‘net, your provider ensures a return path for all of your packets.

• Remember, sending packets OUT is easier than getting them back.

• Also, remember - sending routes OUT causes IP traffic to come IN.

Page 11: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

BGP Route Advertisement (3)BGP Route Advertisement (3)

• But the most specific route wins, so if one of my customers’ ISPs is advertising 207.8.240.0/24, all incoming traffic from other networks will start flowing in that pipe.

• So I must “punch a hole” in my aggregate announcement and advertise 207.8.128.0/17 and 207.8.240.0/24.

Page 12: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

BGP Route Advertisement (4)BGP Route Advertisement (4)

• The complete set of routes advertised by all BGP speakers on the net is about 55,000 routes as of 10/98.

• If your route is missing in the “view” of any major provider, you will not have connectivity to them.

Page 13: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Multihoming Multihoming Without BGP -Without BGP -How it WorksHow it Works

Page 14: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Customer Side - OutboundCustomer Side - Outbound

• All you need to do is to put in static default route(s). To prefer two upstreams equally:– ip route 0.0.0.0 0.0.0.0 s4/0– ip route 0.0.0.0 0.0.0.0 s4/1

• To use one link as a backup only for outbound packtes:– ip route 0.0.0.0 0.0.0.0 s4/0– ip route 0.0.0.0 0.0.0.0 s4/1 10– why? S4/1 could be a 56k or backup link

Page 15: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Cisco Load BalancingCisco Load Balancing• The way Ciscos (except for big new ones running

“CEF”) work if there are two “equal-cost” routes to the same place is -– Option 1 - Round-robin the packets without “route

caching”. This goes through the slowest sections of the router’s OS. Bad. Also, if you are connected to different ISPs, packets can arrive out of order, etc…

– Option 2 - Use route caching (default). Traffic to the same dest IP will always use the same interface, until the cache entry expires.

Page 16: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Customer Side - InboundCustomer Side - Inbound

• Just tell your ISP what address space you are bringing, if any.

• Your ISP may allocate you space out of their larger address blocks.

• If so, they need to announce your space “more specifically”.

• But you do no work other than tell your ISP what to do.

Page 17: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Provider Side (1)Provider Side (1)

• If both providers don’t advertise your routes with the same specificity, you might have -– netaxs saying “4969 sez 207.8.128.0/17”– uunet saying “701 sez 207.8.195.0/24”

• Bad, because almost all traffic on the ‘net will come into you via UUNET.

• {note} - talk about address filters

Page 18: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Provider Side (2)Provider Side (2)• What you need is -

– netaxs saying “4969 sez 207.8.128.0/17”– netaxs saying “4969 sez 207.8.195.0/24”– uunet saying “701 sez 207.8.195.0/24”

• Good, because -– 1) Because the two 207.8.195.0/24 routes are of the same

specificity, providers CAN choose btwn netaxs and uunet to get to you; and

– 2) For some people who don’t listen to /24s and such in new address space, they still have the 207.8.128.0/17 route to use to get to you.

Page 19: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Address Space ComplicationsAddress Space Complications• So, in the case of -

– netaxs saying “4969 sez 207.8.128.0/17”

– netaxs saying “4969 sez 207.8.195.0/24”

– uunet saying “701 sez 207.8.195.0/24”

• “Some people won’t listen to the /24, so what happens if my netaxs connection goes down?”

• Not a problem!!! Because netaxs will hear the UUNET /24. Sprint send traffic to netaxs; netaxs to uunet; and uunet to you.

Page 20: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Disadvantages of Disadvantages of not using BGPnot using BGP

• You gain a bit more control of your destiny when you speak BGP yourself. You can break up your routes in an emergency, or to tune traffic. You can “pad” your announcements to de-prefer one or more upstreams.

• Also, you lose the ability to fine-tune outbound traffic flow to the “best” upstream.

Page 21: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Why BGP?Why BGP?

• BGP is a multi-vendor “open” protocol with multiple implementations, all mostly interoperable. It is the only actively used EGP on the Internet.

• The main design feature of BGP was to allow ISPs to richly express their routing policy, both in selecting outbound paths and in announcing internal routes. Keep this in mind as we progress.

Page 22: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

What is BGP?What is BGP?

Page 23: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

BGP is … (1)BGP is … (1)

• An Exterior Gateway Protocol (EGP), used to propagate tens or hundreds of thousands of routes between networks (ASs).

• The only protocol used to do this on the Internet today.

Page 24: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

BGP is … (2)BGP is … (2)

• The Border Gateway Protocol, currently Version 4 - defined in RFC 1771, and extended (with additional optional attributes) in other RFCs.

• A “distance-vector” routing protocol, running over TCP port 179.

• Supports modern “classless” routing. BGP3, RIPv1, and some others do NOT.

Page 25: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Purpose of BGPPurpose of BGP

Page 26: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Purpose of BGPPurpose of BGP

• To allow networks to tell other networks about routes (parts of the IP address space) that they are “responsible” for.

• Using “route advertisements”, or “promises” - also called “NLRI” or “network-layer reachability information”.

• Networks are “Autonomous Systems”.

• Identified in BGP by a number, called the ASN (“Autonomous System Number”)

Page 27: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

BasicBasicBGPBGP

ConceptsConcepts

Page 28: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Basic BGP Concepts (1)Basic BGP Concepts (1)• BGP exchanges routes between ASs.

• When routes are exchanged, ASNs are stamped on the routes *on the way out* - adding one “AS hop” per network traversed. (0-65535)

• No concept of pipe size, internal router hop-count, congestion - in some sense BGP treats all ASs the same.

• ASs allow administrative debugging, “policy” routing, and *loop detection*.

Page 29: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

BGP AND ASNsBGP AND ASNs

AS 4969

AS 5000

AS 6461

AS 701

AS 12001

Page 30: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Basic BGP Concepts (2)Basic BGP Concepts (2)

• Routes are exchanged over “peering sessions”, which run on top of TCP.

• Keepalives are used to avoid needed to re-send the whole table periodically.

• The routes are “objects”, or “bags” of “attributes” - really mini-databases.

• BGP is actually two protocols - iBGP, designed for internal routing, and eBGP, designed for external routing.

Page 31: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Basic BGP Concepts (3)Basic BGP Concepts (3)

• There is only one “best” BGP route for any given IP block at one time.

• This “best” BGP route is not always the route that gets “installed” into the router’s RIB/FIB.

• Once a session comes up, all best-routes are exchanged. Then over time, just “topology updates” are exchanged.

• You can ONLY exchange “best” routes.

Page 32: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Basic BGP Concepts (4)Basic BGP Concepts (4)

• Policy– The Internet was a strange place before the

modern commercial Internet evolved in 1992-1993.

– Some networks had policies about what kind of traffic they would carry.

– BGP was designed to allow network operators to make routing decisions based on whatever “policy” they wanted (or HAD) to use.

Page 33: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

CISCO DIAGRAM -RIBFIBETC

Page 34: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Basic BGP Concepts -Basic BGP Concepts -The BGP RouteThe BGP Route

andandRoute AttributesRoute Attributes

Page 35: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

The BGP RouteThe BGP Route

• A BGP “route” is a “bag” of objects, or “attributes”.

• The “prefix” is the section of address space being advertised. A prefix consists of:– A starting point (i.e. 207.8.128.0)– A netmask (i.e. /24, aka 255.255.255.0)

Page 36: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

What Is an Attribute?What Is an Attribute?

• A BGP message consists of a prefix and information about that prefix (i.e., local-pref, med, next-hop, originator, etc...). Each piece of information is encoded as an attribute in a TLV (type-length-value) format. The attribute length is 4 bytes long, and new attributes can be added by simply appending a new attribute.

• Attributes can be transitive or non-transitive, some are mandatory.

Next Next HopHop

AS AS PathPath

............MEDMED......

Page 37: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Next Hop AttributeNext Hop Attribute

• Next-hop IP address to

reach a network.

• Router A will advertise 198.3.97.0/24 to router B with a next-hop of 207.240.24.202.

• With IBGP, the next-hop does not change.

• IGPs should carry route to next-hops, using intelligent forwarding decision.

AS 6201

AS 3847

198.3.97.0/24A

B

207.240.24.200/30

.201

A

B

.202

C

Page 38: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Next Hop SelfNext Hop Self

AS701 AS3561

AS3847

AA BB

CCDD AS1

198.32.184.19

198.32.184.116198.32.184.42

198.32.184.56

Page 39: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

• Sequence of AS(s) a route has traversed.

• Provides a mechanism for loop detection.

• Policies may be applied

based on AS path.

• Local AS added only when

send to external peer.

*Shortest AS path preferred

AS Path Attribute (1)AS Path Attribute (1)

AS3847207.240.0.0/16 AS1673

140.222.0.0/16

AS701192.67.95.0/24

AS3561204.70.0.0/15

192.67.95.0/24 3847 701 i140.222.0.0 3847 1673 i204.70.0.0/15 3847 3561 i207.240.0.0/16 3847 i

AS6201

E

C

FG

D

B

A

Page 40: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

• Sprint is 1239; UUNET is 701; Net Access is 4969.

• When pattern-matching, or regexping, AS_PATHS, ^ means “match beginning”, and $ means “match end”.

• The null AS-Path is ^$ - if the AS-Path is null, the BGP route originated inside the same AS.

AS Path Attribute (2)AS Path Attribute (2)

Page 41: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

• ^1239 4969$ is how a Sprint customer would see a Net Access route.

• ^1239 4969 11023$ is how a Sprint customer would see a Net Access BGP customer’s route.

• ^4969 11023$ is how Sprint itself sees that same route.

AS Path Attribute (3)AS Path Attribute (3)

Page 42: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

• Indication to external peers of the preferred path into an AS.

• Affects routes with same AS path.

• Advertised to external neighbors

• Usually based on IGP metric

* Lowest MED preferred

Multi-Exit Discriminator (MEDMulti-Exit Discriminator (MED)

Page 43: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

MED Attribute (2)MED Attribute (2)• The MED (multi-exit discriminator) is a

commonly used attribute. It comes after the AS_PATH in evaluation, and thus isn’t quite as much of a “hammer” as local-pref.

• Commonly, MED is used to tack a distance on BGP routes as they move within your network.

• NSPs advertise MEDs to each other to let it be known which POP the route is “closest” to.

Page 44: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

• Applies on a AS path basis

• Current aggregation schemes significantly lessen value.

MED Attribute MED Attribute (3)(3)

+40+40

+20+20

+5+5

Page 45: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Origin AttributeOrigin Attribute

• One of the mandatory, but minor, attributes of a BGP route is the origin. It is one of (in order of preference):– IGP (i) (from a network statement)– EGP (e) (from an external peer)– Unknown (?) (from IGP redistribution)

• It can be re-set, but that is not often done.• It is almost-last in the selection algorithm.

Page 46: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Weight AttributeWeight Attribute

• Cisco proprietary, not part of any spec.

• Local to router.

• Value 0-65535 (default if originated by

router - 32768, other - 0)

* Highest weight preferred

Page 47: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Weight Attribute (ctd)Weight Attribute (ctd)

• Weight is rarely used. It overrides almost all other attributes in the decision path, and is local to a specific router - it is never sent to other routers, even ones inside your ASN.

• Usually used for temporary “I-don’t-have-time-to-think-about-it” fixes.

Page 48: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Local Preference AttributeLocal Preference Attribute

• Local to AS• Used to influence BGP path selection• Default 100* Highest local-pref preferred

AS 6201

208.1.1.0/24

A B

208.1.1.0/24 100Preferred by all AS3847 routers

208.1.1.0/24 80

AS 3847

GF E

C D

Page 49: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Local-Pref Attribute (2)Local-Pref Attribute (2)

• An often-used attribute, local-pref (normally 100) overrides AS_PATH, and is transitive throughout your network. It is never advertised to an eBGP peer.

• For example, you can express the policy “prefer private interconnects” by making the local_pref be 150 and leaving all other peers at 100.

• Best used as an intermediate-level knob.

Page 50: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

iBGPiBGPvs.vs.

eBGPeBGP

Page 51: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

iBGP vs. eBGPiBGP vs. eBGP

• BGP is very strange. It is promiscuous with external routes, making it very easy for you to become “MAE-Clueless”, yet it makes it very hard to advertise routes thoroughly inside your network.

• iBGP sessions are established when peering with the same AS; eBGP otherwise.

• Same protocols; different route install rules.• YOU MUST STRONGLY FILTER ALL eBGP

SESSIONS!

Page 52: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

iBGPiBGPAS 3847

When BGP speakers in the same AS form a BGP connection for the purpose of exchanging routinginformation, they are said to be running IBGP or internal BGP.

IBGP speakers are usually fully-meshed.

B

A

c

Page 53: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

eBGP (1)eBGP (1)AS 3561

AS 3847

When BGP speakers in different ASs form a BGP connection for the purpose of exchanging routinginformation, they are said to be running EBGP or external BGP.

EBGP peers are usually directly connected.

B

A

Page 54: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

eBGP (2)eBGP (2)

AS 2033

AS 4200

AS 7007

AS 2041

Page 55: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

iBGP and eBGP DiagramiBGP and eBGP Diagram

AS 7007XP

AS 1239

AS 6079

AS 701

AS 4006

Page 56: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

eBGP RuleseBGP Rules• By default, only talks to directly-connected router.

• Sends the one best BGP route for each destination.

• Sends all of the important “attributes”; omits the “local preference” attribute.

• Adds (prepends) the speaker’s ASN to the “as-path” attribute.

• Usually rewrites the “next-hop” attribute.

Page 57: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

iBGP RulesiBGP Rules

• Can talk to routers many hops away by default.

• Can only send routes it “injects”, or routes heard DIRECTLY from an external peer.

• Thus, requires a FULL mesh.

• Sends all attributes.

• Leaves the as-path attribute alone.

• Doesn’t touch the “next hop” attribute.

Page 58: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Logical view of 16 routers, fully Logical view of 16 routers, fully meshedmeshed

Page 59: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

iBGP Restriction (1)iBGP Restriction (1)

Assume AS1239 sends route 10.0.0.0/8 to AS2828. Router A will send that route to Routers B and C.

AS 2828AS 1239A

B

C

Page 60: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

iBGP Restriction (2)iBGP Restriction (2)

When Router B receives 10.0.0.0/8, it will not propagate that route to Router C because it was learned from an iBGP neighbor. Router C will behave similarly.

AS 2828AS 1239A

B

C

Page 61: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

iBGP and next-hop (1)iBGP and next-hop (1)

Furthermore, the Next Hop for 10.0.0.0/8 will be the serial interface on the AS1239 router, even in Router B’s and Router C’s forwarding table.

AS 2828AS 1239A

B

C

Page 62: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

iBGP and next-hop (2)iBGP and next-hop (2)

• With iBGP, next-hop is not a router directly connected.

• So a “recursive lookup” is needed.

• After the next-hop is found, a second lookup is made to figure out how to send the packet “in the direction” of the next-hop.

Page 63: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Basic BGP ConceptsBasic BGP ConceptsInserting RoutesInserting Routes

into BGPinto BGP

Page 64: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Inserting Routes into BGP (1)Inserting Routes into BGP (1)

• How do routes get into BGP? They have to come from somewhere. You have to insert routes into BGP, and someone had to insert external routes that you get into BGP somewhere else in the first place.

• Two main ways:– network statements (like static BGP routes)– redistributing from OSPF, static, etc...

Page 65: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Inserting Routes into BGP (2)Inserting Routes into BGP (2)

• network statements– “network x.y.z.q [mask a.b.c.d]”– MUST have an EXACTLY-matching IGP route

- specificity must be an exact match– Doesn’t scale beyond 200 or so network

statements per routers; not a problem, though.– Makes scaling easier when you have to support

multi-homed customers

Page 66: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Inserting Routes into BGP (3)Inserting Routes into BGP (3)• aggregate-address statements

– “aggregate-address x.y.z.q a.b.c.d [aggregate-only] [suppress-map XXX]”

– (Really a relative of the network statement)– Brings up the given network if there are any more

specific BGP routes for the prefix specified.– Usually used with aggregate-only to suppress more

specifics.– Usually used in conjunction with redistribution.

Page 67: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Inserting Routes into BGP (4)Inserting Routes into BGP (4)

• Redistribution– ALWAYS redistribute through an address

filter! Otherwise you will have crud in your BGP!

– Examples later on...

• Default route is a special case. More soon.

Page 68: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Basic BGPBasic BGPAdvertising RoutesAdvertising Routes

Page 69: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

BGP Peering Sessions (1)BGP Peering Sessions (1)

• BGP Routes are exchanged inside of BGP peering sessions.

• BGP uses TCP to ensure reliable delivery of routing updates.

• If a TCP session dies, all associated routes must be withdrawn.

• BGP peers, or neighbors, must be specified explicitly. This is a good thing.

Page 70: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

BGP Peering Sessions (2)BGP Peering Sessions (2)• Once a peering session is set up:

– Both sides flood the other end with all of their best BGP routes. VERY IMPORTANT - there is one best route per prefix, and that is the route that is advertised. BGP can only advertise routes that are eligible for use or routing loops can occur.

– Then, periodic updates send new routes and/or withdraw old ones, and keepalives are sent every N seconds.

– On a very stable network,very little or no traffic should flow besides keepalives.

Page 71: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Peering - BGP State MachinePeering - BGP State Machine

• There is a state machine that describes the setting up, use, and tearing down of BGP sessions. It’s useful to know the states because Cisco uses them to describe session state.

• Idle -> Connect -> Active {send “startup” packet} -> OpenSent -> OpenConfirm {wait for ack} -> Established [ … -> Idle]

• In “sho ip bgp summ”, “Active” does NOT mean Active, it means “waiting” - FYI.

Page 72: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Peering - Processing RoutesPeering - Processing Routes

• For each route received:– If it’s a valid route AND passes any filters, it must

be put into the BGP routing table.– Then, unless it is replacing a duplicate, a best-path

computation must be run on all candidate BGP routes of the same prefix.

– Then, if the best route changed, the RIB and/or FIB must be updated.

– This process is done for ALL incoming BGP routes.

Page 73: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Filtering BGP Routes -Filtering BGP Routes -BGP Policy ControlBGP Policy Control

Page 74: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

BGP Policy ControlBGP Policy Control

• To decide what routes can and can’t go to various other routers, you can “filter” using:– “distribute lists” (“prefix filters”) - lists of routes– “filter lists” (“as-path filters”) - lists of regular

expressions matching or denying ASs– “route maps” (“BGP Basic programs”) that allow

you to match and change most BGP attributes

Page 75: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

• Per neighbor access list applied to BGP routes

• Inbound or outbound

• Based upon network numbers

Distribute List (1)Distribute List (1)

Page 76: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Distribute List (2)Distribute List (2)

router bgp 3847 neighbor 207.240.8.246 remote-as 8130 neighbor 207.240.8.246 distribute-list 127 in neighbor 207.240.8.246 distribute-list 101 out

access-list 127 permit ip host 207.19.74.0 host 255.255.255.0access-list 127 permit ip host 208.198.100.0 host 255.255.252.0access-list 127 permit ip host 208.204.80.0 host 255.255.252.0access-list 127 permit ip host 208.212.249.0 host 255.255.255.0access-list 127 permit ip host 207.240.120.0 host 255.255.255.0access-list 127 permit ip host 208.220.144.0 host 255.255.248.0access-list 127 permit ip host 208.225.192.0 host 255.255.240.0access-list 127 deny ip any any ! explicit deny if not specified

Page 77: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Distribute List Distribute List (3)(3)

access-list 10 deny ip 10.0.0.0 0.255.255.255 access-list 10 deny ip 127.0.0.0 0.255.255.255access-list 10 deny ip 128.0.0.0 0.0.255.255access-list 10 deny ip 172.16.0.0 0.15.255.255access-list 10 deny ip 191.255.0.0 0.0.255.255access-list 10 deny ip 192.0.2.0 0.0.0.255access-list 10 deny ip 192.168.0.0 0.0.255.255access-list 10 deny ip 223.255.255.0 0.0.0.255access-list 10 deny ip 224.0.0.0 31.255.255.255access-list 10 deny ip 207.240.0.0 0.0.3.255access-list 10 permit ip any

A sanity filter like this keeps your table neat and prevents you from advertising crud to your peers.

Page 78: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

• Filter routes both inbound and outbound based on value of AS path attribute.

• Called “as-path” access, or filter, lists.

• Configuration router bgp 3847 neighbor 207.240.10.100 remote-as 2900 neighbor 207.240.10.100 distribute-list 100 in neighbor 207.240.10.100 distribute-list 101 out neighbor 207.240.10.100 filter-list 10 in

ip as-path access-list 10 permit ^2900$ ip as-path access-list 10 deny .*

Filter List (1)Filter List (1)

Page 79: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Cisco Regular Expressions (1)Cisco Regular Expressions (1)

. Period matches any single character, including white space.

* Asterisk matches 0 or more sequences of the pattern.

+ Plus sign matches 1 or more sequences of the pattern.

? Question mark matches 0 or 1 occurrences of the pattern

Page 80: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Cisco Regular Expressions (2)Cisco Regular Expressions (2)

^ Caret matches the beginning of the input string.

$ Dollar sign matches the end of the input string.

_ Underscore matches a comma (,), left brace ({), right brace (}) left parenthesis, right parenthesis, the beginning or end of the input string, or a space.

Page 81: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Cisco Regular Expressions (3)Cisco Regular Expressions (3)

[] Square brackets designate a range of single character patterns.

- Hyphen separates the endpoints of a range.

As you may have noticed, these are much like standard vi regular expressions.

Page 82: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Applying AS Path FilteringApplying AS Path Filtering

3847

6201

D

A

C

BE

701

F

6202

G

The following configuration could be used on router B to accept routes from AS6201 & 6202 and deny all others.

ip as-path access-list 10 permit ^6201$ip as-path access-list 10 permit ^6201_6202$ip as-path access-list 10 deny .*

Page 83: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

• 3 default lists

• (Permit all; Deny all; Permit only our routes)

ip as-path access-list 1 permit .*

ip as-path access-list 2 deny .*

ip as-path access-list 3 permit ^$

netaxs AS-Path ACLsnetaxs AS-Path ACLs

Page 84: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Route Maps (1)Route Maps (1)

Route-maps are cisco’s mechanism to select and modify routes with if/then style algorithms.

Route-maps are used for more than just BGP in a cisco router, such as traffic shaping and policy routing.

Page 85: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Route Maps (2)Route Maps (2)

Route-maps follow this format:

route-map <name> <per|deny> <#>

[match statements]

[set satements]

[repeat with unique sequence numbers as needed]

Page 86: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Route Maps (3)Route Maps (3)

Route-maps follow this format:

route-map <name> <per|deny> <#>

[match statements]

[set satements]

[repeat with unique sequence numbers as needed]

Page 87: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Route Maps (4)Route Maps (4)

For route-maps with the keyword “permit”, if the prefix being examined passes the match statement, the set commands are executed and the route-map is exited.

If the match statement is not passed, the next sequence number is executed.

If there are no more sequence numbers, the prefix is filtered/dropped.

Page 88: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Route Maps (5)Route Maps (5)

For route-maps with the keyword “deny”, if the prefix being examined passes the match statement, the prefix in question is filtered and no more sequence numbers are executed.

If the prefix does not pass the match statements, the next sequence number is executed.

Page 89: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Basic BGPBasic BGPSelecting RoutesSelecting Routes

Page 90: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Selecting BGP RoutesSelecting BGP Routes

• Usually there will be 2, 3, 4, etc… ways to get to a given destination, all of which are represented by BGP routes.

• There is a way of picking the “best” one.

• Most important note - – Selection is NOT random between “similar” routes.– You can ALWAYS figure out why something is

happening if you understand the rules.

Page 91: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Selecting BGP Routes - BasicSelecting BGP Routes - Basic

• ALWAYS find the most specific route.

• ONLY consider paths w/ reachable NEXT_HOPs.

• Prefer a route originated on the local rtr.

• Then, unless tuning has been done, pick the route with the shortest AS-PATH; then origin code; select on MED; then router ID.

• Or, if weight, LOCAL_PREF is set, or padding done to AS_PATH, look at those.

Page 92: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

BGP Decision AlgorithmBGP Decision Algorithm

• Do not consider IBGP path if not synchronized

• Do not consider path if no route to next hop

• Highest weight (local to router)

• Highest local preference (global within AS)

• Prefer local route

• Shortest AS path

• Lowest origin code IGP < EGP < incomplete

• Lowest MED

• Prefer EBGP path over IBGP path

• Path with shortest next-hop metric wins

• Lowest router-id

Page 93: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

HardwareHardwareforfor

BGPBGP

Page 94: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Router Vendors (1)Router Vendors (1)

• cisco (affectionately called Crisco)

• Bay Networks (called Bad Networks)

• Livingston (called Lucington)

• Ascend (pronounced ASS-END)

• PC router w/ unix and gated

Page 95: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Router Vendors (2)Router Vendors (2)

• Cisco rules the backbone router market. Everyone runs Cisco code, so everyone hits the same bugs.

• Bay is next-biggest, but not really catching up. Have their own working BGP implementation, but takes them a while to add new features. Major disadvantage - GUI interface. Command-line is coming but not yet.

Page 96: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Router Vendors (3)Router Vendors (3)

• Livingston has a BGP implementation, and though it isn’t feature-ful, it basically works and is efficient (but only supports t1-speed routing).

• Ascend runs gated and is nasty. They barely understand bridging. You have to reboot their routers to reload a config.

Page 97: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Router Vendors (4)Router Vendors (4)

• The gated consortium, run by merit, puts out a program capable of running OSPF and BGP (among other protocols). Put on a Unix box, it turns it into a router of sorts.– Disadvantages -

• spinning hard disk

• “bgp assembly language”

• poor documentation/support

Page 98: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Cisco ProductsCisco Products• Can’t run full BGP -

– 2501 - 68030, 25mhz, 16mb ram max– 4000/4000M/4500, 16-32mb max

• Can run full BGP -– 2600 - risc,64mb max - < 3k– 3620/3640 - risc, 64/128mb max 3-10k– 4500M/4700 - risc, 64/128mb max 5-10k– 7206 - risc, 128mb max 12-30k– 7000 - motorola, 64mb max 4-30k– 7500 - risc, dist switch, 128mb max 15-70k– GSR/BFR - “anything you want” 30-120k

Page 99: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Multihoming with BGPMultihoming with BGPAn IntroductionAn Introduction

Page 100: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Step 1 - Determine PolicyStep 1 - Determine Policy

• “You go find out what they want; we’ll start programming the routers” doesn’t work well.

• Before you step up to the router, determine what routing policy you want to express with your configuration.

• Plan your configuration, and ask how it could put you (in an unwelcome light) on the nanog mailing list.

Page 101: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Policy for Basic Multi-HomingPolicy for Basic Multi-Homing

• We want to advertise our routes - all of them, but only OUR routes. So, assemble a list of our routes and masks.

• We want to accept all routes and let the router sort them out, initially based on AS-PATH length. If we don’t have enough memory to take full routes, we’ll start off taking none and then play later.

Page 102: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Warning - I am Blackholio (1)Warning - I am Blackholio (1)

• Never blackhole someone.

• Say www.uu.net is 137.239.5.24, and the best match for that IP is the prefix 137.239.0.0/16.

• What happens if you announce 137.239.5.0/24, by accident or on purpose?

• Worldcom’s lawyers show up at your doors and you look like an idiot.

Page 103: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Warning - I am Blackholio (2)Warning - I am Blackholio (2)

• What happens if you have a T1 to Sprint and a T1 to UUNET, and you announce Sprint routes to UUNET? (Assume no sanity filters at the upstream, which is always a good assumption).

• Answer - you have become MAE-Clueless, and all of UUNET tries to get to Sprint through your T1.

• Why?

Page 104: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Warning - I am Blackholio (3)Warning - I am Blackholio (3)

• As your provider, I have to believe that your route is the best way to get to a given prefix.

• Why? Because otherwise I can’t transit you - I can only send routes to the other providers on the Internet if I believe they are the best ones.

Page 105: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Multihoming -Multihoming -Minimal BGPMinimal BGP

(for cheap routers)(for cheap routers)

Page 106: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Insert Static Default RoutesInsert Static Default Routes

• Insert static default routes, either load-balanced or with primary/backup, as per non-BGP multihoming.

• Eitherip route 0.0.0.0 0.0.0.0 s4/0

ip route 0.0.0.0 0.0.0.0 s4/1

• Orip route 0.0.0.0 0.0.0.0 s4/0

ip route 0.0.0.0 0.0.0.0 s4/1 250

Page 107: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Gather NetworksGather Networks

• Routes– 207.8.200.0/22

– 198.69.44.0/24

• Holdup routes keep the routes in BGP so they don’t “flap”. “Flapping” can blackhole you.

• Then, build access-list and holdup routesaccess 55 permit 207.8.200.0 0.0.3.255

access 55 permit 198.69.44.0 0.0.0.255

ip route 207.8.200.0 255.255.252.0 null0 250

ip route 198.69.44.0 255.255.255.0 null0 250

Page 108: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Set up BGP Base ConfigSet up BGP Base Config

ip as access 1 permit .*

ip as access 2 deny .*

ip as access 3 permit ^$

router bgp 22222

no sync

net 207.8.200.0 mask 255.255.252.0

net 198.69.44.0 mask 255.255.255.0

Page 109: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Configuring Neighbors - NoteConfiguring Neighbors - Note

• The best way to configure a neighbor is to use cut-and-paste, or to tftpboot a snippet or whole config.

• You have 30-60 seconds to type in the whole neighbor clause before the session could come up and start receiving and sending routes - WITHOUT FILTERS if you didn’t type fast enough...

Page 110: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Neighbor Configuration (1)Neighbor Configuration (1)

router bgp 22222

neigh 207.106.2.45 descr transit to netaxs

neigh 207.106.2.45 remote-as 4969

neigh 207.106.2.45 next-hop-self

neigh 207.106.2.45 version 4

neigh 207.106.2.45 dist 55 out

neigh 207.106.2.45 filter 3 out

neigh 207.106.2.45 filter 2 in

Page 111: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Neighbor Configuration (2)Neighbor Configuration (2)

router bgp 22222

neigh 10.40.4.81 descr transit to UUNET

neigh 10.40.4.81 remote-as 701

neigh 10.40.4.81 next-hop-self

neigh 10.40.4.81 version 4

neigh 10.40.4.81 dist 55 out

neigh 10.40.4.81 filter 3 out

neigh 10.40.4.81 filter 2 in

Page 112: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Test itTest it

• Do a “sho ip bgp”. Only your 2 routes should show.

• Do a “show ip bgp neigh <neighip> adv”. You should show that you are advertising those 2 routes to your 2 neighbors.

• Go to nitrous.digex.net or another BGP looking glass, to see that the routes are being advertised under your AS, not the provider’s, and that both paths are there.

Page 113: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Multihoming with BGP -Multihoming with BGP -Taking Customer RoutesTaking Customer Routes

(an intermediate solution)(an intermediate solution)

Page 114: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Taking Just Customer RoutesTaking Just Customer Routes

• One option in-between default routing and taking full BGP is to at least take customer routes from each provider.

• This way, you’ll be able to make some intelligent decisions, which can be especially important for news feeding and dns and mail exchange optimization.

• If your provider isn’t Sprint or CW, you can probably fit “customer” routes in 16mb.

Page 115: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Taking Just Customer Routes (2)Taking Just Customer Routes (2)

• The best plan is to get your provider to advertise their customer routes ONLY to you. Still, use the KGB motto - “Trust, but verify”.

• Doesn’t work on small routers if your upstream is MCI or UU.

• Or, community-based filtering (more later).

Page 116: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Taking Just Customer Routes (3)Taking Just Customer Routes (3)

• So, a sanity filter:ip as acc 10 deny _701_

ip as acc 10 deny _1239_

ip as acc 10 deny _3561_

ip as acc 10 deny _1673_

ip as acc 10 deny _1_

ip as acc 10 permit .*

• (Prevent hearing routes from the big boys - eve)

Page 117: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Taking Just Customer Routes (4)Taking Just Customer Routes (4)

router bgp 22222

neigh 207.106.2.45 descr transit to netaxs

neigh 207.106.2.45 remote-as 4969

neigh 207.106.2.45 next-hop-self

neigh 207.106.2.45 version 4

neigh 207.106.2.45 distribute 55 out

neigh 207.106.2.45 filter 3 out

neigh 207.106.2.45 filter 10 in

Page 118: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Multihoming with BGP -Multihoming with BGP -Taking Full RoutesTaking Full Routes

Page 119: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

PolicyPolicy

• Actually, very easy.

• Continue to advertise your routes, as before.

• Take full routing info.

• Later on, you can tune if you find that as-path is not a good indicator to some sites.

Page 120: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

So, what Policy?So, what Policy?

• We’ll do the same thing on advertisement, but we’ll take all routes from both upstreams.

Page 121: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Configuring Full BGPConfiguring Full BGP

• Router bgp 22222– neigh 207.106.2.45 remote-as 4969– neigh 207.106.2.45 next-hop-self– neigh 207.106.2.45 version 4– neigh 207.106.2.45 distribute 55 out– neigh 207.106.2.45 filter 3 out– neigh 207.106.2.45 filter 1 in

Page 122: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Logistics ofLogistics ofbecomingbecoming

MultihomedMultihomed

Page 123: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Multihoming LogisticsMultihoming Logistics

• Address space.

• Redundant connectivity during switch.

• Test configs.

• Bring up outbound BGP first.

Page 124: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Multihoming to theMultihoming to thesame Providersame Provider

Page 125: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Multihoming to the same ProviderMultihoming to the same Provider

• Same configs as being multi-homed, except that as-paths will be the same from your upstream, and your routes will be the same in their network.

• Need some way of preferring. Either:– Send more specifics and MEDs, and take MEDs– Play w/ route-maps and set some set of routes

higher through one POP than another

Page 126: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

The Network Grows -The Network Grows -Supporting BGP CustomersSupporting BGP Customers

Page 127: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Supporting BGP Customers (1)Supporting BGP Customers (1)

• So you’ve built a fine, redundant network. And others are willing to buy from you.

• Setting up neighbor sessions is the easy part.

• Determine your policy.

• Filter EVERY route you hear from a downstream customer, no matter how they bitch. Can you say “blackholio”?

Page 128: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Supporting BGP Customers (2)Supporting BGP Customers (2)

• You’ll need to add all customer prefixes to that access-list 55 you use for controlling your own outbound.

• You’ll need to keep modifying as-path access-list 3 to add the ASNs of your downstreams.

• This gets tedious.

Page 129: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Supporting BGP Customers (3)Supporting BGP Customers (3)

ip as acc 3 permit ^$

ip as acc 3 permit ^22111$

ip as acc 3 permit ^22111 7007 30111$

etc...

• Doesn’t scale at some point.

• Solution? Communities...

Page 130: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Hot Potato Hot Potato vs.vs.

Hop-by-HopHop-by-HopRoutingRouting

Page 131: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Hot Potato RoutingHot Potato Routing

• Most providers try to hand off traffic destined to the outside as soon as possible.

• Even if someone else’s network is bad.

• This will typically be the default behavior - IF you re-set the MED on inbound routes.

• If not, you will do “Cold Potato” routing - sending routes cross-country on your network for UUNET’s other-coastal custs.

Page 132: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Quickie on Route-Maps

• Route-maps are used to match and set attributes of routes. They are a little logic flow of ANDs and NOT ANDs.

• Like a little basic program; evaluated in order of the sequence number.

• At the end of evaluation, if a route has been permitted at some point, it passed.

• A route-map is ADDITIVE to other filters.

Page 133: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Implementing Communitiesip comm 4 permit 4969:123

ip comm 4 permit 4959:1200

ip comm 20 permit 4969:0

ip comm 21 permit 1239:1

ip comm 22 permit 1239:2

route-map tosprint deny 20

match comm 20

route-map tosprint permit 21

match comm 21

set as pre 4969

route-map tosprint permit 22

match comm 22

set as pre 4969 4969

route-map tosprint permit 30

match comm 4

Page 134: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Implementing Communities

route-map set-transit

match ip address 40

set comm 4969:1200 4969:666 additive

router bgp 22222

neigh <custip> route-map set-transit in

Page 135: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

TUNING INBOUND BGP ANNOUNCEMENTS

Page 136: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Inbound BGP Routes

• Inbound BGP routes make traffic go out. Having a route means that an outbound packet can use it as the basis for a forwarding decision (well, the router can).

• It is far easier to adjust outbound routing than inbound.

• Goal is generally to provide fastest, lowest-loss, path for all destinations.

Page 137: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Tuning Inbound BGP Routes

• Policy– Generally, to optimize throughput and latency.– Could be to squash traffic to certain providers,

though, depending on the time of night and state of mind of the network engineer in question.

– Or, to reduce transit cost.– Generally, though, it is to optimize connectivity

“quality”, whatever that is.

Page 138: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Tuning Inbound BGP Routes

• Many destinations that you tune make themselves known in the form of customer complaints.

• Otherwise, start focusing on the biggest providers (Sprint, UU, MCI/SW, ANS, ATT, BBN, ...).

Page 139: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Tuning Inbound BGP Routes

• Use traceroutes to determine connectivity.

• However, do the traceroute from the source IP of the provider you are testing.

• No problem - do it from the border router and the source IP will be that of the serial interface.

• So, just set a temporary static route to a given destination and trace away...

Page 140: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Tuning Inbound BGP Routes

• Once you identify better paths, use AS_PATH padding.

• Identify the providers in question.

• Pick out the relevant AS_PATH regexp.

• Build a route-map to apply inbound.

Page 141: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Tuning Inbound BGP Routes

• Simple route-mapip as acc 20 permit ^701 1673_

route-map inbound-uu permit 10

match as 20

set as pre 701 701

route-map inbound-uu permit 20

match as 1

• Always best to leave a specific match all at the end.

Page 142: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Tuning Inbound BGP Routes

• Other methods:

• We’ll talk about local_prefs later on...

Page 143: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

TUNING OUTBOUNDBGP ANNOUNCEMENTS

Page 144: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Tuning Outbound BGP

• This is harder, because all of the other networks implementing their own policies complicate your life.

• Your two main tools are:– Padding your outbound AS_PATHs– Deaggregating announcements

• And:– With a cooperative provider, using communities

Page 145: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Tuning Outbound - Padding

• When your router announces iBGP routes, it normally creates a 1-entry AS_PATH with your ASN. So, by adding one or more copy of your own ASN, you cause the providers who listen to that route to de-prefer it a bit (since the AS_PATH is now 1 longer, thus making it win less often).

Page 146: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Tuning Outbound - Padding

route-map pad-me-once

match as 1

set as prepend 22222

router bgp 22222

neigh 207.106.2.45 route-map pad-me-once out

Page 147: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Tuning Outbound - Communities

• If your providers are good (netaxs, above.net, some others), they’ll give you the ability to control your destiny with communities.

• For example, netaxs honors the communities:

Page 148: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Tuning Outbound - deagg.

• I have 207.106.128.0/17.I want to advertise 207.106.128.0/17 to spr and uu, and 207.106.128.0/18 to spr alone.

access 56 deny 207.106.128.0 0.0.63.255

access 56 <insert lines from access 55>

neigh <uunetip> dist 56 out

Page 149: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

PEERING WITH OTHER ISPS

Page 150: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Peering

• Networks should peer as widely as possible, for better interconnectivity. The more wide the peering, the more traffic you will use. This is a GOOD thing.

• Particularly, peering with local providers is a very good thing.

• If you are both in a frame or SMDS cloud, or in a room, peering makes sense...

Page 151: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

PEERING ANDnext-hop-self

Page 152: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

BGP: Next-hop-self

• By default, our friend Mr. Promiscuous Q. eBGP will pass on next-hops as imported

• So, if multiple routers are at a common XP, and one party is transitting another, you might accidentally send routes to a 3rd party which would cause them to send traffic to your transit customer instead of “bouncing” the packet off of you.

• Some people think transit over XPs is bad, but many do it as a backup-of-last-resort. If you do, watch your next-hops.

Page 153: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Next-Hop-Self Issues: Bad

XPAS 701192.41.177.241

AS 4969

192.41.177.87

AS 6666

192.41.177.4

10.10.10.0/24 6666 192.41.177.4Prefix AS-Path Next-hop

AS 6666 says to AS 4969:

AS 4969 says to AS 701:Prefix AS-Path Next-hop

10.10.10.0/24 4969 6666 192.41.177.4

Page 154: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Next-Hop-Self Issues: Better

XPAS 701192.41.177.241

AS 4969

192.41.177.87

AS 6666

192.41.177.4

10.10.10.0/24 6666 192.41.177.4Prefix AS-Path Next-hop

AS 6666 says to AS 4969:

AS 4969 says to AS 701:Prefix AS-Path Next-hop

10.10.10.0/24 4969 6666 192.41.177.87

Page 155: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

BACKUP TRANSIT

Page 156: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

STABLE BGP

Page 157: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Stable BGP

• Nail routes to loopback.• Watch out for flapping routes.• Sites think that if a site shows instability, it is

worth blackholing for some time (30-90 minutes) until it stabilizes.

• Dampening hurts.• How to escape from being dampened once

the underlying problem is fixed.

Page 158: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Stable BGP - Loopbacks

• Peering between loopbacks enhances stability, since loopbacks don’t go down.

• Also, good for load-balancing.

• Set up lo0, then

• “neigh x.y.z.q update-source looback0”

Page 159: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

BGP Stability - soft-reconfig• Instead of hammering a session to cause

reevaluation (“clear ip bgp” drops the TCP session), “clear ip bgp soft” can be used.

• “clear ip bgp x.y.z.q soft out” is low cpu; it issues withdrawls for all currently-advertised routes and recomputes and re-sends roues.

• “clear ip bgp x.y.z.q soft in” is high memory, as it needs to keep copy of all routes received.

Page 160: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

BGP DampeningBGP DampeningBGP dampening is used to minimize instability caused by route flapping and oscillation over the network. To accomplish this, values are defined to identify badly behaved routes. Genuity currently uses Cisco's default values which basically say 'flap 3 times in 15 minutes and your damped':

half-life 15 minutespenalty 1000suppress-value 2000reuse-value 750

But in time it can become a bit more complex. Each time a route flaps it gets a penalty (1000). If the cumulative penalty is greater than the suppress-value (2000, so 3 flaps), the advertisement of the route will be suppressed. The penalty will be exponentially decayed based on the half-life. Once the penalty decreases below the predefined reuse-value, the advertisement will be unsuppressed. The default maximum suppress time is 4 times the half-life. This ensures that if a route flaps a lot in a very short period but quickly becomes stable it's only suppressed for a maximum of 1 hour.

Route flap dampening is not applied to routes originated from the AS in which the router resides.

Page 161: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

eBGP Multihop

Page 162: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Why eBGP Multihop is BAD• Why do it?

– “I can’t afford a router to take full routes in the middle”

– “Tough luck. Find another job or get bought so you can”

• What are we talking about?– [7010, 64mb] <-> [2501, 16mb] <-> [4700, 64mb]

– 2501 defaults to 7010

– 7010 and 4700 speak eBGP multihop

• If you must:– neigh <remoteip> ebgp 5 [# of hops]

– REALIZE that you’re breaking one of the Fundamental Postulates of Active Routing - that every box in the middle knows (within a few seconds) how to get to a destination because it HAD to know in order to tell the box connected to it

• If someone puts a /24 route towards the 4700… Oh no..

Page 163: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Blackhole w/ eBGP Multihop

• One use - getting the real-time spam blackhole feed from Vixie and company.

• Take the routes from a remote site and set the next-hop on them to null0.

• Or, take the routes and set next-hop to one of your upstreams to avoid the blackhole effect.

Page 164: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

SUPPORTINGMULTI-HOMED

CUSTOMERS

Page 165: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Supporting Multi-Homed Custs

• What they need from you is routes to the ‘net, and some ability to be flexible in how they announce their routes.

• Routes to the ‘net - give them your communities (“neighbor x.y.z.q send-communities”). Publish your communities so they know what they mean. WARN if you change community semantics.

Page 166: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Supporting Multi-Homed Custs

• Be prepared to punch holes in your aggregates.– Using network statements, no problem.– Otherwise, be prepared to use aggregate-

address.

• Set up communities they can use to control which pipes you advertise them to.

Page 167: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

IGP REDISTRIBUTION

Page 168: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

SCALING WITHCONFEDERATIONS

Page 169: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

BGP Confederations

• Or “BGP done right”• Makes iBGP more promiscuous• How?

– Fully-mesh all BGP speakers at a POP– Use fake ASNs at each POP– Between POPs, use eBGP rules (send everything)– Within POPs, use iBGP rules– Preserve local_prefs between POPs

• ‘bgp confed identifier 4969’• ‘bgp confed peers 64512 64513 64514 64515’• put in extra confed peers up-front

Page 170: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Logical View of full 16-router Mesh

(kudos to danny@genuity)

Page 171: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Confederations

C

C

CC

C

C

C

C C

C C

C

C

AS 1239 AS 701

AS 4969

AS 64512

AS 64513AS 64514

Page 172: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

AS-Path filters for confederations

– ^$ Doesn’t work any more…– ^$ matches internal routes, but with

confederations your routes will look like:– ^(64512 64513)$ as well as ^$– ip as acc 55 deny ^(\([0-9 ]*\))*$

Page 173: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

SCALING WITHROUTE REFLECTORS

Page 174: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Route Reflector TerminologyRoute Reflector Terminology

Client is used to identify “client” of the RR(s).

Non-client identifies standard BGP peers.

Cluster is a group of clients under same RR(s).

Cluster-id unique identifier for a cluster.

Originator-id router-id of the originator of the route.

Page 175: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Other Issues

Page 176: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

Access-List 112: smd

– Deny 10.0.0.0/8, 172.16.0.0/16, 192.168.0.0/24– Permit <= /24s in 192/8-205/8.– Permit <= /19 in >= 206/8– Permit /16 in the old B-space– Permit <= /8 in the old A-space– Deny everything else

Page 177: Intro to BGP All-Day Tutorial Avi Freedman freedman@netaxs.com

CISCO CONFIGURATION