Skip to content

francescor/wirego

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 

Repository files navigation

wirego

wirego is a simple script to manage your many Wireguard's profiles

Installation

Just download wirego and save it in a directory of your $PATH, e.g.

wget https://raw.githubusercontent.com/francescor/wirego/main/wirego
chmod +x /usr/local/bin/wirego
sudo mv wirego /usr/local/bin

Examples

List all available Wireguard profiles:

wirego

Turn on Wireguard profile /etc/wireguard/myvpn.conf

wirego myvpn

Turn on many Wireguard profiles

wirego up

Turn down any active Wireguard

wirego down

Generate the QR code of a profile

wirego qr

Why?

Wireguard tool commands wg & wg-quick do not get into my head :( so I've just created this basic script for myself.
In my daily job I take up and down Wireguard's profile a lot, and some together at the same time, so I do use this scrip myself a lot.

Fedora DNS handling is a bit nasty to me: I see I need to execute

sudo systemctl  restart systemd-resolved.service

everytime I turn down Wireguard (to remove from /etc/resolv.conf the DNS added by the Wireguard VPN), so I just added this command once at the end of the script, instead of having to add a PostDown in each wg profile.

Configuration file

An empty configuration file is created in your HOME: ~/.wirego/wirego.profile

It is useful to store a list of Wireguard profiles you want to take up all together

e.g. with this content in ~/.wirego/wirego.profile

# Ordered list of wireguard profiles to take up with `wirego up`
up_profiles="office1 office2 office3"

the command:

wirego up

will activete all three wireguard profiles: note that if profiles set DNS, the last profile will win; at the same time only one profile should have the "catch all" directive: AllowedIPs = 0.0.0.0/0.

Notes, requirements, and limitations

It's just a basic script, written for Fedora Linux (v.33, 34), so you may have to adapt it to your o.s. Feel free to fork and adapt this code, of just suggest changes here.

It requires:

and Wireguard profiles must be saved into the directory: /etc/wireguard

Script is based on the convention that when you activate one profile (or many profiles), all active ones are first taken down.

To generate QR code, install qrencode

sudo dnf install qrencode