BGP MED

BGP MED is an optional non-transitive attribute meaning its not propagated throughout the whole internet but just to adjacent AS. The word "optional" means that this is not necessarily by default sent with the BGP updates. The purpose of MED is to influence how other autonomous systems enter your AS to reach a certain prefix. If the other attributes are set to default, MED will be the attribute used for path selection however, if Weight or Local preference is configured on the adjacent AS router, then MED will not be selected. The lower the MED the more preferred the path will be.


Acronym for Multi Exit Discriminator and otherwise known as "Metric" in the BGP table.
The lower the MED the more preferred.
It is an optional non-transitive attribute.
Can dictate how other AS enter your AS.
Configure R4 so that it will advertise a MED value of 30 to R3 and 20 to R2. Afterwards,
tweak the route map to set a MED of 10 for network 144.144.144.144/32 in R4 towards R3. The end
result should have traffic from AS123 to 4.4.4.4/32 and 44.44.44.44/32 take R2 but traffic for
144.144.144.144/32 should take R3. At the start BGP has been established on all routers.


To start lets configure 2 route maps and set the MED as required.


R4(config)#access-list 20 permit any
R4(config)#access-list 30 permit any
R4(config)#route-map R2SETMED20 permit 10
R4(config-route-map)#match ip address 20
R4(config-route-map)#set metric 20
R4(config-route-map)#route-map R3SETMED30 permit 10
R4(config-route-map)#match ip address 30         
R4(config-route-map)#set metric 30

Access-list matches all routes. Now, lets apply the route map to the neighbors.

R4(config-router)#neighbor 24.24.24.2 route-map R2SETMED20 out
R4(config-router)#neighbor 34.34.34.3 route-map R3SETMED30 out

Its in the "out" direction because R4 is the one advertising the routes. Let's check what R2 and R3 see in their BGP table.


R2#sh ip bgp
BGP table version is 31, local router ID is 24.24.24.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
*> 4.4.4.4/32       24.24.24.4              20             0 4 i
*> 44.44.44.44/32   24.24.24.4              20             0 4 i
*> 144.144.144.144/32
                   24.24.24.4              20             0 4 i

R3#sh ip bgp
BGP table version is 10, local router ID is 34.34.34.3
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
*> 4.4.4.4/32       34.34.34.4              30             0 4 i
*> 44.44.44.44/32   34.34.34.4              30             0 4 i
*> 144.144.144.144/32
                   34.34.34.4              30             0 4 i

Ok, its clear that the Metric now is changed to 20 and 30 for R2 and R3 respectively. Let's see how R1 sees the routes.

R1#sh ip bgp
BGP table version is 34, local router ID is 13.13.13.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
*>i4.4.4.4/32       24.24.24.4              20    100      0 4 i
* i                 34.34.34.4              30    100      0 4 i
*>i44.44.44.44/32   24.24.24.4              20    100      0 4 i
* i                 34.34.34.4              30    100      0 4 i
*>i144.144.144.144/32
                   24.24.24.4              20    100      0 4 i
* i                 34.34.34.4              30    100      0 4 i

R1 sees two paths, but notice that the paths with ">" are with those with lower MED. Therefore it is going to take those paths. Now, lets configure R4 so that the path R1 will take to 144.144.144.144/32 in R4 will be through R3 then clear the BGP session after.

R4(config)#access-list 33 permit 144.144.144.144 0.0.0.0
R4(config)#route-map R3SETMED30 permit 10
R4(config-route-map)#match ip address 33
R4(config-route-map)#set metric 10
R4(config-route-map)#route-map R3SETMED30 permit 20
R4(config-route-map)#match ip address 30
R4(config-route-map)#set metric 30
R4#clear ip bgp *

Now, lets see the outputs.


R2#sh ip bgp | beg Network
  Network          Next Hop            Metric LocPrf Weight Path
*> 4.4.4.4/32       24.24.24.4              20             0 4 i
*> 44.44.44.44/32   24.24.24.4              20             0 4 i
*> 144.144.144.144/32
                   24.24.24.4              20             0 4 i

R3#sh ip bgp | beg Network
  Network          Next Hop            Metric LocPrf Weight Path
*> 4.4.4.4/32       34.34.34.4              30             0 4 i
*> 44.44.44.44/32   34.34.34.4              30             0 4 i
*> 144.144.144.144/32
                    34.34.34.4              10             0 4 i

R1#sh ip bgp | beg Network
  Network          Next Hop            Metric LocPrf Weight Path
* i4.4.4.4/32       34.34.34.4              30    100      0 4 i
*>i                 24.24.24.4              20    100      0 4 i
* i44.44.44.44/32   34.34.34.4              30    100      0 4 i
*>i                 24.24.24.4              20    100      0 4 i
*>i144.144.144.144/32
                    34.34.34.4              10    100      0 4 i
* i                 24.24.24.4              20    100      0 4 i

We can see a change in R3 that shows a MED of 10 for 144.144.144.144/32, while R1 shows the same and will now take R3 to reach the subnet.

Comments

Popular posts from this blog

REVERSE TELNET ON AUX PORT

Disabling Unneeded Services