Professional Documents
Culture Documents
Some time ago I published article about BGP local preference attribute. Today Id like to
show you how to configure BGP MED attribute.
What is it for?
The multi-exit discriminator MED determines an optimal route for incoming traffic of an AS.
When a BGP device obtains multiple routes to the same destination but with different next
hops from EBGP peers, the BGP device selects the route with the smallest MED value as the
optimal route. Simply saying, configuring MED attribute, we would like to show the next hop
for traffic coming from EBGP peer. The MED attribute is exchanged only between two
neighboring ASs. The AS that receives the MED attribute does not advertise it to any other
ASs.
If you want to recall the BGP configuration, just go to basic BGP in Huawei CLI article.
What we want to do in this lab is to force Warsaw router to send traffic to network 4.4.4.4
through Krakow router. Of course we will use BGP MED attribute to achieve this.
Configure Loopback100 on Lublin router and add its address 100.100.100.100/32 to BGP:
[Lublin]interface LoopBack 100
[Lublin-LoopBack100]ip add 100.100.100.100 32
[Lublin-bgp]ipv4-family unicast
[Lublin-bgp-af-ipv4]network 100.100.100.100 255.255.255.255
View BGP routing table of Warsaw router:
<Warsaw>dis bgp routing-table
As you can see from the output, there are 2 valid routes to 100.100.100.100. The route with
the next hop 200.1.1.2 is the optimal route, because of a smaller router ID. A default value of
MED is 0.
Now we can set MED attribute for routes advertised by Wroclaw router to Warsaw:
[Wroclaw]route-policy med permit node 10
Info: New Sequence of this List.
[Wroclaw-route-policy] apply cost 200
[Wroclaw]bgp 200
[Wroclaw-bgp]ipv4-family unicast
[Wroclaw-bgp-af-ipv4]peer 200.1.1.1 route-policy med export
As you can see, the router with the next hop 200.2.2.2 is the optimal route to 100.100.100.100.
It was chosen because of MED attribute (smaller MED = best route).
1 200.2.2.2 60 ms 50 ms 30 ms
2 150.2.2.2 80 ms 60 ms 60 ms
Anyway, traffic from Lublin router to Warsaw still goes through Wroclaw router:
<Lublin>tracert -a 100.100.100.100 1.1.1.1
1 150.1.1.1 50 ms 50 ms 40 ms
2 200.1.1.1 70 ms 60 ms 40 ms
At the end I have a question for you. Is it possible to compare MED attributes of routes,
received from different EBGP peers? If yes, how to do this? Waiting for your comments.