MED attribute and “hot potato” routing


The purpose of this post is to demonstrates how to use the BGP Best path selection algorithm and manipulate BGP attribute MED (Multi-Exit Discriminator) in the outgoing advertisement traffic to influence the inbound traffic.

Let’s consider the topology depicted in Figure1 under the following conditions:

 -Router R7 is the route reflector and R6 and R5 route reflector clients.

– A full mesh iBGP is deployed inside AS65500 between BGP routers R1, R2, R3 and R4.

– Default EIGRP links costs are considered between routers.

– For internal connectivity EIGRP 1234 is the IGP for 65500 and EIGRP 567 is the IGP for 65501.

Figure 1: Lab topology

 

the network 192.168.10.0/24 is reachable from R7 through 2 paths:

R7:

R7#sh ip bgp 192.168.10.0

BGP routing table entry for 192.168.10.0/24, version 4

Paths: (2 available, best #2, table Default-IP-Routing-Table)

Flag: 0x800

  Advertised to update-groups:

     1

  65500, (Received from a RR-client)

    6.6.6.6 (metric 2297856) from 6.6.6.6 (6.6.6.6)

      Origin IGP, metric 0, localpref 100, valid, internal

  65500, (Received from a RR-client)

    5.5.5.5 (metric 2297856) from 5.5.5.5 (5.5.5.5)

      Origin IGP, metric 0, localpref 100, valid, internal, best

R7#

Table1: R7 best path selection for 192.168.10.0/24

 

Attribute

Path1

Path2

1

weight

0

0

2

local preference

100

100

3

originated locally

No

No

4

AS_PATH

65500

65500

5

ORIGIN

i

i

6

MED

0

0

7

eBGP<>iBGP

iBGP

iBGP

8

Best IGP metric to NEXT-HOP

2297856

2297856

9

Multipath

No

No

10

oldest path

No

No

11

Lowest neighbor router-ID

6.6.6.6

5.5.5.5  <<<

The best route chosen is the route through R5 because of the last criteria (figure2).

R7(config)#do traceroute 192.168.10.1 source 192.168.70.1

 

Type escape sequence to abort.

Tracing the route to 192.168.10.1

 

  1 192.168.57.1 92 msec 44 msec 160 msec

  2 192.168.45.1 256 msec 72 msec 96 msec

  3 192.168.14.1 136 msec *  280 msec

R7(config)#

Figure2: paths to 192.168.10.0/24 from R7

In the other side, network 192.168.70.0/24 (AS 65501) is reachable from R1 (AS 65500) through 2 paths (figure3):

R1:

R1#sh ip bgp

BGP table version is 16, local router ID is 192.168.10.1

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

*> 192.168.10.0     0.0.0.0                  0         32768 i

* i192.168.70.0     4.4.4.4                  0    100      0 65501 i

*>i                 3.3.3.3                  0    100      0 65501 i

R1#sh ip bgp 192.168.70.0

BGP routing table entry for 192.168.70.0/24, version 16

Paths: (2 available, best #2, table Default-IP-Routing-Table)

Flag: 0x900

  Not advertised to any peer

  65501

    4.4.4.4 (metric 5639936) from 4.4.4.4 (4.4.4.4)

      Origin IGP, metric 0, localpref 100, valid, internal

  65501

    3.3.3.3 (metric 2809856) from 2.2.2.2 (2.2.2.2)

      Origin IGP, metric 0, localpref 100, valid, internal, best

      Originator: 3.3.3.3, Cluster list: 2.2.2.2

R1#

Table2: R1 best path selection for 192.168.70.0/24

 

Attribute

Path1

Path2

1

weight

0

0

2

local preference

100

100

3

originated locally

No

No

4

AS_PATH

65501

65501

5

ORIGIN

i

I

6

MED

0

0

7

eBGP<>iBGP

iBGP

iBGP

8

Best IGP metric to NEXT-HOP

5639936

2809856 <<<

9

Multipath

No

No

10

oldest path

No

No

11

Lowest neighbor router-ID

2.2.2.2

4.4.4.4

 

Links between R1-R2 and R2-R3 are 2mpbs whereas R1 and R4 are connected through a 512kbps link, therefore the  tie breaker in the best path selection algorithm was the IGP metric to NEXT-HOP and below attributes are not considered.               

figure3: paths to 192.168.70.0/24 from R1

 

 

R1#traceroute 192.168.70.1 source 192.168.10.1

 

Type escape sequence to abort.

Tracing the route to 192.168.70.1

 

  1 192.168.12.2 84 msec 72 msec 96 msec

  2 192.168.23.2 104 msec 76 msec 40 msec

  3 192.168.36.2 308 msec 184 msec 184 msec

  4 192.168.67.2 208 msec *  144 msec

R1#

This type of routing is called “hot potato” or “Early exit” routing, because BGP choose the shortest path to transit traffic through the AS.

Hot potato routing can cause asymmetric routing between the source and the destination (figure4).

Figure4: Asymmetric routing

In case AS 65501 need to send and receive traffic between 192.168.10.0/24 and 192.168.70.0 through R5-R4, we have to manipulate more preferable criteria than IGP metric to NEXT-HOP, MED (Multi Exit Discriminator) for example.

In this case one service provider AS 65501 can SUGGEST to the other to take into account MED criterion so the  incoming and the outgoing traffic take the same path, which is a less common practice, this will certainly depend on the policies and negotiations, because each provider goal is to control how traffic enter and exit its AS according to its own needs not other providers needs.

The MED (Multi-Exit-Discriminator) is :

– optional non-transitive attribute.

– an INDICATION, SUGGESTION or a HINT to the neighbor AS about the preferred path for a particular incoming traffic, which is complying with the nature of AUTONOMOUS systems.

– used with dual-homed connections to the same neighbor AS.

Let’s suppose AS65500 will accept to take into account the criterion MED from eBGP peers from 65501 for the prefix 192.168.70.0/24, both border routers R5 and R6 will advertise the internal prefix 192.168.70.0/24 with different MED values (the lowest is the preferred).

R5:

ip prefix-list 70_plist seq 5 permit 192.168.70.0/24

 

route-map Low_MED_45_pmap permit 10

 match ip address prefix-list 70_plist

 set metric 10

 

router bgp 65501

 neighbor 4.4.4.4 route-map Low_MED_45_pmap out

 

R5#clear ip bgp 4.4.4.4 soft out

R6:

ip prefix-list 70_plist seq 5 permit 192.168.70.0/24

 

route-map High_MED_36_pmap permit 10

 match ip address prefix-list 70_plist

 set metric 100

 

router bgp 65501

 neighbor 3.3.3.3 route-map High_MED_36_pmap out

 

R6#clear ip bgp 3.3.3.3 soft out

R4 and R3 has received updates for the prefix 172.168.70.0/24 respectively from R5 and R6 with the different MED which is transmitted further throughout AS 56500 as you can see from R1 routing table:

R1:

R1#sh ip bgp

BGP table version is 21, local router ID is 192.168.10.1

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

*> 192.168.10.0     0.0.0.0                  0         32768 i

*>i192.168.70.0     4.4.4.4                 10    100      0 65501 i

* i                 3.3.3.3                100    100      0 65501 i

R1#

 

R1#sh ip bgp 192.168.70.0

BGP routing table entry for 192.168.70.0/24, version 21

Paths: (2 available, best #1, table Default-IP-Routing-Table)

Flag: 0x920

  Not advertised to any peer

  65501

    4.4.4.4 (metric 5639936) from 4.4.4.4 (4.4.4.4)

      Origin IGP, metric 10, localpref 100, valid, internal, best

  65501

    3.3.3.3 (metric 2809856) from 2.2.2.2 (2.2.2.2)

      Origin IGP, metric 100, localpref 100, valid, internal

      Originator: 3.3.3.3, Cluster list: 2.2.2.2

R1#

 

R1#traceroute 192.168.70.1 source 192.168.10.1

 

Type escape sequence to abort.

Tracing the route to 192.168.70.1

 

  1 192.168.14.2 56 msec 92 msec 64 msec

  2 192.168.45.2 108 msec 100 msec 64 msec

  3 192.168.57.2 240 msec *  180 msec

R1#

The tie is broken by MED value before reaching the criterion “shortest IGP cost to NEXT-HOP”

Table3: R1 best path selection for 192.168.70.0/24

 

Attribute

Path1

Path2

1

Weight

0

0

2

local preference

100

100

3

originated locally

No

No

4

AS_PATH

65501

65501

5

ORIGIN

i

I

6

MED

10 <<<

100

7

eBGP<>iBGP

iBGP

iBGP

8

Best IGP metric to NEXT-HOP

5639936

2809856

9

Multipath

No

No

10

oldest path

No

No

11

Lowest neighbor router-ID

2.2.2.2

4.4.4.4

 

Figure5: symmetric routing

Conclusion:

If your policy doesn’t take into account MED, make sure to explicitly reset it for prefixes received from you multi-homed connection with your peer AS.

Tags:

About ajnouri
Se vi deziras sekure komuniki eksterbloge, jen mia publika (GPG) Ĺťlosilo: My public key for secure communication: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x41CCDE1511DF0EB8

2 Responses to MED attribute and “hot potato” routing

  1. Bakr says:

    Useful information……….good example with well summarized explanation

  2. arpit says:

    Excellent post! keep it up dude 🙂

Leave a comment