Change Wan LED color depending on if the connection is up or not

I have TP link Archer c20 V4, on the stock firmware when the internet connection is not working the Wan led turns orange from green. How do i go about doing that on OpenWRT i know the stock firmware pings its website to check if the wan is receiving data or not. how can i do the same on OpenWRT.

1 Like

Thanks for replying, I tried your code in the reply of both posts when i paste it in rc.local and both the times the power led keeps blinking and only 2g and 5g wifi leds are on rest of them are off. I think i am pointing it to another led.

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

while true; do
if ping -c 1 &> /dev/null
  /bin/echo "0"  /sys/class/leds/tp-link:orange:wan/brightness
  /bin/echo "255"  /sys/class/leds/tp-link:orange:wan/brightness
sleep 5

Forgot to say i have to reboot by pressing the switch i cant do it through gui and ssh.


You'll have to play around with the different LEDs, it's very device specific.
They're all in /sys/class/leds , trial and error.

t@OpenWrt:~# vi /sys/class/leds/c20-v4\:green\:wan/
brightness      max_brightness  port_mask       subsystem/      uevent
device/         mode            speed_mask      trigger
root@OpenWrt:~# vi /sys/class/leds/c20-v4\:orange\:wan/
brightness      device/         max_brightness  subsystem/      trigger         uevent
root@OpenWrt:~# vi /sys/class/leds/c20-v4\:orange\:wan/

Well they are called the same thing i also checked it on the led config tab and its the same names. and the lines in the code just sends 0 and 255 to the brightness file. It might be to do something with port mask

In addition to the answers above, is your internet connection PPPoE on WAN? Then you can do it without having to ping every 5 seconds.

1 Like

Yeah it is, Should i remove it or or just make it longer ?

If you are on PPPoE, you don't have to ping at all, the interface status itself should serve fine as an indicator. You can just use a script in /etc/hotplug.d/iface, something like:


[ "$INTERFACE" = wan ] || exit 0
if [ "$ACTION" = ifup ] ; then
# WAN interface went up, echo to the LED(s) here
if [ "$ACTION" = ifdown ] ; then
# WAN interface went down, echo to the LED(s) here
exit 0

(untested, supply your own echo commands as you like. The name of the script file is not relevant, something like 30-wanled should do fine.)

Or, if you are fine with just one LED that lights up if the WAN interface is up, you don't even need a script at all. Just use regular LED configuration, and attach an LED via netdev to pppoe-wan, like this:


As a bonus, if you don't just select "Link On", but also "Transmit" and "Receive", you will get pretty blinkylights if there is network traffic on WAN. Unfortunately it's not possible to have an LED light up when the interface is down through the LED configuration. (Oh how nice would an "invert LED" flag be.)


Cool ill try it later, i wouldn't mind the led off but it would be great if it was orange for my isp to diagnose the issues he gets confused :sweat_smile:

Sure, but how much more confused will they be once they open the router's web interface? :wink:

Well he does, i just went with blinkyblink

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.