BGP Path Attributes III

Local_Pref

Category: Well-known discretionary
Preference: Highest value

The Local_Pref attribute is only used in updates between iBGP peers, it is not advertised to other (eBGP peers) AS’. The attribute defines a routers local preference for an advertised route. A router will compare the routes Local_Pref attributes if it receives different routes to the same destination over its iBGP peers. The route with the highes preference will be chosen. Cisco’s default is 100.

Local_Pref Configuration

Based on the diagram above, all interfaces, except the loopback interfaces, are configured for OSPF. The loopbacks itself will only be taken into BGP.
R4 receives R3s loopback network via R2 and R1. To set the path over R1 as the preferred path for R4 we are going to set a higher Local_Pref on R1. R2 should still use its direct peering to R3 so we only change the Local_Pref attribute for R3s loopback network on outgoing updates from R1 to R4.

R1:
router bgp 12
 no synchronization
 bgp log-neighbor-changes
 network 99.99.1.0 mask 255.255.255.0
 neighbor 116.1.12.2 remote-as 12
 neighbor 116.1.13.3 remote-as 3
 neighbor 116.1.14.4 remote-as 12
 neighbor 116.1.14.4 route-map LOCAL_PREF out
 no auto-summary
!
!
route-map LOCAL_PREF permit 10
 set local-preference 300
!
route-map LOCAL_PREF permit 20

The configuration works as the following commands show, R4 uses R1 to R3 while R2 still uses its direct peering:


R2#sh ip bgp
<pre>BGP table version is 6, local router ID is 99.99.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>i99.99.1.0/24     116.1.12.1               0    100      0 i
*> 99.99.2.0/24     0.0.0.0                  0         32768 i
*> 99.99.3.0/24     116.1.23.3               0             0 3 i
* i                 116.1.13.3               0    100      0 3 i
*>i99.99.4.0/24     116.1.24.4               0    100      0 i

R4#sh ip bgp
BGP table version is 5, local router ID is 99.99.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>i99.99.1.0/24     116.1.14.1               0    100      0 i
*>i99.99.2.0/24     116.1.24.2               0    100      0 i
* i99.99.3.0/24     116.1.23.3               0    100      0 3 i
*>i                 116.1.13.3               0    300      0 3 i
*> 99.99.4.0/24     0.0.0.0                  0         32768 i

Multi_Exit_Disc (MED)

Category: Optional nontransitive
Preference: Lowest value

MED is used to influence the incoming traffic. The attribute is used within eBGP updates and allows an AS to inform another AS which incoming path is preferred to reach the own AS. If an AS receives different routes to the same destination and the attributes are the same the router will compare the MED attribute to decide which path to take. Since the MED is seen as a metric the lowest value is chossen. The default is set to 0. The MED attribute is advertised inside the next AS via iBGP updates but it will not be advertised to another AS. A router will not compare the MED values if it receives two or more routes to the same destination but over different AS’.

MED is known as INTER_AS metric in BGP-2 and BGP-3

MED Configuration

The MED will be used to tell AS 12 that AS3 prefers the path over R1 for R3s loopback network, so we set the MED to 100 for updates to R2 and manually set it to 0 for updates to R1.

<pre>router bgp 3
 no synchronization
 bgp log-neighbor-changes
 network 99.99.3.0 mask 255.255.255.0
 neighbor 116.1.13.1 remote-as 12
 neighbor 116.1.13.1 route-map MED-R1 out
 neighbor 116.1.23.2 remote-as 12
 neighbor 116.1.23.2 route-map MED-R2 out
 no auto-summary
!
ip prefix-list R3-Lo0 seq 5 permit 99.99.3.0/24
!
route-map MED-R2 permit 10
 match ip address prefix-list R3-Lo0
 set metric 100
!
route-map MED-R2 permit 20
!
route-map MED-R1 permit 10
 match ip address prefix-list R3-Lo0
 set metric 0
!
route-map MED-R1 permit 20

R2 still receives the route to R3s loopback but prefers the way over R1 instead of using its own path to R3. R4 only gets the path via R1:

<pre>R2#sh ip bgp
BGP table version is 16, local router ID is 99.99.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>i99.99.1.0/24     116.1.12.1               0    100      0 i
*> 99.99.2.0/24     0.0.0.0                  0         32768 i
*>i99.99.3.0/24     116.1.13.3               0    100      0 3 i
*                   116.1.23.3             100             0 3 i
*>i99.99.4.0/24     116.1.24.4               0    100      0 i

R4#sh ip bgp
BGP table version is 13, local router ID is 99.99.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>i99.99.1.0/24     116.1.14.1               0    100      0 i
*>i99.99.2.0/24     116.1.24.2               0    100      0 i
*>i99.99.3.0/24     116.1.13.3               0    100      0 3 i
*> 99.99.4.0/24     0.0.0.0                  0         32768 i

Depending on the BGP implementation it might happen that there is no MED set per default, if additionally to that behavior the command bgp bestpath med missing-as-worst is used the MED will be set to the worst possible value (4’294’967’295) instead of 0. Based on that it is better to manually set the MED on bot/all peers.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s