Skip to content

HikaruChang/NetPath

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

NetPath - High-performance Multi-WAN Manager

License: CC BY-NC Rust OpenWrt

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.

โœจ Features

  • ๐Ÿš€ 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

๐Ÿ—๏ธ Architecture

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

๐Ÿ“‹ Requirements

Runtime

  • 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

Build

  • Rust 1.70+ with musl/cross-compile target support
  • OpenWrt SDK (for package building)
  • Standard build tools (make, gcc)

๐Ÿš€ Installation

From Package

opkg update
opkg install netpath luci-app-netpath
/etc/init.d/netpath enable
/etc/init.d/netpath start

From Source

# 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/install

โš™๏ธ Configuration

UCI Configuration (OpenWrt)

Edit /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'

TOML Configuration

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.

๐ŸŽฎ Usage

Via Web Interface

Navigate to Network โ†’ NetPath in LuCI.

Via Command Line

# 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

๐Ÿ”ง Load Balancing Modes

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

๐Ÿ“Š Monitoring

Health Check Methods

  • ping: ICMP echo request (default)
  • httping: HTTP/HTTPS connectivity check
  • dns: DNS query resolution
  • arping: ARP-level connectivity
  • none: No health checking

Metrics

  • Interface status (online/offline)
  • Latency (ms)
  • Packet loss (%)
  • Traffic counters (TX/RX bytes)
  • Connection count

๐Ÿ” Debugging

# 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

๐Ÿ†š Comparison with mwan3

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

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit pull requests.

๐Ÿ“„ License

GPL-2.0 - see LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Inspired by mwan3
  • Built on nftables
  • Powered by Rust
  • Integrated with OpenWrt/LuCI

๐Ÿ“ž Support


Note: NetPath is under active development. Production use should be carefully tested in your environment.

About

NetPath is a brand-new multi-WAN management plugin built on the functionality of mwan3, fully re-architected with a modern technology stack to deliver faster, more efficient multi-WAN load balancing and failover capabilities.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors