Wrong switch port numbering in LuCI

Not sure if this topic is appropriate in this forum or should go into HW or developer, please advise if not.

OpenWrt 18.06.1 r7258-5eb055306f / LuCI openwrt-18.06 branch (git-18.340.83383-3dea6b5) on MikroTik RouterBOARD 951G-2HnD

LuCi reports different port numbers in network/switch than the labels on the board itself/swconfig numbers. That makes administration confusing:

Swconfig port numbers:
also as physici0al port numbers on device:
1 2 3 4 5
| | | | | LuCI
| | | | | label
| | | | |
| | | | +- LAN4 (should be LAN5)
| | | +--- LAN3 (should be LAN4)
| | +----- LAN2 (should be LAN3)
| +------- LAN1 (should be LAN2)
+--------- WAN (ok.)

I tried to see if mucking around with /etc/board.d/02_network could help, but i don't think that this file gets even executed from overlay: i added a logger output and nothing shows up in syslog. Aka: i fear its only executed from underlay.

02_network is only executed if there is no etc/config/network. If there is one, the file has no impact. And it only creates the config into etc/config/network, so you can directly edit switch config there.

Does editing /etc/board.json or /tmp/board.json change it?
I’m not familiar with where LuCI pulls the values, but those files do contain a mapping.

files in /etc/config

LuCI is just GUI that shows and modifies the existing uci config files, which are located in /etc/config.


It looked as if the syntax in 02_network would allow to assign name/numbers to switch ports, such as: "1:lan:2".

There seems to be nothing like this in /etc/config/network:


Does not mention anything about assigning names/numbers to port that would show up on the LuCI web page:

Alas, the full switch documention is seemingly not maintained, it points to:


But also nomentioning how to define port number/names.

This made me also believe that these names/numbers have to be set up in a place different than /etc/config/network (or LuCI).

If port name/number can be configured in /etc/config/network or LuCI directly, i would appreciate an example!

Yes but i don't think this particular setting is controlled from there.
the 02_network file invokes functions from /lib/functions/uci-defaults.sh, which all dump to board.json files.

This is just a logical to physical naming scheme

From a quick grep, we can see that the network lua model from LuCI pulls from /etc/board.json here:
and loads the port number (LOGICAL), role and the index (PHYSICAL).

Now, keep in mind that i don't use LuCI, but i've written my own implementation that does similar in Gargoyle here: https://github.com/ericpaulbishop/gargoyle/blob/base_on_openwrt_remerge/package/gargoyle/files/usr/lib/gargoyle/switchinfo.sh#L36

And would be surprised if LuCI didn't do it similarly. But i am just guessing here, and will stand corrected by LuCI gurus.
So my suggestion still stands @toerless. Edit /etc/board.json and see what happens.
And if that fixes it, then a patch should be sent to Openwrt to change this mapping permanently.

Thanks. Have to try next year, off now, but my main concern is that my board.json does not assign logical numbers, but only what looks like the physcial numbers, so i fear that the local numbers shown by LuCI are just in numerical order.

You are right, LuCI uses /etc/board.json for that functionality. I overlooked that. My bad.

You are also right, the change to /etc/board.d/02_network needs to be in the flashed firmware as it is evaluated early in the preinit phase before overlay is mounted. (I noticed that also in a PR discussion in July: https://github.com/openwrt/openwrt/pull/1130 )

But for testing purposes, the suggestion by @lantis1008 works ok: you can edit /etc/board.json and after refreshing the LuCI switch page, the new numbering should be visible. (Just tested with my wrt3200acm...) But that chage only lives until the next reboot.

For permanent changes you will need to make the change to 02_network source, compile firmware and flash it.

But I am not sure if the shown numbering can start from 2. It may need to start from 1.

1 Like

I thought the same. Another interesting experiment for sure!

Is there still an (easy) way to install OpenWrt without overlay ? Thats what i did years ago with CC, but i don't remember how. Woul aleviate the pain to have to jump through hoops when trying to fixup stuff (hoops = build another flash image).

For most routers, no.
(the old jffs2-only version was removed from most targets some years ago.)

Thanks. Too bad.

Btw: can not renumber/rename ports except permutation because the LuCI code does simply assigns the names sequentially with the name being the role (LAN, WAN).

Improving LuCI output looks like a feature request.