Some time ago I published article about BGP local preference attribute. Today I’d 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.
Let’s look at typical scenario for MED attribute configuration:
Some time ago I wrote about interface policy-based routing PBR. Today I will show you example of local PBR configuration on Huawei AR routers. Local PBR allows you to forward packets through different interfaces or to different hops. Unlike interface PBR, local PBR is used for locally generated packets and classifies packets based on source addresses or packet lengths.
Let’s look at the topology and configure as follows:
- Locally generated ICMP packets (with the size of 70-1300 bytes) will be sent to next hop IP address 172.16.0.2.
- Locally generated ICMP packets (with the size of 1301-1500 bytes) will be sent to outbound interface GE0/0/1.
Configure IP addresses and static routes to ensure connectivity between loopback interfaces of both routers:
How to filter advertised and received routes on Huawei router?
Let’s try to check it based on the following topology:
- Configure basic OSPF functions on all routers.
- Configure static routes on AR1 router and import them to OSPF.
- Use filter-policy for advertised routes on AR1.
- Use filter-policy for received routes on AR3.
Let’s keep going and try to configure BGP local preference attribute using route-policy.
We can take full advantage of topology and configuration from the last post: “BGP default local preference in Huawei CLI“.
- Assure full connectivity based on the attached topology (look at the previous article).
- Configure Loopback 10 and Loopback 20 on router AR4.
- Import all Loopback interfaces of router AR4 to BGP.
Let’s assume that we have a topology like in below picture:
- AR1, AR2 and AR3 are in AS 100.
- AR4 is in AS 200.
- Loopback 100 of router AR1 and loopback 0 of router AR4 are advertised by BGP.
What we want to do is to configure default local preference attribute, which will determine the optimal route, for traffic that leaves AS 100. In our case, the whole traffic leaving AS 100 will go through AR3.
If a BGP device obtains multiple routes from different IBGP peers and these routes have different next hops to the same destination, the BGP device will select the route with the greatest Local_Pref value.