From 1002f86172681c444962b89df68d3c40c8e0ed6c Mon Sep 17 00:00:00 2001 From: Andreas Wrede Date: Fri, 18 Sep 2026 18:45:59 -0400 Subject: [PATCH] Fix regulatory domain persistence for 5GHz AP on boot Problem: wlan1 regulatory domain not set on boot, defaults to 2.4GHz-only mode, preventing channel 149 (5GHz) from being available. hostapd fails on startup. Solution: 1. Modified regdomain.service to: - Run BEFORE hostapd/hostapd-2g services (Before= directive) - Run earlier in boot (After= sysinit.target) - RemainAfterExit=yes to persist setting 2. Added 80-regdomain.rules udev rule: - Triggers on regulatory device changes - Executes 'iw reg set CA' automatically 3. Added hostapd drop-in config: - Explicitly requires regdomain.service - Adds Wants= to ensure it starts This ensures the regulatory domain is set BEFORE hostapd attempts to use channel 149, fixing the boot-time AP failure loop. Co-Authored-By: Claude Haiku 4.5 --- ap/80-regdomain.rules | 3 +++ ap/hostapd-regdomain.conf | 4 ++++ ap/regdomain.service | 5 +++-- deploy.sh | 3 +++ 4 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 ap/80-regdomain.rules create mode 100644 ap/hostapd-regdomain.conf diff --git a/ap/80-regdomain.rules b/ap/80-regdomain.rules new file mode 100644 index 0000000..080dc39 --- /dev/null +++ b/ap/80-regdomain.rules @@ -0,0 +1,3 @@ +# Set wireless regulatory domain on boot +# Trigger when regulatory device appears +SUBSYSTEM=="regulatory", ACTION=="change", RUN+="/usr/sbin/iw reg set CA" diff --git a/ap/hostapd-regdomain.conf b/ap/hostapd-regdomain.conf new file mode 100644 index 0000000..5ffd2d5 --- /dev/null +++ b/ap/hostapd-regdomain.conf @@ -0,0 +1,4 @@ +# Ensure regdomain.service runs before hostapd +[Unit] +After=regdomain.service +Wants=regdomain.service diff --git a/ap/regdomain.service b/ap/regdomain.service index f9de904..638a543 100644 --- a/ap/regdomain.service +++ b/ap/regdomain.service @@ -1,9 +1,10 @@ [Unit] Description=Set wireless regulatory domain -After=network-pre.target -Before=NetworkManager.service +After=network-pre.target sysinit.target +Before=hostapd.service hostapd-2g.service NetworkManager.service [Service] Type=oneshot +RemainAfterExit=yes ExecStart=/usr/sbin/iw reg set CA [Install] WantedBy=multi-user.target diff --git a/deploy.sh b/deploy.sh index c3d676f..c0b42f1 100755 --- a/deploy.sh +++ b/deploy.sh @@ -116,9 +116,11 @@ fi echo "== access point ==" install_rendered ap/hostapd.conf /etc/hostapd/hostapd.conf install -D -m0644 ap/hostapd-restart.conf /etc/systemd/system/hostapd.service.d/restart.conf +install -D -m0644 ap/hostapd-regdomain.conf /etc/systemd/system/hostapd.service.d/regdomain.conf install -D -m0644 ap/default-hostapd /etc/default/hostapd install_rendered ap/hostapd-2g.conf /etc/hostapd/hostapd-2g.conf install_rendered ap/hostapd-2g.service /etc/systemd/system/hostapd-2g.service +install -D -m0644 ap/hostapd-regdomain.conf /etc/systemd/system/hostapd-2g.service.d/regdomain.conf install_rendered ap/11-van-ap-2g.network /etc/systemd/network/11-van-ap-2g.network install -D -m0644 ap/van-ap-watchdog-2g.service /etc/systemd/system/van-ap-watchdog-2g.service install -D -m0755 ap/van-ap-watchdog /usr/local/sbin/van-ap-watchdog @@ -139,6 +141,7 @@ install_rendered ap/van-ap-unmanaged.conf /etc/NetworkManager/conf.d/van-ap-un ln -sfn /dev/null /etc/systemd/network/zzzz-dracut-default.network install -D -m0644 ap/nftables.conf /etc/nftables.conf install -D -m0644 ap/regdomain.service /etc/systemd/system/regdomain.service +install -D -m0644 ap/80-regdomain.rules /etc/udev/rules.d/80-regdomain.rules install -D -m0644 ap/rtw89.conf /etc/modprobe.d/rtw89.conf install -D -m0644 ap/99-van-router.conf /etc/sysctl.d/99-van-router.conf