Production-Grade WAN Management Framework for ASUSWRT-Merlin Routers
A self-scaffolding, CI/CD-integrated deployment system with hardware acceleration awareness, state machine monitoring, and observability built for the GT-AX6000 (BCM4912) and compatible Broadcom-based Merlin routers.
- State Machine: 6-state model (INIT β WAN_WAIT β RULES_APPLY β ACTIVE β DEGRADED/SAFE) with timeout protection
- Hardware Acceleration Gatekeeper: Detects CTF/Flow Accelerator/Runner and validates zapret compatibility
- TCP Health Validation: Beyond ICMP ping - validates actual data flow with TCP handshake checks
- Boot-Time Fallback: Automatic recovery from bad rules via watchdog mechanism
- DHCP Lifecycle Hooks: Integrates with Merlin's dhcpc-event for reliable IP acquisition
- Semantic Versioning: Automated version bumping via Conventional Commits
- GitHub Actions: Free public runners, GHCR container publishing
- Artifact Management: Signed releases, changelog generation, backward compatibility checks
- Safe Upgrade Path: NVRAM migration, dry-run validation, atomic swap
- Embedded Systems Testing: shellspec framework for POSIX-compatible shell scripts
- Static Analysis: ShellCheck linting, NVRAM key validation
- Integration Tests: Simulated DHCP events, state transitions, rule application
- Performance Benchmarks: Throughput validation (CTF enabled vs. disabled vs. zapret)
- State Persistence: Machine-readable state files in
/tmp/netadmin_* - Metric Export: JSON outputs for monitoring integrations
- Boot Watchdog: Prevents infinite boot loops via counter mechanism
- Health Checks: WAN readiness probes, rule validation, hardware acceleration status
# SSH to your router
ssh admin@192.168.1.1
# Download and run installer (dry-run first)
curl -fsSL https://github.com/edcet/netadmin-v3/releases/download/latest/install.sh | sh -s -- --dry-run
# Apply installation
curl -fsSL https://github.com/edcet/netadmin-v3/releases/download/latest/install.sh | sh# Safe mode (minimal rules)
netadmin profile safe
# Standard Verizon throttling bypass
netadmin profile verizon
# Full DPI bypass with zapret
netadmin profile verizon-bypass
# Query current state
netadmin wan-state
netadmin get-stateINIT(0)
β
WAN_WAIT(1) ββββββββββββββββ
β β (timeout 60s)
RULES_APPLY(2) β
β β
ACTIVE(3) ββ DEGRADED(4) ββββ
β
βββ SAFE(5) β error transition
| Mode | CTF | FC | Runner | Throughput | Use Case |
|---|---|---|---|---|---|
| Stock | β | β | β | ~2000 Mbps | Normal routing |
| TTL Spoof | β | β | β | ~800 Mbps | Tethering bypass |
| DPI Bypass | β | β | β | ~200 Mbps | Full anti-throttle |
# Core configuration
netadmin_mode # Current mode: safe, verizon, verizon-bypass
netadmin_state # Current state: 0-5 (see state machine)
netadmin_ttl_mode # TTL spoofing: off, clamp, spoof
netadmin_zapret # DPI bypass: 0 (disabled), 1 (enabled)
netadmin_wan_primary # WAN interface: eth0, eth1, etc.
netadmin_boot_attempts # Boot failure counter (auto-reset after safe revert)# Check current hardware acceleration status
nvram get ctf_disable # 0 = enabled (default), 1 = disabled
nvram get fc_disable
nvram get runner_disable
# Enable zapret (automatically disables CTF)
netadmin profile verizon-bypass
# Expects: ~200 Mbps throughput (vs. 2000 Mbps baseline)# Check WAN readiness (JSON output)
netadmin wan-state
# Output:
# {
# "interface": "eth0",
# "carrier": "up",
# "ip_acquired": "192.168.100.1",
# "gateway_reachable": true,
# "tcp_health_1.1.1.1:443": true,
# "state": "ACTIVE",
# "rules_active": true,
# "hardware_accel": {
# "ctf_enabled": false,
# "fc_enabled": false,
# "runner_enabled": false
# }
# }# Real-time state transitions
tail -f /tmp/netadmin_state.log
# Boot watchdog counter
cat /tmp/netadmin_boot_attempts# Automatic migration (pre-tested on boot)
netadmin migrate --from-v2.1
# Rollback if needed
netadmin rollback-
On Commit (develop):
- ShellCheck lint analysis
- Conventional Commit validation
- Unit tests (shellspec)
-
On PR:
- All above + integration tests
- Hardware acceleration compatibility check
- Performance regression detection
-
On Merge to Main:
- Semantic version bump (auto)
- Release notes generation
- Signed artifact creation
- GHCR container push
- GitHub release publication
| Config | WANβLAN | CPU | Latency | Notes |
|---|---|---|---|---|
| Baseline (CTF) | 1.8-2.0 Gbps | 5% | <1ms | Stock Merlin |
| TTL Spoof | 600-900 Mbps | 50% | 2-5ms | iptables mangle |
| Zapret DPI | 150-300 Mbps | 85% | 5-20ms | NFQUEUE bottleneck |
See PERFORMANCE.md for detailed analysis.
netadmin-v3/
βββ .github/
β βββ workflows/
β β βββ lint.yml # ShellCheck, semantic validation
β β βββ test.yml # Unit + integration tests
β β βββ release.yml # Semantic versioning & release
β β βββ publish.yml # GHCR container publishing
β βββ dependabot.yml # Automated dependency updates
βββ src/
β βββ core/
β β βββ netadmin-lib.sh # State machine, hardware checks
β β βββ wan-state.sh # WAN monitoring & health checks
β β βββ watchdog.sh # Boot-time protection
β βββ hooks/
β β βββ wan-event # Merlin WAN state hook
β β βββ dhcpc-event # DHCP lifecycle hook
β β βββ services-start # Boot initialization
β βββ profiles/
β β βββ safe.sh # Safe mode rules
β β βββ verizon.sh # TTL spoofing
β β βββ verizon-bypass.sh # Full DPI bypass
β βββ cli/
β βββ netadmin # Main CLI interface
βββ tests/
β βββ spec/
β β βββ state_machine_spec.sh
β β βββ hardware_accel_spec.sh
β β βββ wan_health_spec.sh
β β βββ integration_spec.sh
β βββ fixtures/
β β βββ nvram_mock.sh # Mock NVRAM for testing
β β βββ ip_mock.sh # Mock iproute2 for testing
β β βββ iptables_mock.sh # Mock iptables for testing
β βββ bench/
β βββ throughput_test.sh # Performance benchmarking
βββ install/
β βββ install.sh # Main installer with dry-run
β βββ migrate.sh # v2.1 β v3.0 migration
β βββ rollback.sh # Emergency rollback
βββ docs/
β βββ ARCHITECTURE.md # System design
β βββ PERFORMANCE.md # Benchmark analysis
β βββ TROUBLESHOOTING.md # Debug guide
β βββ API.md # Script API reference
βββ .releaserc.json # Semantic release config
βββ .shellcheckrc # ShellCheck rules
βββ Makefile # Local development targets
βββ VERSION # Current version (semantic)
# Install dependencies
make install-dev
# Run tests locally
make test
make lint
# Simulate router environment
make test-router # Runs in busybox container
# Build release artifacts
make release# Automatic on first boot failure:
# 1. Increment /tmp/netadmin_boot_attempts
# 2. After 3 failures β activate fallback
# 3. Load safe profile + revert to last known good
# 4. Alert user in logs# Atomic NVRAM migration with checkpoint
cp -r /jffs/scripts /jffs/scripts.v3.0.backup
netadmin migrate
# On error: auto-restore from backupMIT - See LICENSE file
See CONTRIBUTING.md for guidelines.
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Full Docs