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
- VRRP Implementation on Huawei Routers.
- DHCP server, DHCP relay and DHCP snooping Implementation on Huawei.
- Dual Link HSB (Direct forwarding) Implementation on Huawei WACs.
- VRRP HSB (Direct forwarding) Implementation on Huawei WACs.
- VXLAN (intra-subnet communication) Implementation on Huawei switches.