Coder Social home page Coder Social logo

ansible-wireguard's Introduction

Ansible WireGuard

This creates a VPN server on Ubuntu 18.04 with WireGuard. Script is based on Getting Started with WireGuard.

Requirement

On your client computer :

  • Install WireGuard
  • Generate you client private and public keys :
    umask 077
    wg genkey | tee privatekey | wg pubkey > publickey
  • Install Ansible
  • As root :
    ip link add dev wg0 type wireguard
    ip address add dev wg0 192.168.2.1/24

Usage

The following script does the job to make for example a VPS as a VPN server. Your WireGuard client public key will be asked.

git clone https://github.com/Tazeg/ansible-wireguard.git
cd ansible-wireguard
ansible-playbook -i <IP>, playbooks/wireguard_server.yml -e "ansible_port=2222" -e "ansible_user=root"
  • <IP>: replace with your Ubuntu server public IP
  • -e "ansible_port=2222": optional, if you are not using ssh on port 22
  • -e "ansible_user=root": ssh connexion as root

After running the ansible script, create the file /etc/wireguard/wg0.conf on your client computer and replace <variables> :

# local device
[Interface]
Address = 10.0.0.2/32
PrivateKey = <your client private key>
DNS = 1.1.1.1

# server
[Peer]
PublicKey = <the server public key given by ansible script>
Endpoint = <IP>:51820
AllowedIPs = 0.0.0.0/0
PersistentKeepalive = 25

Then run on your computer :

curl https://ipinfo.io/ip # your computer public IP
sudo wg-quick up wg0
curl https://ipinfo.io/ip # you now have the public IP of the server

To stop connexion :

sudo wg-quick down wg0

ansible-wireguard's People

Contributors

bjmc avatar tazeg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

heartshare

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.