This code was originally based on a Reddit post: DFS Radar Causes 5GHz to Drop and Doesn’t Come Back. I would like to express my gratitude to u/_daphreak_
and u/try_harder_later
for their initial efforts and contributions.
I have interactively modified this code using DeepSeek-V3 together with DeepSeek-R1-Lite, and the git history reflects the changes made during the process. I am highly satisfied with the capabilities of both DeepSeek-V3 and DeepSeek-R1-Lite, which have significantly streamlined the development and optimization of this script.
The script dfscheck.sh
is designed to monitor the status of wireless interfaces on OpenWrt routers, specifically handling Dynamic Frequency Selection (DFS) channels and radar detection events. When a radar signal causes the wireless interface to shut down, the script automatically switches to a fallback channel to maintain network connectivity and attempts to switch back to the original channel after a specified period.
fixed
, linear
, and exponential
backoff strategies for retries after connectivity failures. The default backoff strategy is fixed
.dfscheck.sh
in the /root/
directory.chmod +x /root/dfscheck.sh
.Assuming the following configuration:
Run the command:
/root/dfscheck.sh 108 149 fixed
channel
: Primary DFS channel (e.g., 108).fallback_channel
: Fallback channel (e.g., 149).backoff_type
: (Optional) Type of backoff strategy (fixed
, linear
, or exp
). Default is fixed
.logread
. Note that the “connection is okay” message is printed to the console and not logged, to prevent log clogs.To ensure the script runs automatically at startup, create a service in OpenWrt.
The cron method was attempted but resulted in parsing errors, preventing the script from running automatically. Using a service ensures the script starts at boot without relying on cron, providing a more reliable solution.
Use the Service Script from the Repository
The repository includes the service script dfscheck
. Copy this file to the /etc/init.d/
directory:
cp ./dfscheck /etc/init.d/dfscheck
Make the Script Executable
Run the following command to ensure the service script is executable:
chmod +x /etc/init.d/dfscheck
Enable the Service
Run the following command to ensure the service starts automatically at boot:
/etc/init.d/dfscheck enable
Start the Service (Without Rebooting)
To start the service immediately without rebooting the device, run:
/etc/init.d/dfscheck start
Check the Service Status
To verify that the service is running, use the following command:
/etc/init.d/dfscheck status
Reboot the Device (Optional)
If you want to verify that the service starts automatically after a reboot, run:
reboot
By following these steps, the script will automatically run upon router reboot, with logs maintained for management and debugging.
The service file now includes default values for the primary channel ( 108
), fallback channel ( 149
), and backoff type ( fixed
). These values can be customized by modifying the service file or passing arguments when starting the script manually.
fixed
, which uses a constant backoff time of 15 seconds.channel
, fallback_channel
, and backoff_type
), as it automatically identifies the 5G radio and its interfaces.This update ensures the documentation is aligned with the latest script and service file changes, making it easier for users to understand and use the tool.