MT300N -- polling status of WAN/LAN ports

I’m running a custom firmware created with your image builder and I need a reliable way of detecting the status of WAN/LAN ports.

Sadly, either checking /sys/class/net/eth0/carrier (/sys/class/net/eth0.1/carrier, /sys/class/net/eth0.2/carrier) or calling /bin/ubus call network.device status produces invalid results: the carrier/up are being reported 1 even with no cables plugged into neither of the ports, until the cable is plugged and unplugged and then all of the above are being properly reported 0.

What is the proper way to poll the status of wired ports to get valid results?

Same thing with your openwrt-gl-mt300n-2.22.bin firmware – both carrier/up are being reported 1 even with the ports unused, until the cable is initially plugged in.

I need a way to reliably detect if there’re no cables plugged in. How can I do that?


swconfig is used to display the switch information and it shows which port is connected.

Fantastic, thank you, it works wonders!

I’m having the same issue, but for my use case I really need the interface state itself to respond correctly to the cable connection state.

Is there any possibility of applying this patch, or a similar solution, to the GLi firmware so that the interface can be properly brought up/down (by setting the carrier state) when the cable is connected/disconnected?


@EddyM, thanks for the link. I will have a check. I think this is very useful. I just don’t know why this is not in OpenWrt and Lede. I will definitely put in our firmware after verification.