Friday , February 28 2025

BGP MED attribute on Huawei router

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:

BGP MED topology

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 IGP for AS200:

[Wroclaw]dis cur config ospf
#
ospf 1
 area 0.0.0.0
  network 2.2.2.2 0.0.0.0
  network 150.1.1.0 0.0.0.3

[Krakow]dis cur config ospf
#
ospf 1
 area 0.0.0.0
  network 3.3.3.3 0.0.0.0
  network 150.2.2.0 0.0.0.3

[Lublin]dis cur config ospf
#
ospf 1
 area 0.0.0.0
  network 4.4.4.4 0.0.0.0
  network 150.1.1.0 0.0.0.3
  network 150.2.2.0 0.0.0.3

Configure IBGP and BGP:

[Warsaw]dis cur config bgp
#
bgp 100
 router-id 1.1.1.1
 peer 200.1.1.2 as-number 200
 peer 200.2.2.2 as-number 200
 #
 ipv4-family unicast
  undo synchronization
  network 1.1.1.1 255.255.255.255
  peer 200.1.1.2 enable
  peer 200.2.2.2 enable

[Wroclaw]dis cu config bgp
#
bgp 200
 router-id 2.2.2.2
 peer 3.3.3.3 as-number 200
 peer 3.3.3.3 connect-interface LoopBack0
 peer 4.4.4.4 as-number 200
 peer 4.4.4.4 connect-interface LoopBack0
 peer 200.1.1.1 as-number 100
 #
 ipv4-family unicast
  undo synchronization
  peer 3.3.3.3 enable
  peer 3.3.3.3 next-hop-local
  peer 4.4.4.4 enable
  peer 4.4.4.4 next-hop-local
  peer 200.1.1.1 enable

[Krakow]dis cur config bgp
#
bgp 200
 peer 2.2.2.2 as-number 200
 peer 2.2.2.2 connect-interface LoopBack0
 peer 4.4.4.4 as-number 200
 peer 4.4.4.4 connect-interface LoopBack0
 peer 200.2.2.1 as-number 100
 #
 ipv4-family unicast
  undo synchronization
  peer 2.2.2.2 enable
  peer 2.2.2.2 next-hop-local
  peer 4.4.4.4 enable
  peer 4.4.4.4 next-hop-local
  peer 200.2.2.1 enable

[Lublin]dis cur config bgp
#
bgp 200
 peer 2.2.2.2 as-number 200
 peer 2.2.2.2 connect-interface LoopBack0
 peer 3.3.3.3 as-number 200
 peer 3.3.3.3 connect-interface LoopBack0
 #
 ipv4-family unicast
  undo synchronization
  peer 2.2.2.2 enable
  peer 3.3.3.3 enable

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

 BGP Local router ID is 1.1.1.1 
 Status codes: * - valid, > - best, d - damped,
               h - history,  i - internal, s - suppressed, S - Stale
               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 3
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>   1.1.1.1/32         0.0.0.0         0                     0      i
 *>   100.100.100.100/32 200.1.1.2                             0      200i
 *                       200.2.2.2                             0      200i

<Warsaw>dis bgp routing-table 100.100.100.100

 BGP local router ID : 1.1.1.1
 Local AS number : 100
 Paths:   2 available, 1 best, 1 select
 BGP routing table entry information of 100.100.100.100/32:
 From: 200.1.1.2 (2.2.2.2)
 Route Duration: 00h00m29s  
 Direct Out-interface: GigabitEthernet0/0/0
 Original nexthop: 200.1.1.2
 Qos information : 0x0
 AS-path 200, origin igp, pref-val 0, valid, external, best, select, active, pre 
255
 Advertised to such 2 peers:
    200.1.1.2
    200.2.2.2
 BGP routing table entry information of 100.100.100.100/32:
 From: 200.2.2.2 (3.3.3.3)
 Route Duration: 01h21m00s  
 Direct Out-interface: GigabitEthernet0/0/1
 Original nexthop: 200.2.2.2
 Qos information : 0x0
 AS-path 200, origin igp, pref-val 0, valid, external, pre 255, not preferred for
 router ID
 Not advertised to any peer yet

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

Look at BGP routing table of Warsaw router once again:

[Warsaw]dis bgp routing-table 

 BGP Local router ID is 1.1.1.1 
 Status codes: * - valid, > - best, d - damped,
               h - history,  i - internal, s - suppressed, S - Stale
               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 3
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>   1.1.1.1/32         0.0.0.0         0                     0      i
 *>   100.100.100.100/32 200.2.2.2                             0      200i
 *                       200.1.1.2       200                   0      200i

[Warsaw]dis bgp routing-table 100.100.100.100

BGP local router ID : 1.1.1.1
Local AS number : 100
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 100.100.100.100/32:
From: 200.2.2.2 (3.3.3.3)
Route Duration: 01h30m40s
Direct Out-interface: GigabitEthernet0/0/1
Original nexthop: 200.2.2.2
Qos information : 0x0
AS-path 200, origin igp, pref-val 0, valid, external, best, select, active, pre
255
Advertised to such 2 peers:
200.1.1.2
200.2.2.2
BGP routing table entry information of 100.100.100.100/32:
From: 200.1.1.2 (2.2.2.2)
Route Duration: 00h00m29s
Direct Out-interface: GigabitEthernet0/0/0
Original nexthop: 200.1.1.2
Qos information : 0x0
AS-path 200, origin igp, MED 200, pref-val 0, valid, external, pre 255, not pref
erred for MED
Not advertised to any peer yet

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).

To be sure just use tracert command on Warsaw router:

<Warsaw>tracert -a 1.1.1.1 100.100.100.100

traceroute to 100.100.100.100(100.100.100.100), max hops: 30 ,packet length: 40,press CTRL_C to break

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

traceroute to 1.1.1.1(1.1.1.1), max hops: 30 ,packet length: 40,press CTRL_C to break

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.

Read More »

assigning multiple IP addresses to network interface

Why might we want to assign multiple IP addresses to the same interface? The following are the most common scenarios:

  • hosts in the network segment use IP addresses on different networks
  • there are not enough host addresses on a logical network segment, suppose a /24 address space and 300 hosts
How to configure multiple IP addresses on Huawei devices?

Let’s configure a pair of routers connected via a Gigabit Ethernet link and use four different logical networks.

[labnarioR1]int gi 0/0/0
[labnarioR1-GigabitEthernet0/0/0]ip add 192.168.12.1 255.255.255.0
[labnarioR1-GigabitEthernet0/0/0]ip add 10.0.12.1 255.255.255.0 sub
[labnarioR1-GigabitEthernet0/0/0]ip add 10.0.22.1 255.255.255.0 sub
[labnarioR1-GigabitEthernet0/0/0]ip add 10.0.32.1 255.255.255.0 sub

[labnarioR2]int gi 0/0/0
[labnarioR1-GigabitEthernet0/0/0]ip add 192.168.12.2 255.255.255.0
[labnarioR2-GigabitEthernet0/0/0]ip add 10.0.12.2 255.255.255.0 sub
[labnarioR2-GigabitEthernet0/0/0]ip add 10.0.22.2 255.255.255.0 sub
[labnarioR2-GigabitEthernet0/0/0]ip add 10.0.32.2 255.255.255.0 sub

Now ping test can be done to check connectivity:

[labnarioR1-GigabitEthernet0/0/0]ping 192.168.12.2
  PING 192.168.12.2: 56  data bytes, press CTRL_C to break
    Reply from 192.168.12.2: bytes=56 Sequence=1 ttl=255 time=50 ms

[labnarioR1-GigabitEthernet0/0/0]ping 10.0.12.2
  PING 10.0.12.2: 56  data bytes, press CTRL_C to break
    Reply from 10.0.12.2: bytes=56 Sequence=1 ttl=255 time=50 ms

[labnarioR1-GigabitEthernet0/0/0]ping 10.0.22.2
  PING 10.0.22.2: 56  data bytes, press CTRL_C to break
    Reply from 10.0.22.2: bytes=56 Sequence=1 ttl=255 time=50 ms

[labnarioR1-GigabitEthernet0/0/0]ping 10.0.32.2
  PING 10.0.32.2: 56  data bytes, press CTRL_C to break
    Reply from 10.0.32.2: bytes=56 Sequence=1 ttl=255 time=50 ms

Read More »

indoor and outdoor Huawei ATN905

As you know I try to avoid products descriptions here, on this blog. But last time I had possibility to see ATN905 boxes, available in the indoor and outdoor types. You can install them in various environment. The application scenarios of ATN905 are divided into the small-cell base station bearer scenario and the Ethernet demarcation device (EDD) scenario.

Let’s look at the pictures of the two types of this router:

Indoor ATN905 picture

Outdoor ATN905 can be wall and pole mounted. Indoor ATN905 can be installed in outside premises, street cabinets, indoor cabinets or just on a desk.

And the next interesting box:

The APM30H is an outdoor cabinet with heat exchangers. It supports AC power supply and DC power distribution, and can provide a 7 U installation space for user devices.

I allowed myself to place pictures from Huawei ATN905 documentation in this post.

Read More »

from Huawei CLI – check …

Very useful command, especially when you are preparing and executing upgrade of a software of Huawei carrier class devices, like NE40E and CX600. Let’s look what can be checked by this command:

<labnario>check ?
  hardware-compatibility  hardware compatibility
  startup                 Check the version of the resource file
  system-software         system-software
  version                 check version

I personally use “check hardware-compatibility” before all planned upgrades. During a preparation phase of an upgrade, you have to read software release notes, to be sure that all software and hardware components will be compatible with the new software. You can check hardware compatibility by the command, instead of searching software documents.

Imagine that you’ve just uploaded a new software to CFcard of a router. The new software is v600r006c00spc300.

<labnario>check hardware-compatibility v600r006c00spc300.cc
Slot#    BoardType        Result           Detail
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3        CR57LAXFB00      Compatible       NA
4        CR57LAXFB00      Compatible       NA
5        CR57EMGFB20      Compatible       NA
6        CR57EMGFB20      Compatible       NA
9        CR57SRU200A5     Compatible       NA
10       CR57SRU200A5     Compatible       NA
11       CR57SFU200C0     Compatible       NA
12       FRA200A          Compatible       NA
13       FRA200A          Compatible       NA

It’s very simple, isn’t it?

A second useful command before upgrade:

<labnario>check startup next
Main board:
Check startup software.......ok
Check configuration file.....ok
Check PAF....................ok
Check License................ok
Check Patch..................ok
PAF is fitted with startup software
License is fitted with startup software
Patch is fitted with startup software
Slave board:
Check startup software.......ok
Check configuration file.....ok
Check PAF....................ok
Check License................ok
Check Patch..................ok
PAF is fitted with startup software
License is fitted with startup software
Patch is fitted with startup software
Startup software in slave board is fitted with main board.

By this command we can check whether the next startup software is set properly.

Let’s look at the remaining options:

<labnario>check system-software v600r006c00spc300.cc
Info: Prepare to check system software cfcard:/v600r006c00spc300.cc, please wait..........
Info: System software CRC check OK!

<labnario>check version cfcard:/v600r006c00spc300.cc
Info: Software version match Ok!

I think these options don’t need any explanation.

You have to remember that this command is available from “user-view“.

Read More »

new options in display elabel command

Some time ago I described how to display electronic labels. As you probably could see, the displayed information looked illegibly, especially for budding engineers.

Starting from V6R6 software of carrier class devices (like Huawei NE40E, CX600), it looks much better. You have all the information at a glance:

<labnario>display elabel brief
Slot     BoardType    BarCode                 Description
================================================================================
LPU 1    CR52LPUF40A  030KWD10AB000351        LPUF-40-A
  PIC 0  CR52L2XXN0   03675210A9000134        P40-2x10GBase LAN/WAN-XFP
  PIC 1  CR52L2XXN0   03675210A9000115        P40-2x10GBase LAN/WAN-XFP
LPU 2    CR52LPUF40A  030KWD10B7000867        LPUF-40-A
  PIC 0  CR52L2XXN0   03675210B7001018        P40-2x10GBase LAN/WAN-XFP
  PIC 1  CR52L2XXN0   03675210B7001188        P40-2x10GBase LAN/WAN-XFP
LPU 3    CR52LPUKD0   030KJY10A8000126        LPUF-21-A
  PIC 0  CR52L1XX0    030GSK10A9002012
  PIC 1  CR52L1XX0    030GSK10B7001228
LPU 7    CR52LPUKD0   030KJY10B1000383        LPUF-21-A
  PIC 0  CR52L1XX0    030GSK10A2001595
  PIC 1  CR52EBGF0    030GSH10B1000971
LPU 8    CR52LPUKD0   030KJY10CC001471        LPUF-21-A
  PIC 0  CR52L1XX0    030GSK10A2001005
  PIC 1  CR52EBGF0    030GSH10B1000795
MPU 9    CR57SRU40A4  030KSR10AA000258        SRUA4-40
MPU 10   CR57SRU40A4  030KSR10AA000175        SRUA4-40
SFU 11   CR57SFU40C0  030KSY10A9000472        SFUI-40-C
SFU 12
SFU 13

This is not the end. We have more options:

<labnario>display elabel ?
  <1-2,7-11>      The present slot
  backplane       The backplane
  brief           brief
  fuse-unit       Fuse Board
  optical-module  optical-module
  |               Matching output

Let’s try to display optical modules:

<labnario>display elabel optical-module brief
Port      BoardType          BarCode         VendorName        Description
===============================================================================
Eth1/0/0  HUXF-MM85300-GP    XA9V200007      GBC PHOTONICS     9900Mb/s-850nm-L
                                                               C-300m(EBW 50/12
                                                               5um)-100m(50/125
                                                               um)-33m(62.5/125
                                                               um)

Eth1/0/1  FTLX1412M3BCL      UL109YQ         FINISAR CORP.     9900Mb/s-1310nm-
                                                               LC-10km(0.009mm)

Eth1/1/0  TRF5013FN-GA420    T10J17302       Opnext Inc.       10000Mb/s-1310nm
                                                               -LC-10km(0.009mm
                                                               )

Eth1/1/1  FTLX1412M3BCL      UHB00LR         FINISAR CORP.     9900Mb/s-1310nm-
                                                               LC-10km(0.009mm)

Eth2/0/0  XF-MM85300-GP      XA9V200003      GBC               9900Mb/s-850nm-L
                                                               C-300m(EBW 50/12
                                                               5um)-100m(50/125
                                                               um)-33m(62.5/125
                                                               um)
.
.
.

I think it’s a good solution yet simple, don’t you?

Read More »