Fast, zero-dependency WireGuard rotating utility

Effortless WireGuard Endpoint Rotation

A lightweight CLI tool built for users with hundreds of VPN profiles (like Mullvad). Seamlessly switch between global endpoints or filter by country code in a single keystroke.

$curl -sL https://raw.githubusercontent.com/joshuacox/wgu/refs/heads/master/bootstrap.sh | bash
Advertisement

Key Features

Engineered with Unix simplicity and reliability in mind.

🎲

Random Endpoint Selection

Picks a random WireGuard configuration file from your configuration directory using native Unix shuf.

🌍

Country-Specific Filtering

Filter configurations dynamically by ISO country code prefix (e.g. wgu us, wgu se).

🔄

Automatic Clean Teardown

Ships with wgd to automatically detect active WireGuard interfaces and cleanly bring them down before rotating.

⚡

Zero Dependencies

Written completely in clean Bash. Runs directly on Debian, Ubuntu, Arch, Fedora, Alpine, or macOS with standard WireGuard packages.

⚙️

Flexible Configuration

Supports environment variables (WG_DIR) or dedicated config files (~/.config/wgu/config).

🛡️

Auto DNS Recovery

Includes fallback triggers for resolvconf -u if DNS resolution gets hung during network interfaces switches.

Installation

First, ensure WireGuard tools (wg-quick) are installed on your machine.

# Run the bootstrap installer:
curl -sL https://raw.githubusercontent.com/joshuacox/wgu/refs/heads/master/bootstrap.sh | bash

Command Usage & Syntax

Rotate endpoints instantly with straightforward commands.

#1 Random Worldwide Rotation

Randomly selects any WireGuard configuration in your directory:

wgu

#2 Target Country Code

Restricts random selection to files matching country prefix:

wgu us    # United States
wgu se    # Sweden
wgu ch    # Switzerland

Configuration Reference

By default, wgu scans /etc/wireguard. You can configure it via environment variables or a configuration file.

Config File Paths~/.config/wgu/config(fallback: ~/.wgu_config)
Environment Variablesexport WG_DIR=/path/to/configsOverrides default directory
VariableDefaultDescription
WG_DIR/etc/wireguardDirectory containing WireGuard .conf files
VERBOSITY1Logging output detail (1 = status, 10+ = bash tracing)
WG_D_B4_U1Automatically run wgd to bring down existing connections before starting
Included Utility

wgd: The Graceful WireGuard Teardown Tool

Inspects active interfaces via sudo wg and runs wg-quick down on all active configurations safely.

$ wgd