"Automatic" Wireguard config file generator for PIA (Private Internet Access)

Comments

3 comments

  • Avatar
    Firewalla

    Thank you!

    1
    Comment actions Permalink
  • Avatar
    Windboarder

    Thank you for this!  Does it support multiple PIA WireGuard VPN clients running at the same time on Firewalla?

    0
    Comment actions Permalink
  • Avatar
    Jpflaw00

    Thanks for sharing this.  I had to jump through a couple of hoops to get it to work.  While connecting from a Windows host through SSH, I couldn't use SCP to transfer files from my host over to FWG.  The connection would time out on port 22.  I added a Windows firewall rule (New-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -DisplayName "OpenSSH Server (SSH)" -Enabled True -Direction Inbound -Protocol TCP -LocalPort 22 -Action Allow) to allow SSH traffic through port 22, but SCP still wouldn't work.  Then I thought, if I successfully started a SSH session with FWG, port 22 was definitely open.  I checked 'netstat -an | findstr :22' and saw the connection between my host and FWG on port 22.  Also, 'telnet host_ip 22' resulted in the connection timing out.

    I ended up finding a solution on Reddit, which recommended using the command 'ssh -CD 33333 user@machine'.  After starting a new SSH session, I configured the Windows proxy (Network & internet > Proxy) with Proxy IP address 'localhost' and Port '33333'.  By doing this, I could use the command '$ ssh user@machine "wget https://raw.githubusercontent.com/JasonMeudt/Firewalla-pia-wireguard/refs/heads/main/firewalla-vpn-monitor.sh -O -" > firewalla-vpn-monitor.sh' and '$ ssh user@machine "wget https://raw.githubusercontent.com/JasonMeudt/Firewalla-pia-wireguard/refs/heads/main/pia-firewalla.sh -O -" > pia-firewalla.sh' to grab the two raw files.

    The next issue came up when I executed pia-firewalla.sh.  The password entered was incorrect, so I had to update it under PIA_PASSWORD using nano in '/etc/pia-wg/pia-wg.conf'.  After doing that, I noticed the error '/home/pi/.config/pia-wg/pia.conf not found!'.  I checked '/tmp/pia-wg-output.log' and saw the file was created in '/var/cache/pia-wg/pia.conf' when I ran the script as sudo (later I found out it will appear in the correct directory if you run the script without sudo).  I tried moving it with mv, but the file was deleted.  I had to run pia-firewalla.sh again to generate the file and move the file to the expected directory.  It wouldn't move because '/home/pi/.config/' didn't have the folder pia-wg.  So I had to add the folder with mkdir and then finally move the file as sudo.  I ran pia-firewalla.sh again and finally saw the final message say, "Setup complete. WireGuard configuration copied as WG_USSilic.conf."

    While performing the steps for firewalla-vpn-monitor.sh, I saw the message, "nohup: ignoring input and appending output to 'nohup.out'".  That can be ignored and just informs you that once started the input/output is removed from the console.  To avoid the message you could use the command 'nohup php server1.php </dev/null &>/dev/null &', but I chose not to do that.  The last command I ran 'cat nohup.out' displayed the error 'WireGuard config file not found: /etc/wireguard/vpn_SWISS_PIA.conf', so setup for that region wasn't completed.  I checked '/home/pi/.firewalla/run/wg_profile' and saw the config, json, and settings were missing.

    It's been awhile since I've used bash, so setting this up was a challenging but rewarding experience.  Hopefully this will help someone out.

    0
    Comment actions Permalink

Please sign in to leave a comment.