Git Product home page Git Product logo

poor-mans-vpn's Introduction

Poor man's VPN (pay for only what you need)

An ansible playbook to quickly set up Wireguard server for occasional personal use. It takes around five minutes to set this up. Spin up a VM, run the playbook, do your business and delete the VM.

Motivation: Lately due to GDPR many websites are blocking access in the EU. For me, I cannot order medicines back home via netmeds.com or book flights/hotels via makemytrip.com (as of December 2021). With wireguard and this playbook it becomes trivial to perform these tasks for very little cost.

Setup

  • Create a vm at your desired location from your favorite provider
    • I have tested with a $5 DigitalOcean droplet with Ubuntu 20.04 LTS
  • Make sure you can ssh into the machine with default public key
  • Install & start the wireguard client app
  • Create an empty tunnel
  • Copy the client public key

Create python environment

virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
deactivate

Run the playbook

Make sure your wireguard connection is deactivated

source venv/bin/activate
ansible-playbook -i <server public ip>, -u <server username> playbook.yaml

Prompts

Client public key: <copy from wireguard client app>
Allowed IPs [10.0.0.3]: 
Wireguard listen port [51820]: 

Running the playbook multiple times will change the server private/public keys. Make sure to copy the new public key into the client config each time.

Client configuration

Edit the tunnel configurations so that it looks like this

[Interface]
PrivateKey = <auto generated for client>
Address = 10.0.0.3/24
DNS = 1.1.1.1, 1.0.0.1

[Peer]
PublicKey = <server wg public key / changes every time we run the playbook>
AllowedIPs = 0.0.0.0/0
Endpoint = <server public ip>:<wg port>

poor-mans-vpn's People

Contributors

amritb avatar lvnilesh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

poor-mans-vpn's Issues

Failing when running on Mac with M1

Failed running on Mac with M1 chip using DO droplet

PLAY [Wireguard server setup]*********************************************

TASK [Gathering Facts] ****************************************************
ok: [xxx.xx.xx.xx]

TASK [apt update] *********************************************************
ok: [xxx.xx.xx.xx]

TASK [Install wireguard] ***************************************************
changed: [xxx.xx.xx.xx]

TASK [wg0 down in case it's up] *******************************************
fatal: [xxx.xx.xx.xx]: FAILED! => {"changed": true, "cmd": "wg-quick down wg0", "delta": "0:00:00.017250", "end": "2022-01-14 05:39:29.010561", "msg": "non-zero return code", "rc": 1, "start": "2022-01-14 05:39:28.993311", "stderr": "wg-quick: `/etc/wireguard/wg0.conf' does not exist", "stderr_lines": ["wg-quick: `/etc/wireguard/wg0.conf' does not exist"], "stdout": "", "stdout_lines": []}
...ignoring

TASK [Create wireguard keys directory] ************************************
changed: [xxx.xx.xx.xx]

TASK [Create wg server and client keys] ***********************************
changed: [xxx.xx.xx.xx]

TASK [Get server key] *****************************************************
changed: [xxx.xx.xx.xx]

TASK [Create wg0.conf from template] ************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: If you are using a module and expect the file to exist on the remote, see the remote_src option
fatal: [xxx.xx.xx.xx]: FAILED! => {"changed": false, "msg": "Could not find or access 'wg0.conf.j2'\nSearched in:\n\t/poor-mans-vpn/templates/wg0.conf.j2\n\t/poor-mans-vpn/wg0.conf.j2\n\t/poor-mans-vpn/templates/wg0.conf.j2\n\t/poor-mans-vpn/wg0.conf.j2 on the Ansible Controller.\nIf you are using a module and expect the file to exist on the remote, see the remote_src option"}

PLAY RECAP **************************************************************
xxx.xx.xx.xx             : ok=7    changed=5    unreachable=0    failed=1    skipped=0    rescued=0    ignored=1   

What's the benefit instead of running Wireguard in a Docker container?

Why are you not using Docker(-Compose) instead of installing and setting up Wireguard?

Setting up a VM with Ansible is really great ๐Ÿ‘๐Ÿป but why do you not use a docker container? This would make your playbook much easier (install docker and docker-compose, copy docker-compose.yml and execute docker-compose)

For example:
https://github.com/linuxserver/docker-wireguard#usage

---
version: "2.1"
services:
  wireguard:
    image: lscr.io/linuxserver/wireguard
    container_name: wireguard
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/London
      - SERVERURL=wireguard.domain.com #optional
      - SERVERPORT=51820 #optional
      - PEERS=1 #optional
      - PEERDNS=auto #optional
      - INTERNAL_SUBNET=10.13.13.0 #optional
      - ALLOWEDIPS=0.0.0.0/0 #optional
    volumes:
      - /path/to/appdata/config:/config
      - /lib/modules:/lib/modules
    ports:
      - 51820:51820/udp
    sysctls:
      - net.ipv4.conf.all.src_valid_mark=1
    restart: unless-stopped

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.