A WireGuard configuration utility for Private Internet Access
This is a Python utility that generates WireGuard configuration files for the Private Internet Access VPN service. This allows you to take advantage of the WireGuard protocol without relying on PIA's proprietary client.
This was created by reverse engineering the manual-connections script released by PIA. At this stage, the tool is a quick and dirty attempt to get things working. It could break at any moment if PIA makes changes to their API.
pia-wg runs on both Windows and Linux.
- Install the latest version of Python 3
- Select "Add Python to environment variables"
- Install WireGuard
Open a command prompt and navigate to the directory where you placed the pia-wg utility. The following commands will create a virtual Python environment, install the dependencies, and run the tool.
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
python generate-config.py
Follow the prompts. When finished, you can exit the virtual environment with the deactivate
command.
The script should generate a .conf
file that can be imported into the WireGuard utility.
Install dependencies, clone pia-wg project, and create a virual Python environment:
sudo apt install git python3-venv wireguard openresolv
git clone https://github.com/hsand/pia-wg.git
cd pia-wg
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Run the tool, and follow the prompts
python3 generate-config.py
Copy the .conf
file to /etc/wireguard/
, and start the interface
sudo cp PIA-Iceland-1605054556.conf /etc/wireguard/wg0.conf
sudo wg-quick up wg0
You can shut down the interface with sudo wg-quick down wg0
For headless usage, you can optionally pass the following arguments when running the generate-config.py
script:
--region
: The PIA region. If not provided, you will be prompted to choose a region.--username
: The PIA username. If not provided, you will be prompted to enter your username.--password
: The PIA password. If not provided, you will be prompted to enter your password securely.--output
: The output file path. If not provided, the configuration file will be saved in the current directory.
Here is an example of how to run the script with these arguments:
python generate-config.py --region "US East" --username "myusername" --password "mypassword" --output "/path/to/output.conf"
## Check everything is working
Visit https://dnsleaktest.com/ to see your new IP and check for DNS leaks.