Netgate SG-3100 LEDs: A Network Status Display with pfSense
Use the SG-3100 LEDs for external-IP and LAN-host status, with a configurable shell script, startup steps and troubleshooting.
A step-by-step guide to turning the front RGB LEDs of your Netgate SG-3100 into a small network status display, using the pfSense web interface to create and launch a shell script.
✨ Intro — why I did this
I recently bought a Netgate SG-3100 running pfSense® Plus on its ARM CPU and immediately thought: “Those three LEDs aren’t telling me anything useful!” With one lightweight shell script and three GUI clicks we can make
- Circle LED → Reachability of an external IP address (8.8.8.8)
- Square LED → LAN host 192.168.1.3 (My Unifi AP)
- Diamond LED → LAN host 192.168.1.5 (My HomeLab server / NAS)
update periodically and start automatically at boot.
This is an SG-3100-specific project, not a generic pfSense LED driver. The commands depend on the GPIO interface exposed by the installed firmware. The script below has been reviewed for shell syntax; the revised version has not been re-tested on physical hardware. Back up your pfSense configuration before changing startup commands.
🎯 Results in Action
LED Logic Summary:
- Green WAN = The configured external IP replies to ping
- Red WAN = The external IP did not reply after a retry
- Violet WAN = An enabled DHCP/DNS process check failed
- Off Host LEDs = Local devices responding
- Orange Host LEDs = Local devices unreachable
🛠️ Implementation Details
1 Why a custom script?
- The SG-3100’s IS31FL3193 controller boots in “breathing” mode; we must switch it to PWM before manual colours stick.
- pfSense exposes those PWM registers via
sysctl dev.gpio.*.led.*.pwmandgpioctl, so no kernel hacking is needed. - The Shellcmd package lets any script run automatically late in the boot process. Keep a separate backup of the script: a Shellcmd entry in the configuration does not guarantee that a custom file under
/usr/local/bin/survives an upgrade or reinstall.
Thanks to Zachary Schneider for decoding these registers and sharing them!
2 Packages you need
| Package | Why it matters | Where to install |
|---|---|---|
Shellcmd (pfSense-pkg-Shellcmd) |
Stores a shellcmd line in config.xml so pfSense runs your script after packages load. | System ▸ Package Manager ▸ Available Packages → search shellcmd → Install → Confirm |
No other packages are required; everything else uses built-in utilities.
3 Create the script (Diagnostics ▸ Edit File)
- Diagnostics ▸ Edit File
-
Path to file →
1
/usr/local/bin/led-watch.sh
Click Load (blank editor).
- Paste the script below and adjust its configuration variables.
Set
WAN_TGT,HOST1, andHOST2for your network. Match the optional process names to your DHCP/DNS setup; leave a process variable empty if you do not use that service. Hit Save.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/bin/sh
# SG-3100 LED watcher – external IP + two configured LAN hosts
# forces PWM mode, binds pins, 2-s ping timeout, clears all channels
# ------------------------------------------------------------------
### Detect the GPIO controller #####################################
GPIO=$(sysctl dev.gpio | awk -F. '/\.led\.0/ {print $3; exit}')
if [ -z "$GPIO" ]; then
echo "No compatible GPIO LED controller found" >&2
exit 1
fi
G="/dev/gpioc${GPIO}"
### Put every LED block into PWM mode ##############################
for b in 0 1 2; do # 0=diamond,1=square,2=circle
sysctl -q dev.gpio.${GPIO}.led.$b.pwm=1
done # PWM mode is mandatory for gpioctl … duty to work
### Attach every RGB pin to the LED driver #########################
for p in 0 1 2 3 4 5 6 7 8; do
gpioctl -f "$G" "$p" func led >/dev/null 2>&1
done
### Pin constants ##################################################
DIAMOND_R=0 DIAMOND_G=1 DIAMOND_B=2
SQUARE_R=3 SQUARE_G=4 SQUARE_B=5
CIRCLE_R=6 CIRCLE_G=7 CIRCLE_B=8
# Aliases for readability
WAN_R=$CIRCLE_R WAN_G=$CIRCLE_G WAN_B=$CIRCLE_B
H1_R=$SQUARE_R H1_G=$SQUARE_G H1_B=$SQUARE_B
H2_R=$DIAMOND_R H2_G=$DIAMOND_G H2_B=$DIAMOND_B
### Helper ##########################################################
set_led() { gpioctl -f "$G" "$1" duty "$2"; } # 0–255 PWM
### Ping settings ##################################################
PING_T=2 # total ping timeout in seconds, using FreeBSD -t
WAN_TGT=8.8.8.8
HOST1=192.168.1.3
HOST2=192.168.1.5
# Match these to services you actually use; an empty value disables that check.
DHCP_PROCESS=kea-dhcp4
DNS_PROCESS=unbound
### Main loop #######################################################
while :; do
#######
# WAN #
#######
# Optional process checks. This checks process existence, not service health.
if { [ -n "$DHCP_PROCESS" ] && ! pgrep -x "$DHCP_PROCESS" >/dev/null 2>&1; } ||
{ [ -n "$DNS_PROCESS" ] && ! pgrep -x "$DNS_PROCESS" >/dev/null 2>&1; }; then
# Violet = Red + Blue at moderate PWM (12/12)
set_led $WAN_R 12
set_led $WAN_G 0
set_led $WAN_B 12
else
# 2) Enabled process checks passed → check external IP reachability:
# Try one quick ping to WAN_TGT
if /sbin/ping -q -c1 -t "$PING_T" "$WAN_TGT" >/dev/null 2>&1; then
# WAN is reachable → green
set_led $WAN_R 0
set_led $WAN_G 2
set_led $WAN_B 0
else
# Wait 2s and try again
sleep 2
if /sbin/ping -q -c1 -t "$PING_T" "$WAN_TGT" >/dev/null 2>&1; then
# Temporary glitch, now reachable → green
set_led $WAN_R 0
set_led $WAN_G 3
set_led $WAN_B 0
else
# Still unreachable → red
set_led $WAN_R 255
set_led $WAN_G 0
set_led $WAN_B 0
fi
fi
fi
sleep 1
##########
# Host 1 #
##########
if /sbin/ping -q -c1 -t "$PING_T" "$HOST1" >/dev/null 2>&1; then
# reachable → off
set_led $H1_R 0
set_led $H1_G 0
set_led $H1_B 0
else
# down → dim orange
set_led $H1_R 100
set_led $H1_G 10
set_led $H1_B 0
fi
sleep 1
##########
# Host 2 #
##########
if /sbin/ping -q -c1 -t "$PING_T" "$HOST2" >/dev/null 2>&1; then
# reachable → off
set_led $H2_R 0
set_led $H2_G 0
set_led $H2_B 0
else
# down → dim orange
set_led $H2_R 100
set_led $H2_G 10
set_led $H2_B 0
fi
sleep 18
done
4 Make it executable (Diagnostics ▸ Command Prompt)
Open Diagnostics ▸ Command Prompt and run:
1
chmod +x /usr/local/bin/led-watch.sh
5 Test the script (Diagnostics ▸ Command Prompt)
Run the script in the background:
1
/usr/local/bin/led-watch.sh &
The first status should appear shortly after launch. Each loop includes 20 seconds of sleep plus the time spent probing hosts, so failures make the interval longer. If you see no change, check the Troubleshooting table at the end of this post.
Stop the previous watcher before testing another copy. Multiple instances will compete to update the same LEDs.
If you want to stop the script, run:
1
pkill -f led-watch.sh
6 Autostart with pfSense (Services ▸ Shellcmd)
- Services ▸ Shellcmd
- Add a new row:
| Field | Value |
|---|---|
| Command | /usr/local/bin/led-watch.sh & |
| Type | shellcmd |
- Save and apply the entry. Menu labels can differ by package version; use the normal
shellcmdentry rather thanearlyshellcmd.
7 Reboot & verify
Reboot via Diagnostics ▸ Reboot. Verify that one watcher starts and that the LEDs reflect your configured targets. Then briefly test an unreachable LAN address and confirm its LED turns orange.
If a block stays dark:
1
2
3
4
5
GPIO=$(sysctl dev.gpio | awk -F. '/\.led\.0/ {print $3; exit}')
if [ -n "$GPIO" ]; then
for b in 0 1 2; do sysctl "dev.gpio.${GPIO}.led.$b.pwm"; done
gpioctl -f "/dev/gpioc${GPIO}" -l
fi
8 Need darkness?
1
2
3
4
5
6
7
pkill -f led-watch.sh
GPIO=$(sysctl dev.gpio | awk -F. '/\.led\.0/ {print $3; exit}')
if [ -n "$GPIO" ]; then
for p in 0 1 2 3 4 5 6 7 8; do
gpioctl -f "/dev/gpioc${GPIO}" "$p" duty 0
done
fi
9 Troubleshooting table
| Symptom | Likely cause | Fix |
|---|---|---|
| Colours never change | Pin not in LED function | gpioctl -f "$G" <pin> func led |
| Script doesn’t run after reboot | Missing file or startup entry | Confirm the script exists, is executable, and has a normal shellcmd entry |
| WAN stays violet | Process checks do not match the configured services | Adjust DHCP_PROCESS / DNS_PROCESS, or leave an unused check empty |
| LEDs flash random colours on upgrade | PWM flag reset | Re-run sysctl … pwm=1 |
What the LEDs can—and cannot—tell you
A successful ping to 8.8.8.8 confirms a reply from that IP, not that DNS, HTTPS, or every internet service works. A failed ping can also mean ICMP is filtered. Likewise, a running DHCP or DNS process is not proof that it is answering clients correctly.
The timeout uses FreeBSD’s ping -t in seconds. FreeBSD’s -W is measured in milliseconds, unlike the seconds used by some other implementations. See the FreeBSD ping manual.
To remove the customization, delete its Shellcmd entry, stop the watcher, and reboot to return control to the firmware. Keep the saved script separately if you want to restore it later.
🔗 References & thanks
- Zachary Schneider — “Customizing the LEDs on the Netgate SG-3100” — the original inspiration for the pin map and PWM setup. The original URL currently leads to the blog index: Zach’s blog
- Netgate Shellcmd package documentation.
Thanks again, Zach, for blazing the trail and saving the rest of us hours of trial-and-error!




