BGP calculates its metric through a series of attributes. There are two braod categories of attributes and also we can say that 4 subcategories :
Well known – These attributes must be supported by every BGP router that is compatible for the BGP routing protocol
- Mandatory – must be included in every single BGP routing update
- Origin – Tells how the route originated. It can be one of three values. IGP – „I“ (it originated from interior gateway protocol somehow), EGP – „E“ (Exterior Gateway Protocol – this is the old version of BGP not used anymore), Unknown – „?“ (The BGP has no idea where this route has come from. Most of the routes will show up as Unknown routes. The reason why is that everytime you redistribute some routes into the BGP, it instantly goes int the unknown Origin. IGP shows only in specific situation when you use for example „network“ command in BGP.)
- AS-PATH – has to be in every single update. Initially the AS-PATH of inserted route is empty. AS number is PREPENDED when route crosses AS BOUNDARY. This is also used as LOOP prevention in EBGP. This is also used as route selection criteria by default for EBGP. Less AS-HOPS the better.
- Next-Hop – another very critical attribute, has to be in every single update. It specify the next hop interface/IP address of EBGP router from which you received the routing update. So typically it is the IP address of sending router. However if 3 BGP routers are on the same ethernet segment and establish bgp session via the one central router (call it hub), next hop remains same when spoke updates hub and hub updates the other spoke. This is good in ethernet segment as the spoke can reach the other spoke directly. But this can cause problems when are in NBMA networks. Also in IBGP the next hop IP is not updated. Use the command next-hop self to update the next-hop IP.
- Discretionary (does not needs to be included in every BGP routing update)
- Local-Preference – gives you control over the preffered routes. Higher is Better. Lets say you have connection to two service provider. If you want to route most routes via service provider A but for some routes you want to use service provider B. So you want to select some routes from provider A and B and TAG them to be the preferred one towards that provider. So if both providers updates you with same network, you can control via which SP you route the network through the local preferrence. By default the SP with better AS-PATH for that route would win, but with local-preference you can tweak that 😉
- Atomic Aggregate – it just informs the Router that the route has been summarized.
Optional – does not need to be supported by all router manufactors to be compatible with BGP routing protocol. You may also develop your own optional attribute.
Transitivity is defined against peers by RFC 4271 (BGP). Transitivity is used to inform peer what to do if that peer doesnt recognize the attribute. In case its transitive the peer should send it to other peer. If its non-transitive the peer should not send it to other peer. This is the transitivity rule. However be ware that there might be specific rules for the attributes itself (like for MED). According to this princliple MED should be always sent to peer if recognized. However MED itself specify in RFC that it should not be sent to other EBGP peers if received from any EBGP peer.
- Transitive – ALLOWED to be sent to other peers if not recognized
- Aggregator – This attribute comes along with the Atomic Aggregate attribute. The Atomic aggreate tells you that route is summarized and this attribute tells you who did the aggregation. So this attribute designates the IP address of the router who performed the Summarization. You can then restrict that you will not accept routes from this aggregator for example.
- Community – used for the route tagging. The only way you are able to mark the routes are via community attributes. There are some well known community and some not so well known.
- NON-Transitive – are NOT allowed to be sent to other peers if not recognized
- Multi-Exit Discriminator – used to suggest an entry point into your AS. This is the closest attribute you ever get to break the golden rule of BGP which is what? Yeah dont tell me how to make my coffee 😀 In MED Lower is better. However by default you cannot influence the routing via this attribute because this is by default turned OFF. You need to explicitly configure that you will accept as a SP the MED attribute.
Weight – this is Cisco proprietary attribute. It does not belongs to any group of attribute. Its is just influencing the BGP decisions of local router. It gives you control of routes on the same router. It is not propagated to other routers even in the same AS. This does not influence the routing decisions of other routers! This attribute has local significance within one router.
Route Selection Criteria
- Next HOP
- Local Preference
- Originated by router – prefer paths that was locally originated via a network or aggregate BGP subcommand or through redistribution from an IGP.
- Origin code – IGP<EGP<?
- MED – lower is better
- Prefer external paths over internal paths