Tuesday, November 8, 2011

Border Gateway Protocol (BGP)

Border Gateway Protocol (BGP) advertises, learns, and chooses the best paths inside the global Internet. 

Some key points:
  • Establishes a neighbor relationship before exchanging topology information with a neighbor router, like EIGRP and OSPF.
  • Does not require neighbors to be attached to the same subnet (Uses TCP port 179), unlike EIGRP or OSPF.
  • Uses path attributes, which will be described shortly, to determine the best route.
  • Emphasis is on scalability, not fast convergence as EIGRP and OSPF are.
  • Similar to distance vector
Path Attributes (PA) define information about a path, or route, through a network.  Unless the PAs have been manipulated, BGP defaults to use AS_Path as the default determinate for the best path.  The integer BGP ASN, or autonomous system number, is a unique identifier for each individual organization.  Each company whose Enterprise network connects to the internet can be considered to be an AS and can be assigned a BGP ASN.    In an attempt to describe how the AS_Path attribute works is as follows:

Because AS_Path can be used to choose the best route, over who has the shortest AS_PATH (Fewest number of ASNs listed), as each ASN advertises the routes they know about the AS_Path PA is manipulated.  For example: As ASN1 tells ASN2 about prefix 192.X.X.X, the AS_Path is simply 1.  When ASN2 tells ASN5 about the same prefix, the AS_Path is now 1,5.  One thing worth noting, is that when routers share information within an AS (iBGP), the AS_Path PA does not change--only when passing between different ASNs (eBGP).  Again, assuming no other PAs have been manipulated, BGP path selection uses the shortest AS_Path. 

Routing loop prevention:  Because each ASN includes its ASN when advertising a known prefix, it can prevent routing loops.  If an ASN receives an update, and a route advertisement lists an AS_Path with its own ASN, the router ignores the route. 

Because ASN numbers need to be unique, IANA administers the assignments of ASNs much like it does with IP address prefixes.  If they were to assign two organizations the same ASN, and one were to advertise its prefix, the BGP update would be ignored as part of the BGP loop prevention process.

When to use BGP over static routes?  Because having a default route is most beneficial when you have a single internet connection, once you have two, BGP allows you to choose one outbound path over another for particular destinations.  The alternative?  The ISP could configure static routes for the Enterprise's public IP addres prefix and then use BGP in the Internet to advertise those routes.  Also, you could simply use a default static route pointing towards the core of the network.  The WAN edge routers then need static routes for the subnets at each branch, with the WAN edge routers advertising these brange subnets into the core using an IGP. 

Different cases of internet connectivity:
  • Single Homed (1 link per ISP, 1 ISP)
    • Single link between the enterprise and the ISP (only one possible next-hop router for any and all routes destined for the internet).
    • Two options of implementing:
      • Default routes on the inside, and static for the Enterprise's public address range at the ISP).
      • Use BGP, but only to exchange a default and a route for the Enterprise's public prefix.
        • ISP router uses BGP to advertise a default route to the enterprise..IGP configured on Enterprise internet-facing router to flood a default route..BGP configured on the Enterprise router and advertise the Enterprise's public prefix towards the ISP.
  • Dual Homed (2+ links per ISP, 1 ISP)
    • This option gives the enterprise a choice!
    • Can manipulate EIGRP metrics or AD to create a preferred route.
    • Manipulate BGP PAs to create a preferred route (soon to follow..)
  • Single multihomed (1 link per ISP, 2+ ISP)
  • Dual multihomed (2+ links per ISP, 2+ ISP)
 External BGP

Requirements to form eBGP neighborships:
  • A local router's ASN must match the neighboring router's reference to that ASN with its neighbor remote-as <asn> command.
  • The BGP router IDs of the two routers must NOT be the same
    • How is the router ID chosen?
      Like EIGRP and OSPF, BGP follows these steps to choose the router ID:  Configured, highest loopback, highest other interface.  The syntax to hardcode the router ID is bgp router-id <rid>
  • If configured, MD5 authentication must pass.
    • Will fail if keys are incorrect, or if only one router configures authentication.  Syntax to configure authentication is neighbor <neighbor IP> password <key>.
  • An active TCP connection with the other router (read below for how this works..)
Step 1: Router A finds the neighbor 10.1.1.2 command, so Router A sends the BGP message for this neighbor inside a package with destination IP 10.1.12
Step 2. E1 looks in the IP routing table for the route that matches destination 10.1.1.2
Step 3. Route matched in Step 2 lists S0/0/0 as outgoing interface
Step 4: Router A's interface IP address for S0/0/0 is 10.1.1.1, so Router A uses 10.1.1.1 as its source IP address for this BGP peer.
Step 5: The neighbor command on the other router, must refer to Router A's source IP address (10.1.1.1 in this case). 

Because TCP uses a concept called a socket, which consists of a local TCP port number and an IP address, if the interface whose IP addres ised used by IP were to fail, then the TCP socket would fail, closing the TCP connection.  Using the example above, if S0/0/0 were to fail, the devices would loose connectivity. 
 How to avoid this?! Configure a loopback interface as the source of their single BGP TCP connection.  In the event that there are multiple links between the routers, and one interface were to fail, the loopback interface would remain up.  To accomplish this, setup a loopback interface, then initiate the command neighbor... update-source <interface-id> command. 

If you utilize the loopback interface as the source of the BGP TCP connection, you must also enable eBGP Multihop.  The purpose for this is that when building packets to send to an eBGP peer, IOS defaults to a TTL value of 1.  With a TTL value of 1, the packets will never arrive!  While it seems as if a router 1 hop away should work fine with a TTL of 1, the internal IOS packet forwarding logic decrements the TTL before giving the packet to the loopback interface!  For two devices directly connected, configuring the command neighbor ebgp-multihop 2 would solve this issue.

Keep in mind, because you are now using a loopback interface for BGP TCP connectivity, the two devices will no longer be "connected" and cannot realy on connected routes for forwarding packets.  You would need to either configure an IGP or static routes for this to work.

How does the ISP learn routes for the Enterprise's public IP address space?
  • Utilize the BGP network command
    • The IGP network command, which lists paramaters that the router comapres to all its interface IP address, and if it finds a match the router enables the IGRP routing protocol on that particular interface.  Unlike the IGP network command, BGP does not use the network command to enable BGP on interfaces.  It adds a prefix to the BGP table only if the exact prefix with that same mask exists in a router's routing table.  If a router does not have a route for an entire range (which is possible if that range has been subnetted), you can use a static route pointing towards null0.  When implementing the network <IP> mask <subnet mask>, if you omit the subnet mask, IOS will assume a classful network mask.
    • WTF is BGP auto-summary?  Unlike EIGRP, BGP defaults to no auto-summary.  If auto-summary is enabled, it will change how we interpret the network command listed above.  With auto-summary enabled, the router will add a route to the BGP table if the exact classful route is in the IP routing table, or if any subset routes of that classful network are int he routing table.  For instance, if you used the network 9.0.0.0 command and auto-summary were enabled, and if only a subset route exists (like 9.1.1.0/24) , but no route for exactly 9.0.0.0/8 were present, then the router still adds a route for the classful network to the BGP table. 
  • Redistribute from an IGP

No comments:

Post a Comment