Using BGP MED Attribute to Control Route Selection on Huawei Devices
- May 16, 2024
- Posted by: Lyfey Technologies
- Categories: Huawei, Networking

Configuration Steps
Step 1: Configure Hostnames and IP addresses on interfaces for all routers.
***************************R1
sys
sysname R1
#
interface GigabitEthernet0/0/0
ip address 10.10.10.0 255.255.255.254
#
interface GigabitEthernet0/0/1
ip address 10.10.10.2 255.255.255.254
#
interface LoopBack0
ip address 1.1.1.1 255.255.255.255
#
***************************R2
sys
sysname R2
#
interface GigabitEthernet0/0/0
ip address 10.10.10.4 255.255.255.254
#
interface GigabitEthernet0/0/1
ip address 10.10.10.3 255.255.255.254
#
interface LoopBack0
ip address 2.2.2.2 255.255.255.255
#
***************************R3
sys
sysname R3
#
interface GigabitEthernet0/0/0
ip address 10.10.10.5 255.255.255.254
#
interface GigabitEthernet0/0/1
ip address 10.10.10.1 255.255.255.254
#
interface LoopBack0
ip address 3.3.3.3 255.255.255.255
#
Step 2: Configure EBGP peering sessions between R1, R2, and R3. Configure IBGP session between R2 and R3.
***************************R1
#
bgp 100
router-id 1.1.1.1
peer 10.10.10.1 as-number 200
peer 10.10.10.3 as-number 200
#
ipv4-family unicast
peer 10.10.10.1 enable
peer 10.10.10.3 enable
#
*******************************R2
bgp 200
router-id 2.2.2.2
peer 10.10.10.2 as-number 100
peer 10.10.10.5 as-number 200
#
ipv4-family unicast
peer 10.10.10.2 enable
peer 10.10.10.5 enable
#
************************R3
#
bgp 200
router-id 3.3.3.3
peer 10.10.10.0 as-number 100
peer 10.10.10.4 as-number 200
#
ipv4-family unicast
peer 10.10.10.0 enable
peer 10.10.10.4 enable
#
Step 3: Advertise network 10.10.10.4/31 on R2 and R3 and verify the routing on R1.
***********************R1 and R2
bgp 200
network 10.10.10.4 255.255.255.254
#
On R1, we observe that there are two valid routes to 10.10.10.4/31 and the route via R2 is preffered due to lower router ID of R2(2.2.2.2) compared to R3(3.3.3.3).

We can use MED attribute to control the route selection so that the route learned from R3 will be preffered. MED is like metric for IGPs and is used to control traffic that enters an AS. The route with the smallest MED value is alway preffered, hence we need to configure higher MED value for routes learned from R2 on R1.
Step 4: Configure high MED for routes from R2.
****************************R2
#
route-policy CHANGE_MED permit node 10
apply cost 100
#
bgp 100
ipv4-family unicast
peer 10.10.10.3 route-policy CHANGE_MED import
#
Step 5: Verify the routing table of R1.

The route from R2 now has MED of 100 while the route from R3 has default MED value of 0 hence its preffered as the best route by R1.
Thank you for reading. Please leave your comments below and check our blog for more interesting content on networking.
Related Posts
online animal pharmacy: pharmacy bangkok viagra – rx pharmacy symbol
community pharmacy: generic levitra online pharmacy – how much does viagra cost at pharmacy
buy viagra over the counter nz: real viagra no prescription – generic viagra free shipping
https://vgrsources.com/# viagra 150 mg pills
sildenafil 100mg without prescription: VGR Sources – sildenafil 100mg usa cheap
generic viagra best online pharmacy: canadian pharmacy generic sildenafil – order viagra online singapore
real viagra from canada VGR Sources viagra soft canada
where to buy sildenafil online: VGR Sources – viagra prescriptions
purchase viagra 100mg: VGR Sources – viagra generic online cheapest
sildenafil 2.5 VGR Sources sildenafil tablets coupon
buy female viagra online india: buy female viagra pills in india online – sildenafil 100 mg generic price
get viagra prescription online: can i buy viagra otc – viagra 125 mg
where to buy viagra online in usa: VGR Sources – viagra prescription nz
buy generic viagra from europe: buy generic viagra online in usa – viagra substitute
best pharmacy prices for viagra: buying viagra in europe – brand viagra 50 mg
viagra canada online viagra fiyatД± 50mg online sildenafil usa