(1) Can use to choose the best path for inbound traffic which means influence routing in eBGP neighbors..
(2) The lowest MED is the preferred path..
(3) Propagated to iBGP neighbors in one AS only and will be propagated to neighboring AS only if the eBGP neighbor is directly connected to the route originating router or advertised using a route-map..
(4) MED values are compared for the prefixes coming from the same AS only by default..
MED can be used to advertise to your neighbors how they should enter your AS like we did in AS-Path prepending. Go here to find how AS-Path do same kind of thing..
Following example and this post is for the default behavior of Cisco IOS for the routes learned via the same AS. For an example where the same route is learned by 2 different ASes please go here.
Let's see an example..
Basic routing (EIGRP) configurations in AS-1
R1(config)#router eigrp 10
R1(config-router)#network 192.168.12.0
R1(config-router)#network 192.168.13.0
R1(config-router)#network 1.0.0.0
R2(config)#router eigrp 10
R2(config-router)#network 192.168.12.0
R2(config-router)#network 2.0.0.0
R3(config)#router eigrp 10
R3(config-router)#network 192.168.13.0
R3(config-router)#network 3.0.0.0
Basic routing (static) on R1 to reach the R2-R4 & R3-R4 links
R1(config)#ip route 192.168.24.0 255.255.255.0 192.168.12.2
R1(config)#ip route 192.168.34.0 255.255.255.0 192.168.13.3
Basic BGP configurations
R1(config)#router bgp 1
R1(config-router)#neighbor 2.2.2.2 remote-as 1
R1(config-router)#neighbor 2.2.2.2 update-source Loopback0
R1(config-router)#neighbor 3.3.3.3 remote-as 1
R1(config-router)#neighbor 3.3.3.3 update-source Loopback0
R2(config)#router bgp 1
R2(config-router)#neighbor 1.1.1.1 remote-as 1
R2(config-router)#neighbor 1.1.1.1 update-source lo0
R2(config-router)#neighbor 3.3.3.3 remote-as 1
R2(config-router)#neighbor 3.3.3.3 update-source lo0
R2(config-router)#neighbor 192.168.24.4 remote-as 2
R3(config)#router bgp 1
R3(config-router)#neighbor 1.1.1.1 remote-as 1
R3(config-router)#neighbor 1.1.1.1 update-source lo0
R3(config-router)#neighbor 2.2.2.2 remote-as 1
R3(config-router)#neighbor 2.2.2.2 update-source lo0
R3(config-router)#neighbor 192.168.34.4 remote-as 2
R4(config)#router bgp 2
R4(config-router)#neighbor 192.168.24.2 remote-as 1
R4(config-router)#neighbor 192.168.34.3 remote-as 1
R4(config-router)#neighbor 192.168.45.5 remote-as 2
R5(config)#router bgp 2
R5(config-router)#neighbor 192.168.45.4 remote-as 2
R5(config-router)#neighbor 192.168.56.6 remote-as 3
R6(config)#router bgp 3
R6(config-router)#neighbor 192.168.56.5 remote-as 2
R4(config-router)#neighbor 192.168.34.3 remote-as 1
R4(config-router)#neighbor 192.168.45.5 remote-as 2
R5(config)#router bgp 2
R5(config-router)#neighbor 192.168.45.4 remote-as 2
R5(config-router)#neighbor 192.168.56.6 remote-as 3
R6(config)#router bgp 3
R6(config-router)#neighbor 192.168.56.5 remote-as 2
R1(config)#router bgp 1
R1(config-router)#network 2.2.2.0 mask 255.255.255.0
You can see even in the advertising router, the metric is set to 409600. From where does it came??
Let's see what we can see on other routers..
You will not see the route in R2 & R6.. Why?
R1 will not advertise the route to R2 because the next hop to the route from R1 is R2..
R6 has only one neighbor which is R5; and the route in BGP table of R5 is not taken as a best route because there is no route to the next hop 192.168.34.3 from R5. We can fix it with a static route..
Let's put 2 static routes on R5 to reach both the possible eBGP next hops (192.168.34.3 & 192.168.24.2)
R5(config)#ip route 192.168.34.0 255.255.255.0 192.168.45.4
R5(config)#ip route 192.168.24.0 255.255.255.0 192.168.45.4
Now you will see the route on R6..
Actually what I wanted to show you is that, look for the metric values ip BGP tables as it propagates to different AS.. You will notice that the MED is unchanged in iBGP neighbors and will not be advertised to eBGP neighbors. But this behavior is little bit different if the eBGP neighbor is directly connected to the advertising router.
Let's advertise 192.168.13.0/24 from R2;
R2(config-router)#network 192.168.13.0 mask 255.255.255.0
Now you can see that the metric is advertised to both iBGP & eBGP neighbors..
Also you will notice that the lowest metric route is chosen as the best route to 192.168.13.0 from R4..
Now let's increase the metric of 192.168.13.0/24 route by a route-map..
R3(config)#access-list 10 permit 192.168.13.0 0.0.0.255
R3(config)#route-map MED permit 10
R3(config-route-map)#match ip address 10
R3(config-route-map)#set metric 400000
R3(config-route-map)#route-map MED permit 20
R3(config)#router bgp 1
R3(config-router)#neighbor 192.168.34.4 route-map MED out
Now you can see that the lowest metric route is chosen as the best route.. If you recall, this R3 is not originating this route. It is only passing the route to eBGP neighbor which it learned from it's iBGP neighbor. In default behavior this R3 is not advertising it's MED to R4. But the policy made R3 to advertise the metric to R4 forcefully..
According to the theory, R5 must get the best route with the MED & R6 should get the best route without MED because R5 is in same AS as R4 but R6 is in a different AS..
Let's take a look..
As expected it is working..
Note:-
You can also use route-maps to set metrics both to inbound and outbound directions to both types of neighbors (iBGP & eBGP).
No comments:
Post a Comment