Giter Club home page Giter Club logo

ansible-docker-wireguard's Introduction

Wireguard server ansible role

Suitable to deploy https://github.com/linuxserver/docker-wireguard

Configuration

wireguard_service_name: wireguard
wireguard_docker_image: lscr.io/linuxserver/wireguard

wireguard_host_config_dir: /etc/wireguard
wireguard_host_memory: 32m
wireguard_host_port: 51820

wireguard_port_mappings: []

wireguard_peers:
  - name: peer1
    allowed_ips:
  - name: peer2
    allowed_ips:

wireguard_log_confs: True

Route inbound traffic to wireguard

wireguard_port_mappings:
  - 80:8080/tcp
  - 443:8443/tcp

Configure peers for outbound VPN mode

wireguard_peers:
  - name: peer1
  - name: peer2

Configure peers in site-to-site mode

wireguard_peers:
  - name: peer1
    allowed_ips: 192.168.1.0/24
  - name: peer2
    allowed_ips: 192.168.2.0/24
  - name: peer3
    allowed_ips: 192.168.3.0/24

Customize iptables rules

Works only with https://github.com/dddpaul/docker-wireguard until (and if) linuxserver/docker-wireguard#202 will be merged.

For example, these rules will route inbound traffic to "internal" web servers:

wireguard_post_up: >-
  iptables -t nat -A PREROUTING -p tcp --dport 8080 -j DNAT --to-destination 10.13.13.2:8080;
  iptables -t nat -A PREROUTING -p tcp --dport 8443 -j DNAT --to-destination 10.13.13.3:8443;
  iptables -t nat -A POSTROUTING -p tcp -d 10.13.13.0/24 -j MASQUERADE;
  iptables -A FORWARD -i %%i -j ACCEPT; iptables -A FORWARD -o %%i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth+ -j MASQUERADE
wireguard_post_down: >-
  iptables -t nat -D PREROUTING -p tcp --dport 8080 -j DNAT --to-destination 10.13.13.2:8080;
  iptables -t nat -D PREROUTING -p tcp --dport 8443 -j DNAT --to-destination 10.13.13.3:8443;
  iptables -t nat -D POSTROUTING -p tcp -d 10.13.13.0/24 -j MASQUERADE;
  iptables -D FORWARD -i %%i -j ACCEPT; iptables -D FORWARD -o %%i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth+ -j MASQUERADE

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.