Digital

Linux Network Manager: Multi-Gateway Routing and VPN Automation

Linux Network Manager is a complete bash script I built for advanced Linux network management. This Linux Network Manager automates multi-gateway routing for ZeroTier and WireGuard VPNs, policy-based routing (PBR), NAT configuration, and netplan management, turning complex networking tasks that typically require deep Linux expertise into reproducible, scriptable operations.

Why Linux Network Manager

Servers that participate in multiple VPN networks, ZeroTier for overlay networking, WireGuard for point-to-point tunnels, need careful routing configuration. Traffic must reach the right gateway based on destination: some traffic through the VPN, some direct, some through a specific ISP link. Doing this manually with ip route, iptables, and netplan is error-prone. This script encapsulates years of production routing patterns.

Core Capabilities

  • Multi-gateway routing, automatic configuration for servers with multiple network interfaces and gateways
  • ZeroTier integration, route management for ZeroTier overlay networks with proper gateway selection
  • WireGuard management, tunnel configuration, peer setup, and routing rules for WireGuard VPNs
  • Policy-based routing (PBR), route traffic based on source, destination, or application using custom routing tables
  • NAT configuration, masquerade and SNAT rules for internet sharing through VPN tunnels
  • Netplan automation, generate and apply netplan configurations for Ubuntu systems

Technology Details

  • Language: Bash (POSIX-compatible with Ubuntu extensions)
  • Networking: iproute2, iptables/nftables, netplan
  • VPNs: ZeroTier, WireGuard
  • Target OS: Ubuntu 22.04+ (tested on server and desktop)

Practical Application

As a Fractional CTO, I deploy this across client infrastructure where servers need to route traffic through multiple VPN networks simultaneously. A typical scenario: a server in Dubai connects to client networks via WireGuard, management networks via ZeroTier, and has direct internet access, all requiring different routing policies. This script makes that configuration deterministic and version-controllable, working alongside Ansible-based infrastructure management.

The script is available upon request. Contact me for access or networking consulting.

FAQ

Does it work with other VPN solutions?

The routing logic is generic. ZeroTier and WireGuard have specific integration, but the PBR and NAT modules work with any tunnel interface.

Will it survive a reboot?

Yes. Routes and rules are persisted through netplan configurations and systemd service units. The script generates persistent configs, not just runtime rules.

Can it handle failover between gateways?

Basic failover is supported through metric-based routing. For advanced failover with health checks, I recommend combining with keepalived or custom monitoring.

Is it safe to run on production servers?

The script includes dry-run mode and backup of existing configurations. Always test in a staging environment first, network misconfigurations can cause connectivity loss.

Ilya Arestov, Fractional CTO | Dubai Airport Free Zone (DAFZ), Dubai, UAE | Almaty, Zenkov Street 59, Kazakhstan | +971-585-930-600 | https://t.me/getmonolith
Rate article