MED
----
By default
The comparison of med only occurs if the first AS is the same in the 2 paths or
in other words we will only use med when we have multiple connections to the same AS
Med is non transitive meaning it will not go from AS to As so if i am r1 in AS1 and
advertise
med 100 to r2 in AS 2 r2 will not advertise this on to r3 in AS3
Lowest Med is the preference
route-map TO-R5
set metric 100
router BGP 100
neighbor 155.28.0.5 route-map TO-R5 out
You have to watch out for potential issue here say we are on r1 in AS1 and sending to r5 AS2
r5 will recieve this route from r1 with med of 100 if r5 is connected router AS1 say r3 it
may recieves
this route with a null metric. Some ios will interpret the null value as 0. So when we come
to compare
if everything is a tie up till the med it will compare of 0 vs 100 med so the 0 route will
win.
We can change this default behaviour by using the command
router bgp 400
bgp bestpath med missing-as-worst
if we do this a missing/null will be interpreted as the highest med value so least
preference.
As stated above the comparison of med only occurs if the first AS is the same in both paths.
We can override this
so it will compare med from path from different AS. We do this with the command
bgp always compare med
LAB
----
I look at the various med related commands
so the lab will be that bb1 in AS 54 is advertising network 111.1.1.0/24
R1 will advertise the path via r6>>>bb1 while r4 should advertise the path via r4>>bb3>>bb1
to r5
r5
---
r5#sh ip bgp
BGP table version is 22, local router ID is 5.5.5.5
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
* 111.1.1.0/24 3.3.3.3 0 300 100 54 i
* 1.1.1.1 0 100 54 i
*> 4.4.4.4 0 100 54 i
At the moment this is the status i want the routes to be all even when it comes to the bgp
selection policy up until moment at the moment 3.3.3.3 has as path of 3 compared to 1.1.1.
and 4.4.4.4 which is aspath of 4
I am going do an ASPATH prepend for r1 advertising to r5 and same for r4 advertising to r5
r5#sh ip bgp
BGP table version is 24, local router ID is 5.5.5.5
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
* 111.1.1.0/24 1.1.1.1 0 100 100 54 i
* 4.4.4.4 0 100 100 54 i
*> 3.3.3.3 0 300 100 54 i
ok now it is all equal it is choosing 3.3.3.3 this is going be by one of the tie breakers
oldest route table i would imagine since we cleared the process to apply the aspath change
for both 1.1.1.1 and 4.4.4.4
I am going set the metric for the route to 20 on 3.3.3.3 and the metric to 1 on 1.1.1.1
R3
----
Ok we will set route-map to change the med and assign to 5.5.5.5 out
r3(config)#route-map MED permit 10
r3(config-route-map)#set metric 20
r3(config-route-map)#exit
r3(config)#router bgp 300
r3(config-router)#neighbor 5.5.5.5 route-map MED to 20 out
r3(config-router)#
r1
===
Same on r1 except we are setting to metric 10
r1(config)#route-map PREPEND permit 10
r1(config-route-map)#set metric 10
r1(config-route-map)#exit
r1(config)#do sh run | sec router
router bgp 100
no synchronization
bgp log-neighbor-changes
aggregate-address 155.0.0.0 255.255.0.0 summary-only
neighbor IBGP peer-group
neighbor IBGP remote-as 100
neighbor IBGP update-source Loopback0
neighbor 3.3.3.3 remote-as 300
neighbor 3.3.3.3 disable-connected-check
neighbor 3.3.3.3 update-source Loopback0
neighbor 4.4.4.4 peer-group IBGP
neighbor 5.5.5.5 remote-as 400
neighbor 5.5.5.5 disable-connected-check
neighbor 5.5.5.5 update-source Loopback0
neighbor 5.5.5.5 route-map PREPEND out
neighbor 6.6.6.6 peer-group IBGP
no auto-summary
r5#sh i
*Jan 25 20:38:56.863: %SYS-5-CONFIG_I: Configured from console by consolep bgp
BGP table version is 26, local router ID is 5.5.5.5
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
* 111.1.1.0/24 3.3.3.3 20 0 300 100 54 i
* 1.1.1.1 10 0 100 100 54 i
*> 4.4.4.4 0 100 100 54 i
r5#config t
ok r4 was chooosen as the best route this either because the metric null is picked up as 0
are we are ignoring med as they are from different AS
5(config)#router bgp 400
r5(config-router)#bgp bestpath med missing-as-worst
r5(config-router)#exit
r5(config)#exit
r5#sh ip bgp
BGP table version is 2, local router ID is 5.5.5.5
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
*> 111.1.1.0/24 1.1.1.1 10 0 100 100 54 i
* 4.4.4.4 4294967295 0 100 100 54 i
* 3.3.3.3 20 0 300 100 54 i
it is choosen so it looks good lets try lowering the med on r3 and see does it select that
as the best route
so on r3
-----------
r3(config)#route-map MED permit 10
r3(config-route-map)#no set metric 20
r3(config-route-map)#set metric 5
r3(config-route-map)#
it is as i thought it was order of operation why 1.1.1.1 got selected the routes were
probably of all same age it did not compare the med and as 1.1.1.1 it probably ran route id
r5#sh ip bgp
BGP table version is 2, local router ID is 5.5.5.5
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
* 111.1.1.0/24 3.3.3.3 5 0 300 100 54 i
*> 1.1.1.1 10 0 100 100 54 i
* 4.4.4.4 4294967295 0 100 100 54 i
r5#
r1 is remaining the best route even though 3.3.3.3 has lower metric this is because by
default med will be only compared from paths from the 2 same AS
ALWAYS COMPARE MED on DETEMISTIC MED OFF
=====================================
r5(config)#router bgp 400
r5(config-router)#bgp always-compare-med
r5(config-router)#
r5#sh ip bgp
BGP table version is 2, local router ID is 5.5.5.5
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
* 111.1.1.0/24 4.4.4.4 4294967295 0 100 100 54 i
* 1.1.1.1 10 0 100 100 54 i
*> 3.3.3.3 5 0 300 100 54 i
r5#
since it is always compare it comparing med from multiple AS so r3 routes wins
NO ALWAYS COMPARE MED + DETERMINISTIC MED ON
---------------------------------------------
r5(config)#router bgp 400
r5(config-router)#bgp deterministic-med
r5(config-router)#
r5#sh ip bgp
BGP table version is 2, local router ID is 5.5.5.5
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
* 111.1.1.0/24 3.3.3.3 5 0 300 100 54 i
*> 1.1.1.1 10 0 100 100 54 i
* 4.4.4.4 4294967295 0 100 100 54 i
OK so r1 and r4 are compared r1 is selected as the best then compared to r3 but since bgp
always compare med is off med is not checked and r1 is selected as the best route based on
lowest route id.
ALWAYS COMPARE MED ON + DETERMINISTIC MED ON
---------------------------------------------
config)#router bgp 400
r5(config-router)#bgp always-compare-med
r5(config-router)#bgp deterministic-med
r5(config-router)#
r5#sh ip bgp
BGP table version is 2, local router ID is 5.5.5.5
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
* 111.1.1.0/24 1.1.1.1 10 0 100 100 54 i
* 4.4.4.4 4294967295 0 100 100 54 i
*> 3.3.3.3 5 0 300 100 54 i
No comments:
Post a Comment