This repository contains scripts and configuration files to set up a WireGuard VPN on an Ubuntu system. Follow the steps below to install and configure the VPN.
- Ubuntu system
yq
installed (for YAML parsing)sed
installed (for text replacement)
.
├── README.md
├── scripts/
│ ├── generate-configs.sh
│ ├── install-packages.sh
│ ├── setup-base-firewall.sh
│ ├── setup-ubuntu.sh
│ ├── setup-vpn-routing.sh
│ └── teardown-vpn-routing.sh
├── systemd/
│ ├── vpn-sync.service
│ └── vpn-sync.timer
└── template/
└── wiregaurd.congs
-
Install Required Packages
Run the
install-packages.sh
script to install the necessary packages../scripts/install-packages.sh
-
Ensure Scripts are Executable
Make sure all scripts are executable.
chmod +x scripts/*.sh
-
Generate Configuration Files
Run the
generate-configs.sh
script to generate the WireGuard configuration files based on the parameters inconfig-params.yml
../scripts/generate-configs.sh
-
Copy Configuration Files
Copy the generated configuration files to the WireGuard directory.
sudo cp configs/*.conf /etc/wireguard/ sudo chmod 600 /etc/wireguard/*.conf
-
Set Up Base Firewall
Run the
setup-base-firewall.sh
script to set up the base firewall rules../scripts/setup-base-firewall.sh
-
Set Up VPN Routing
Run the
setup-vpn-routing.sh
script to set up the VPN routing../scripts/setup-vpn-routing.sh
-
Enable and Start VPN Sync Timer
Enable and start the
vpn-sync.timer
to periodically sync the VPN configuration.sudo cp systemd/vpn-sync.service /etc/systemd/system/ sudo cp systemd/vpn-sync.timer /etc/systemd/system/ sudo systemctl daemon-reload sudo systemctl enable vpn-sync.timer sudo systemctl start vpn-sync.timer
config-params.yml
: Contains the parameters for each VPN configuration.template/wiregaurd.congs
: Template for generating WireGuard configuration files.
.env
: Contains environment variables such asPRIVATE_KEY
andPRE_SHARED_KEY
.
install-packages.sh
: Installs required packages.setup-base-firewall.sh
: Sets up the base firewall rules.setup-vpn-routing.sh
: Sets up the VPN routing.teardown-vpn-routing.sh
: Tears down the VPN routing.generate-configs.sh
: Generates WireGuard configuration files based onconfig-params.yml
.setup-ubuntu.sh
: Main script to set up the VPN on Ubuntu.
vpn-sync.service
: Systemd service to sync the VPN configuration.vpn-sync.timer
: Systemd timer to periodically run thevpn-sync.service
.
To set up the VPN, run the setup-ubuntu.sh
script.
./scripts/setup-ubuntu.sh
This script will execute all the necessary steps to set up the VPN on your Ubuntu system.
- Ensure all scripts are executable.
- Verify that the
config-params.yml
file contains the correct parameters for each VPN configuration. - Check the generated configuration files in the
configs/
directory. - Ensure that the
wiregaurd.congs
template file has the correct placeholders.