BGP IPv4 - MED Attributes

MED Attributes

The BGP (Border Gateway Protocol) Multi-Exit Discriminator (MED) attribute in IPv4 is a metric used to influence route selection in BGP routing decisions. Each BGP route can be assigned a MED value, which is a non-negative integer representing the desirability of a particular route. Lower MED values are considered more preferable, and routers use this attribute to determine the best path when multiple exit points to the same destination exist within different Autonomous Systems (ASes). The use of MED allows administrators to fine-tune routing decisions based on factors such as link bandwidth, congestion, or policy preferences. While MED is an effective tool for path selection, its interpretation may vary between different BGP implementations, and network administrators should carefully configure and monitor MED values to ensure optimal routing and traffic engineering within their BGP IPv4 networks.

Lab:

Disclaimer

This Configuration Guide is designed to assist members to enhance their skills in particular technology area. While every effort has been made to ensure that all material is as complete and accurate as possible, the enclosed material is presented on an “as is” basis. Neither the authors nor Forum assume any liability or responsibility to any person or entity with respect to loss or damages incurred from the information contained in this guide. This configuration guide was developed by Forum. Any similarities between material presented in this configuration guide and any other material is completely coincidental.

Cisco IOS Software, Linux Software (I86BI_LINUX-ADVENTERPRISEK9-M), Version 15.2(4)M1, DEVELOPMENT TEST SOFTWARE

Task 1: Configure BGP MED Attributes for Autonomous

Step 1: In the configuration mode of router configure BGP MED Attributes by following command:

R1:
interface s2/3
ip address 13.0.0.1 255.255.255.0
no shutdown
router bgp 65100
neighbor 13.0.0.3 remote-as 65000
address-family ipv4
neighbor 13.0.0.3 soft-reconfiguration inbound
exit
R2:
interface s2/3
ip address 24.0.0.2 255.255.255.0
no shutdown
router bgp 65000
neighbor 24.0.0.4 remote-as 65200
address-family ipv4
neighbor 24.0.0.4 soft-reconfiguration inbound
exit
R3:
interface s2/3
ip address 13.0.0.3 255.255.255.0
no shutdown
router bgp 65000
neighbor 13.0.0.1 remote-as 65100
address-family ipv4
neighbor 13.0.0.1 soft-reconfiguration inbound
exit
R4:
interface s2/3
ip address 24.0.0.4 255.255.255.0
no shutdown
router bgp 65200
neighbor 24.0.0.2 remote-as 65000
address-family ipv4
neighbor 24.0.0.2 soft-reconfiguration inbound
exit

Step 2: Verify IPv4 BGP routes by following command:

R1#show ip bgp
BGP table version is 21, local router ID is 11.0.3.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop       Metric     LocPrf     Weight    Path
 *>  11.0.1.0/24      0.0.0.0         0         	        32768      i
 *>  11.0.2.0/24      0.0.0.0         0         	        32768      i
 *>  11.0.3.0/24      0.0.0.0         0         	        32768      i
 *>  22.0.1.0/24      13.0.0.3                              0          65000 i
 *                    22.0.1.2        0              	    0          65000 i
 *>  22.0.2.0/24      13.0.0.3                              0          65000 i
 *                    22.0.1.2        0              	    0	       65000 i
 *>  22.0.3.0/24      13.0.0.3                              0          65000 i
 *                    22.0.1.2        0              	    0          65000 i
 *>  33.0.1.0/24      13.0.0.3        0                     0          65000 i
 *                    22.0.1.2              	            0          65000 i
 *>  33.0.2.0/24      13.0.0.3        0              	    0          65000 i
 *                    22.0.1.2                              0          65000 i
 *>  33.0.3.0/24      13.0.0.3        0              	    0          65000 i
 *                    22.0.1.2        0 	        		           65000 i
 *   44.0.1.0/24      22.0.1.2        0 			                   65000 65200 i
 *>                   13.0.0.3        0 			                   65000 65200 i
 *>  44.0.2.0/24      13.0.0.3        0 			                   65000 65200 i
 *                    22.0.1.2        0 		                       65000 65200 i
 *>  44.0.3.0/24      13.0.0.3        0 		                       65000 65200 i
 *                    22.0.1.2        0 			                   65000 65200 i

MED is local to a router and it is use to change router’s decision when it receives multiple path from same AS.

Router R1 can reach 22.0.2.0 via 22.0.1.2 and via 13.0.0.3 through AS 65000 i.e. Router R1 has multiple path to reach AS 65000. But Router R1 will select path via 13.0.0.3 as best path because MED select directly connected path as best path when having multiple exit. Therefore MED selects 13.0.0.3 as best directly connected to reach R2 as best path as 13.0.0.3 is directly connected.

R4#show ip bgp
BGP table version is 13, local router ID is 44.0.3.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP , ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network           Next Hop        Metric    LocPrf    Weight    Path
*   11.0.1.0/24        33.0.1.3                            0         65000 65100 i
*>                     24.0.0.2                            0         65000 65100 i
*   11.0.2.0/24        33.0.1.3                            0         65000 65100 i
*>                     24.0.0.2                            0         65000 65100 i
*   11.0.3.0/24        33.0.1.3                            0         65000 65100 i
*>                     24.0.0.2                            0         65000 65100 i
*   22.0.1.0/24        33.0.1.3                            0         65000 i
*>                     24.0.0.2           0                0         65000 i
*   22.0.2.0/24        33.0.1.3                            0         65000 i
*>                     24.0.0.2           0                0         65000 i
*   22.0.3.0/24        33.0.1.3                            0         65000 i
*>                     24.0.0.2           0                0         65000 i
*   33.0.1.0/24        33.0.1.3           0                0         65000 i
*>                     24.0.0.2                            0         65000 i
*   33.0.2.0/24        33.0.1.3           0                0         65000 i
*>                     24.0.0.2                            0         65000 i
*   33.0.3.0/24        33.0.1.3           0                0         65000 i
*>                     24.0.0.2                            0         65000 i
*>  44.0.1.0/24        0.0.0.0            0         	    32768     i
*>  44.0.2.0/24        0.0.0.0            0         	    32768     i
*>  44.0.3.0/24        0.0.0.0            0         	    32768     i

Router R4 can reach 11.0.1.0 via 33.0.1.3 and via 24.0.0.2 through AS 65000 65100 i.e. Router R4 has multiple path to reach AS 65000. But Router R1 will select path via 24.0.0.2 as best path because MED select directly connected path as best path when having multiple exit. Therefore MED selects 24.0.0.2 as best directly connected to reach R2 as best path as 24.0.0.2 is directly connected.

Task 2: Configure BGP Selective Manipulation using MED for Autonomous

Step 1: In the configuration mode of router configure BGP Selective Manipulation using MED by following command:

R1:
router bgp 65100
address-family ipv4
neighbor 13.0.0.3 route-map aaa in
exit
route-map aaa permit 10
match-ip address 1
set metric 5000
exit
route-map aaa permit 20
exit
access-list 1 permit 22.0.2.0 0.0.0.255
exit

Step 2: Verify IPv4 BGP routes by following command:

R1#show ip bgp
BGP table version is 38, local router ID is 11.0.3.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP , ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network       Next Hop        Metric    LocPrf    Weight    Path
*>  11.0.1.0/24    0.0.0.0            0         	   32768     i
*>  11.0.2.0/24    0.0.0.0            0         	   32768     i
*>  11.0.3.0/24    0.0.0.0            0         	   32768     i
*>  22.0.1.0/24    13.0.0.3                            0         65000 i
*                  22.0.1.2           0                0         65000 i
*   22.0.2.0/24    13.0.0.3         5000       0       65000     i
*>                 22.0.1.2           0                0 	     65000 i
*>  22.0.3.0/24    13.0.0.3                            0         65000 i
*                  22.0.1.2           0                0         65000 i
*>  33.0.1.0/24    13.0.0.3           0                0         65000 i
*                  22.0.1.2                            0         65000 i
*>  33.0.2.0/24    13.0.0.3           0                0         65000 i
*                  22.0.1.2                            0         65000 i
*>  33.0.3.0/24    13.0.0.3           0                0         65000 i
*                  22.0.1.2                            0         65000 i
*   44.0.1.0/24    22.0.1.2                            0         65000 65200 i
*>                 13.0.0.3                            0         65000 65200 i
*>  44.0.2.0/24    13.0.0.3                            0         65000 65200 i
*                  22.0.1.2                            0         65000 65200 i
*>  44.0.3.0/24    13.0.0.3                            0         65000 65200 i
*                  22.0.1.2                            0         65000 65200 i 

Router R1 can now reach 22.0.2.0 via 22.0.1.2. This is done by calling route map policy in which selective route 22.0.2.0 only will set 13.0.0.3 metric 5000 and rest all routes will select their best path via 13.0.0.3. Hence Selective Route Manipulation is done.