Copyright (c) 2024-2026 Hikaru (i@rua.moe). All rights reserved.
Non-commercial use only. Attribution required.
A complete rewrite of mwan3 using modern technologies for superior performance and efficiency.
- ๐ High Performance: Written in Rust for maximum speed and memory safety
- ๐ฅ Modern Stack: Uses nftables instead of legacy iptables
- โก Efficient: Async I/O and optimized algorithms
- ๐ฏ Flexible Policies: Multiple load balancing modes (balanced, failover, round-robin, hash-based, weighted)
- ๐ Health Tracking: ICMP ping, HTTP ping, DNS, ARP monitoring
- ๐ Real-time Metrics: Live interface statistics and traffic visualization
- ๐ Web Interface: Modern LuCI-based management panel
- ๐ Hot Reload: Change configuration without service interruption
- ๐ก IPC Control: Unix socket API for external control
NetPath
โโโ core/ # Rust daemon
โ โโโ src/
โ โ โโโ main.rs # Entry point
โ โ โโโ config.rs # Configuration management
โ โ โโโ interface.rs # Interface state tracking
โ โ โโโ nft.rs # nftables integration
โ โ โโโ policy.rs # Load balancing policies
โ โ โโโ route.rs # Routing table management
โ โ โโโ track.rs # Health monitoring
โ โ โโโ ipc.rs # IPC server
โ โ โโโ metrics.rs # Metrics collection
โ โโโ Cargo.toml
โโโ luci/ # Web interface
โโโ luasrc/
โ โโโ controller/ # Page controllers
โ โโโ model/cbi/ # Configuration forms
โ โโโ view/ # Templates
โโโ htdocs/ # Static assets
- OpenWrt: 22.03+ (fully tested), 23.05+ (recommended), 24.x/25.x (full support with JavaScript UI)
- nftables: 1.0.6+ (kernel 5.4+), 1.0.9+ recommended for OpenWrt 25.x
- Kernel Modules: nft_core, nft_nat, nft_fib (25.x), nf_conntrack
- System: ip-full, ipset, tc, curl, jsonfilter, bind-dig
- Rust 1.70+ with musl/cross-compile target support
- OpenWrt SDK (for package building)
- Standard build tools (make, gcc)
opkg update
opkg install netpath luci-app-netpath
/etc/init.d/netpath enable
/etc/init.d/netpath start# Build core daemon
cd core
make RUST_TARGET=x86_64-unknown-linux-musl
make install DESTDIR=/tmp/install
# The binary and config files will be in /tmp/installEdit /etc/config/netpath:
config globals 'globals'
option enabled '1'
option nft_table 'netpath'
config interface 'wan'
option enabled '1'
option ifname 'eth0'
option track_method 'ping'
list track_targets '8.8.8.8'
config member 'wan_m1_w1'
option interface 'wan'
option metric '1'
option weight '1'
config policy 'balanced'
list members 'wan_m1_w1'
option mode 'balanced'
config rule 'default_rule'
option policy 'balanced'
Edit /etc/netpath/config.toml:
[global]
enabled = true
nft_table = "netpath"
[interfaces.wan]
ifname = "eth0"
enabled = true
[interfaces.wan.track]
method = "ping"
targets = ["8.8.8.8", "1.1.1.1"]See examples/config.toml for full configuration options.
Navigate to Network โ NetPath in LuCI.
# Start service
/etc/init.d/netpath start
# Reload configuration
/etc/init.d/netpath reload
# Check status (via IPC)
echo '{"cmd":"status"}' | nc -U /var/run/netpath.sock
# Get interface details
echo '{"cmd":"interfaces"}' | nc -U /var/run/netpath.sock
# Enable/disable interface
echo '{"cmd":"enable","interface":"wan"}' | nc -U /var/run/netpath.sock
echo '{"cmd":"disable","interface":"wan"}' | nc -U /var/run/netpath.sock| Mode | Description | Use Case |
|---|---|---|
| balanced | Weighted distribution across all interfaces | General multi-WAN |
| failover | Use interfaces in metric order | High availability |
| round-robin | Rotate through interfaces evenly | Equal distribution |
| hash | Source IP hash-based selection | Session persistence |
| weighted | Random selection with weights | Unequal bandwidth |
| random | Pure random selection | Testing |
- ping: ICMP echo request (default)
- httping: HTTP/HTTPS connectivity check
- dns: DNS query resolution
- arping: ARP-level connectivity
- none: No health checking
- Interface status (online/offline)
- Latency (ms)
- Packet loss (%)
- Traffic counters (TX/RX bytes)
- Connection count
# Check nftables rules
nft list table inet netpath
# View routing tables
ip route show table 1000
ip route show table 1001
# Check routing rules
ip rule show
# View daemon logs
logread | grep netpath
# Test interface tracking
ping -I eth0 8.8.8.8| Feature | mwan3 | NetPath |
|---|---|---|
| Language | Shell scripts | Rust |
| Firewall | iptables | nftables |
| Performance | Moderate | High |
| Memory | Higher | Lower |
| CPU Usage | Higher | Lower |
| Hot Reload | Limited | Full support |
| Async I/O | No | Yes |
| Type Safety | No | Yes |
| Load Balancing Modes | 2 | 6 |
| Health Check Methods | 2 | 4 |
| OpenWrt 25.x Support | Limited | Full (JavaScript UI) |
| Real-time Metrics | No | Yes |
Contributions are welcome! Please feel free to submit pull requests.
GPL-2.0 - see LICENSE file for details.
- Inspired by mwan3
- Built on nftables
- Powered by Rust
- Integrated with OpenWrt/LuCI
- Issues: https://github.com/hikaruchang/netpath/issues
- Discussions: https://github.com/hikaruchang/netpath/discussions
- Donate: 0xdb61B2aD59bdF2A066B7fC9F00f86c3EBc4856B4
Note: NetPath is under active development. Production use should be carefully tested in your environment.