Sat Dec 7 update
Optimized code
Added checks and controls for NATMAPT to automatically enable NATMAP after switching between BACKUP and MASTER.
Optimized Features:
The check_and_update function centralizes the configuration check and update process. UCI commands are executed only when changes are required.
Each service’s status is independently checked and logged.
Each configuration item’s state is explicitly logged, recording whether changes are necessary to improve debugging and readability.
Configurations already in the target state are skipped to avoid unnecessary operations.
The restart_odhcpd function consolidates restarts for DHCPv6, RA, and NDP after adjustments.
The main logic is divided into MASTER and BACKUP sections.
If natmap is not installed, related operations are skipped without affecting the configuration of other services.
Tue Dec 3 update:
Includes checks and controls to ensure the BACKUP node can still obtain an IPv6 address while disabling the DHCPv6 service to prevent it from simultaneously distributing IPv6 addresses with the MASTER node.
Applicable for high-availability setups using Keepalived for dual-node failover.
When in BACKUP mode, DNSMASQ’s DHCPv4, DHCPv6, and RA services are disabled.
Upon switching to MASTER, these services are enabled.
This ensures compatibility with setups where DNSMASQ is required by plugins such as AdGuardHome and Passwall2, avoiding disabling the DNSMASQ service itself.
logic_restart() {
# load keepalived_check.sh
/path/to/keepalived_check.sh || true
* * * * * /path/to/keepalived_check.sh