diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
index 34ebccc..7caa933 100644
--- a/.github/FUNDING.yml
+++ b/.github/FUNDING.yml
@@ -1,5 +1,4 @@
# These are supported funding model platforms
-github: pirate
-patreon: theSquashSH
-custom: https://paypal.me/NicholasSweeting
+github: zx2c4
+patreon: zx2c4
diff --git a/README.md b/README.md
index e7f65af..2895b91 100644
--- a/README.md
+++ b/README.md
@@ -1,14 +1,14 @@
-# The Missing Wireguard Documentation
+# Some Unofficial WireGuard Documentation
-
![](https://i.imgur.com/xePt3qp.png)
+
-API reference guide for Wireguard including Setup, Configuration, and Usage, with examples.
+API reference guide for WireGuard including Setup, Configuration, and Usage, with examples.
-
All credit goes to the WireGuard project, [zx2c4](https://www.zx2c4.com/), [Edge Security](https://www.edgesecurity.com/), and the [open source contributors](https://github.com/WireGuard/WireGuard/graphs/contributors) for the original software,
this is my solo unofficial attempt at providing more comprehensive documentation, API references, and examples.
+
All credit goes to the WireGuard project, [zx2c4](https://www.zx2c4.com/) and the [open source contributors](https://github.com/WireGuard/WireGuard/graphs/contributors) for the original software,
this is my solo unofficial attempt at providing more comprehensive documentation, API references, and examples.
@@ -21,17 +21,16 @@ Nicer HTML page version: https://docs.sweeting.me/s/wireguard
---
-[WireGuard](https://www.wireguard.com/) is a BETA/WIP open-source VPN solution written in C by [Jason Donenfeld](https://www.jasondonenfeld.com) and [others](https://github.com/WireGuard/WireGuard/graphs/contributors), aiming to fix many of the problems that have plagued other modern server-to-server VPN offerings like IPSec/IKEv2, OpenVPN, or L2TP. It shares some similarities with other modern VPN offerings like [Tinc](https://www.tinc-vpn.org/) and [MeshBird](https://github.com/meshbird/meshbird), namely good cipher suites and minimal config.
-
-This is my attempt at writing "The Missing Wireguard Documentation" to make up for the somewhat sparse official docs on an otherwise great piece of software.
+[WireGuard](https://www.wireguard.com/) is an open-source VPN solution written in C by [Jason Donenfeld](https://www.jasondonenfeld.com) and [others](https://github.com/WireGuard/WireGuard/graphs/contributors), aiming to fix many of the problems that have plagued other modern server-to-server VPN offerings like IPSec/IKEv2, OpenVPN, or L2TP. It shares some similarities with other modern VPN offerings like [Tinc](https://www.tinc-vpn.org/) and [MeshBird](https://github.com/meshbird/meshbird), namely good cipher suites and minimal config. As of 2020-01 [it's been merged into the 5.6 version of the Linux kernel](https://arstechnica.com/gadgets/2020/01/linus-torvalds-pulled-wireguard-vpn-into-the-5-6-kernel-source-tree/), meaning it will ship with most Linux systems out-of-the-box.
**Official Links**
- Homepage: https://www.wireguard.com
- Install: https://www.wireguard.com/install/
- QuickStart: https://www.wireguard.com/quickstart/
+- Manpages: [`wg`](https://manpages.debian.org/testing/wireguard-tools/wg.8.en.html), [`wg-quick`](https://manpages.debian.org/unstable/wireguard-tools/wg-quick.8.en.html)
- Main Git repo: https://git.zx2c4.com/WireGuard/
-- Github Mirror: https://github.com/WireGuard/WireGuard
+- GitHub Mirror: https://github.com/WireGuard/WireGuard
- Mailing List: https://lists.zx2c4.com/mailman/listinfo/wireguard
**WireGuard Goals**
@@ -57,13 +56,16 @@ See https://github.com/pirate/wireguard-docs for example code and documentation
- Table of Contents
-- Intro
+- Intro
+
-- Wireguard Documentation
-- Glossary
+- WireGuard Documentation
+
+- Glossary
+
-- How WireGuard Works
+- How WireGuard Works
+
-- Usage
-- Quickstart
+- Usage
+
-- Config Reference
+- Config Reference
+
-- Advanced Topics
-- Example Server-To-Server Config with Roaming Devices
-
-- Further Reading
+- Further Reading
+
- Reference Docs
- Tutorials
- Papers, Articles, and Talks
@@ -146,50 +135,90 @@ See https://github.com/pirate/wireguard-docs for example code and documentation
# Intro
-Over the last 8+ years I've tried a wide range of VPN solutions. Somewhat out of necessity, since the city I was living in was behind the Great Wall of China. Everything from old-school PPTP to crazy round-robin GoAgent AppEngine proxy setups were common back in the early 2010's to break through the GFW, these days it's mostly OpenVPN, StealthVPN, IPSec/IKEv2 and others. From the recommendation of a few people in the [RC](https://recurse.com) Zulip community, I decided to try WireGuard and was surprised to find it checked almost all the boxes.
+Whether living behind the Great Wall of China or just trying to form a network between your servers, WireGuard is a great option and serves as a "lego block" for building networks (much in the same way that ZFS is a lego block for building filesystems).
-## My Personal Requirements for a VPN Solution
+## WireGuard Overview
- - minimal config, low config surface area and few exposed tunables
- - minimal key management overhead, 1 or 2 preshared keys or certs is ok, but ideally not both
- - ability to easily create a LAN like 10.0.0.0/24 between all my servers, every peer can connect to every peer,
- - ability to bust through NATs with a signalling server, routing nat-to-nat instead of through a relay (WebRTC-style)
- - fallback to relay server when nat-to-nat busting is unavailable or unreliable
- - ability to route to a fixed list of ips/hosts with 1 keypair per host (not needed, but nice to have: ability to route arbitrary local traffic or *all* internet traffic to a given host)
+ - minimal config, low tunable surface area and sane defaults
+ - minimal key management work needed, just 1 public & 1 private key per host
+ - behaves like a normal ethernet interface, behaves well with standard kernel packet routing rules
+ - ability to easily create a LAN like 192.0.2.0/24 between all servers, or more complex networks using custom routes
+ - ability to some traffic or all traffic to/through arbitrary hosts on the VPN LAN
- robust automatic reconnects after reboots / network downtime / NAT connection table drops
- - fast (lowest possible latency and line-rate bandwidth)
- - encrypted, and secure by default (not needed, nice to have: short copy-pastable key pairs)
+ - fast (low latency and line-rate bandwidth)
+ - modern encryption, secure by default with forward secrecy & resilience to downgrade attacks
- ideally support for any type of Level 2 and control traffic, e.g. ARP/DHCP/ICMP (or ideally raw ethernet frames), not just TCP/HTTP
- - ability to join the VPN from Ubuntu, FreeBSD, iOS, macOS (Windows/Android not needed but would be nice)
- - not a requirement, but ideally it would support running in docker with a single container, config file, and preshared key on each server, but with a full network interface exposed to the host system (maybe with tun/tap on the host passing traffic to the container, but ideally just a single container + config file without outside dependencies)
+ - ability to join the VPN from Ubuntu, FreeBSD, iOS, MacOS, Windows, Android (via open-source apps or natively)
+ - supports both running on the host routing traffic for docker or running in a docker container routing for the host
-## List of Possible VPN Solutions
+**Things WireGuard does not do:**
+- form a self-healing mesh network where nodes automatically gossip with neighbors
+- break through double NATs with a signalling server (WebRTC-style)
+- handle automatically distributing & revoking keys through a central authority
+- allow sending raw layer-2 ethernet frames (it's at the IP layer)
+
+But you can write your own solutions for these problems using WireGuard under the hood (like [Tailscale](https://github.com/tailscale/tailscale) or [AltheaNet](https://althea.net/)).
+
+## List of Other VPN Solutions
+
+ - [WireGuard](https://www.wireguard.com/)
+ - [IPSec (IKEv2)](https://github.com/jawj/IKEv2-setup)/strongSwan: in my experience, there was lots of brittle config that was different for each OS, the NAT busting setup is very manual and involves updating the central server and starting all the others in the correct order, it wasn't great at becoming stable again after network downtime, had to be manually restarted often. your mileage may vary.
+ - [OpenVPN](https://openvpn.net/vpn-server-resources/site-to-site-routing-explained-in-detail/): can work over UDP or be disguised as HTTPS traffic over TCP
+ - StealthVPN: haven't tried it, should I?
+ - [DsVPN](https://github.com/jedisct1/dsvpn): I think it does TCP-over-TCP which usually doesn't end well...
+ - [SoftEther](https://www.softether.org/) ([SSTP](https://en.wikipedia.org/wiki/Secure_Socket_Tunneling_Protocol)): haven't tried it yet, should I? (also does TCP-over-TCP?)
+ - L2TP: somewhat outdated
- PPTP: ancient, inflexible, insecure, doesn't solve all the requirements
- - L2TP: meh
- - SOCKS: proxy tunnel, not a VPN, not great for this use case
- - [IPSec (IKEv2)](https://github.com/jawj/IKEv2-setup)/strongSwan: lots of brittle config that's different for each OS, NAT busting setup is very manual and involves updating the central server and starting all the others in the correct order, not great at reconnecting after network downtime, had to be manually restarted often
- - [TINC](https://www.tinc-vpn.org/): haven't tried it yet, but it doesn't work on iOS, worst case scenario I could live with that if it's the only option
- - [OpenVPN](https://openvpn.net/vpn-server-resources/site-to-site-routing-explained-in-detail/): I don't like it from past experience but could be convinced if it's the only option
- - StealthVPN: haven't tried it
+ - SOCKS/SSH: good for proxying single-port traffic, not a full networking tunnel or VPN
+
+### Mesh VPN Solutions
+
+ - [TINC](https://www.tinc-vpn.org/): haven't tried it yet, but it doesn't work on iOS, worst case scenario I could live
+ - [VPNCloud](https://github.com/dswd/vpncloud): similar properties to WireGuard, with more auto-mesh features
+ - [cjdns](https://github.com/cjdelisle/cjdns): haven't tried it yet, should I?
+ - [ZeroTier](https://www.zerotier.com): haven't tried it yet, should I
- [MeshBird](https://github.com/meshbird/meshbird): "Cloud native" VPN/networking layer
- - [Algo](https://github.com/trailofbits/algo): haven't tried it yet, should I?
- - [Striesand](https://github.com/StreisandEffect/streisand): haven't tried it yet, what's the best config to try?
- - [SoftEther](https://www.softether.org/): haven't tried it yet, should I?
- - [WireGuard](https://www.wireguard.com/): the subject of this post
- - [ZeroTier](https://www.zerotier.com): haven't tried it yet, should I?
+ - [Yggdrasil Network](https://yggdrasil-network.github.io/): Yggdrasil is a self-arranging IPv4/IPv6 mesh VPN (haven't tried it yet)
+
+### VPN Setup Tools
+
+ - [Algo](https://github.com/trailofbits/algo) WireGuard setup tool
+ - [Striesand](https://github.com/StreisandEffect/streisand) Multi-protocol setup tool
+ - [IKEv2-setup](https://github.com/jawj/IKEv2-setup) IKEv2 server setup script
+ - [WireGuard-Manager](https://github.com/complexorganizations/wireguard-manager) WireGuard setup tool, all in one
---
-# Wireguard Documentation
+# WireGuard Documentation
---
## Glossary
+### Example Strings
+
+These are demo hostnames, domain names, IP addresses, and ranges used in the documentation and example configs.
+Replace them with your preferred values when doing your own setup.
+
+- Example domain: `example-vpn.dev` can be replaced with any publicly accessible domain you control
+- Example hostnames: `public-server1`, `public-server2`, `home-server`, `laptop`, `phone` can be changed to your device hostnames
+- IP addresses & ranges: `192.0.2.1/24`, `192.0.2.3`, `192.0.2.3/32`, `2001:DB8::/64` can be replaced with your preferred subnets and addresses (e.g. `192.168.5.1/24`)
+
+Wherever you see these strings below, they're just being used as placeholder values to illustrate an example and have no special meaning.
+
+**Make sure to change the IP addresses in your configs!** The blocks used in these docs
+are reserved for example purposes by the IETF and should never be used in real network setups.
+
+ - **`192.0.2.0/24`** (TEST-NET-1) IPv4 example range [RFC5737](https://tools.ietf.org/html/rfc5737)
+ - **`2001:DB8::/32`** IPv6 example range [RFC3849](https://tools.ietf.org/html/rfc3849)
+
+You can use any private range you want for your own setups, e.g. `10.0.44.0/24`, just make sure
+they don't conflict with any of the LAN subnet ranges your peers are on.
+
### Peer/Node/Device
-A host that connects to the VPN and has registers a VPN subnet address like 10.0.0.3 for itself. It can also optionally route traffic for more than its own address(es) by specifying subnet ranges in comma-separated CIDR notation.
+A host that connects to the VPN and registers a VPN subnet address such as `192.0.2.3` for itself. It can also optionally route traffic for more than its own address(es) by specifying subnet ranges in comma-separated CIDR notation.
### Bounce Server
@@ -197,37 +226,37 @@ A publicly reachable peer/node that serves as a fallback to relay traffic for ot
### Subnet
-A group of IPs separate from the public internet, e.g. 10.0.0.1-255 or 192.168.1.1/24. Generally behind a NAT provided by a router, e.g. in office internet LAN or a home WiFi network.
+A group of IPs separate from the public internet, e.g. 192.0.2.1-255 or 192.168.1.1/24. Generally behind a NAT provided by a router, e.g. in office internet LAN or a home Wi-Fi network.
### CIDR Notation
A way of defining a subnet and its size with a "mask", a smaller mask = more address bits usable by the subnet & more IPs in the range. Most common ones:
- + `10.0.0.1/32` (a single ip address, `10.0.0.1`) netmask = `255.255.255.255`
- + `10.0.0.1/24` (255 ips from `10.0.0.1`-`255`) netmask = ` 255.255.255.0`
- + `10.0.0.1/16` (65,536 ips from `10.0.0.0` - `10.0.255.255`) netmask = `255.255.0.0`
- + `10.0.0.1/8` (16,777,216 ips from `10.0.0.0` - `10.255.255.255`) netmask = `255.0.0.0`
- + `0.0.0.1/0` (4,294,967,296 ips from `0.0.0.0` - `255.255.255.255`) netmask = `0.0.0.0`
- + IPv6 CIDR notation is also supported e.g. `fd42:42:42::1/64`
+ + `192.0.2.1/32` (a single IP address, `192.0.2.1`) netmask = `255.255.255.255`
+ + `192.0.2.1/24` (255 IPs from `192.0.2.0`-`192.0.2.255`) netmask = ` 255.255.255.0`
+ + `192.0.2.1/16` (65,536 IPs from `192.0.0.0` - `192.0.255.255`) netmask = `255.255.0.0`
+ + `192.0.2.1/8` (16,777,216 IPs from `192.0.0.0` - `192.255.255.255`) netmask = `255.0.0.0`
+ + `0.0.0.1/0` (4,294,967,296 IPs from `0.0.0.0` - `255.255.255.255`) netmask = `0.0.0.0`
+ + IPv6 CIDR notation is also supported e.g. `2001:DB8::/64`
https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing
-To people just getting started `10.0.0.1/32` may seem like a weird and confusing way to refer to a single IP. This design is nice though because it allows peers to expose multiple IPs if needed without needing multiple notations. Just know that anywhere you see something like `10.0.0.3/32`, it really just means `10.0.0.3`.
+To people just getting started `192.0.2.1/32` may seem like a weird and confusing way to refer to a single IP. This design is nice though because it allows peers to expose multiple IPs if needed without needing multiple notations. Just know that anywhere you see something like `192.0.2.3/32`, it really just means `192.0.2.3`.
### NAT
-A subnet with private IPs provided by a router standing in front of them doing Network Address Translation, individual nodes are not publicly accessible from the internet, instead the router keeps track of outgoing connections and forwards responses to the correct internal ip (e.g. standard office networks, home wifi networks, free public wifi networks, etc)
+A subnet with private IPs provided by a router standing in front of them doing Network Address Translation, individual nodes are not publicly accessible from the internet, instead the router keeps track of outgoing connections and forwards responses to the correct internal IP (e.g. standard office networks, home Wi-Fi networks, free public Wi-Fi networks, etc)
### Public Endpoint
-The publicly accessible address:port for a node, e.g. `123.124.125.126:1234` or `some.domain.tld:1234` (must be accessible via the public internet, generally can't be a private ip like `10.0.0.1` or `192.168.1.1` unless it's directly accessible using that address by other peers on the same subnet).
+The publicly accessible address:port for a node, e.g. `123.124.125.126:1234` or `some.domain.tld:1234` (must be accessible via the public internet, generally can't be a private IP like `192.0.2.1` or `192.168.1.1` unless it's directly accessible using that address by other peers on the same subnet).
### Private key
-A wireguard private key for a single node, generated with:
+A WireGuard private key for a single node, generated with:
`wg genkey > example.key`
(never leaves the node it's generated on)
### Public key
-A wireguard public key for a single node, generated with:
+A WireGuard public key for a single node, generated with:
`wg pubkey < example.key > example.key.pub `
(shared with other peers)
@@ -235,24 +264,17 @@ A wireguard public key for a single node, generated with:
Domain Name Server, used to resolve hostnames to IPs for VPN clients, instead of allowing DNS requests to leak outside the VPN and reveal traffic. Leaks are testable with http://dnsleak.com.
-### Example Strings
-
-`example-vpn.dev`, `public-server1`, `public-server2`, `home-server`, `laptop`, `phone`
-
-These are demo host and domain names used in the example config.
-Replace them with your own names when doing your actual setup.
-
---
## How WireGuard Works
### How Public Relay Servers Work
-Public relays are just normal VPN peers that are able to act as an intermediate relay server between any VPN clients behind NATs, they can forward any VPN subnet traffic they receives to the correct peer at the system level (WireGuard doesn't care how this happens, it's handled by the kernel `net.ipv4.ip_forward = 1` and the iptables routing rules).
+Public relays are just normal VPN peers that are able to act as an intermediate relay server between any VPN clients behind NATs, they can forward any VPN subnet traffic they receive to the correct peer at the system level (WireGuard doesn't care how this happens, it's handled by the kernel `net.ipv4.ip_forward = 1` and the iptables routing rules).
If all peers are publicly accessible, you don't have to worry about special treatment to make one of them a relay server, it's only needed if you have any peers connecting from behind a NAT.
-Each client only needs to define the publicly accessible servers/peers in it's config, any traffic bound to other peers behind NATs will go to the catchall VPN subnet (e.g. `10.0.0.1/24`) in the public relays `AllowedIPs` route and will be forwarded accordingly once it hits the relay server.
+Each client only needs to define the publicly accessible servers/peers in its config, any traffic bound to other peers behind NATs will go to the catchall VPN subnet (e.g. `192.0.2.1/24`) in the public relays `AllowedIPs` route and will be forwarded accordingly once it hits the relay server.
In summary: only direct connections between clients should be configured, any connections that need to be bounced should not be defined as peers, as they should head to the bounce server first and be routed from there back down the vpn to the correct client.
@@ -261,20 +283,15 @@ In summary: only direct connections between clients should be configured, any co
More complex topologies are definitely achievable, but these are the basic routing methods used in typical WireGuard setups:
- **Direct node-to-node**
- In the best case, the nodes are on the same LAN or are both publicly accessible, and traffic will route over encrypted UDP packets sent directly between the nodes.
+ In the simplest case, the nodes will either be on the same LAN or both be publicly accessible. Define directly accessible nodes with hardcoded `Endpoint` addresses and ports so that WireGuard can connect straight to the open port and route UDP packets without intermediate hops.
- **Node behind local NAT to public node**
- When 1 of the 2 parties is behind a remote NAT (e.g. when laptop behind a NAT connects to `public-server2`), the connection will be opened from NAT -> public client, then traffic will route directly between them in both directions as long as the connection is kept alive.
-- **Node behind local NAT to node behind remote NAT (via UDP NAT hole-punching)**
- "Hole Punching" refers to triggering automatic NAT rules of a router in order to allow inbound traffic. When you send a UDP packet out, the router (usually) creates a temporary rule mapping your source address and port to the destination address and port, and vice versa. This is how most UDP applications function behind NATs (e.g. Bittorent, Skype, etc). UDP packets returning from the destination address and port (and no other) are passed through to the original source address and port (and no other). This rule will timeout after some minutes of inactivity, so the client behind the NAT must send regular outgoing packets to keep it open (see `PersistentKeepalive`).
- Getting this to work when both end-points are behind NATs or firewalls would require that both end-points send packets to each-other at about the same time. This means that both sides need to know each-other's public IP addresses and port numbers and need to communicate this to each-other by some other means (in our case by defining them in `wg0.conf`).
- WireGuard punches holes through NATs natively as a side effect of its UDP-based design, but it only works if a `ListenPort` is hardcoded for the peer behind the NAT. It does not search for a hole-punching port dynamically like WebRTC/N2N as it has no concept of a signaling server to communicate the port to the other side, it only works with a hardcoded port and `PersistentKeepalive` set to some non-null value.
+ When 1 of the 2 parties is behind remote NAT (e.g. when a laptop behind NAT connects to `public-server2`), define the publicly accessible node with a hardcoded `Endpoint` and the NAT-ed node without. The connection will be opened from NAT client -> public client, then traffic will route directly between them in both directions as long as the connection is kept alive by outgoing `PersistentKeepalive` pings from the NAT-ed client.
- **Node behind local NAT to node behind remote NAT (via relay)**
- In the worst case when both parties are behind remote NATs, both will open a connection to `public-server1`, and traffic will forward through the intermediary bounce server as long as the connections are kept alive.
+ Most of the time when both parties are behind NATs, the NATs do source port randomization making direct connections infeasible, so they will both have to open a connection to `public-server1`, and traffic will forward through the intermediary bounce server as long as the connections are kept alive.
+- **Node behind local NAT to node behind remote NAT (via UDP NAT hole-punching)**
+ While sometimes possible, it's generally infeasible to do direct NAT-to-NAT connections on modern networks, because most NAT routers are quite strict about randomizing the source port, making it impossible to coordinate an open port for both sides ahead of time. Instead, a signaling server (STUN) must be used that stands in the middle and communicates which random source ports are assigned to the other side. Both clients make an initial connection to the public signaling server, then it records the random source ports and sends them back to the clients. This is how WebRTC works in modern P2P web apps. Even with a signalling server and known source ports for both ends, sometimes direct connections are not possible because the NAT routers are strict about only accepting traffic from the original destination address (the signalling server), and will require a new random source port to be opened to accept traffic from other IPs (e.g. the other client attempting to use the originally communicated source port). This is especially true for "carrier-grade NATs" like cellular networks and some enterprise networks, which are designed specifically to prevent this sort of hole-punching connection. See the full section below on [**NAT to NAT Connections**](#NAT-to-NAT-Connections) for more information.
-
-Choosing the proper routing method is handled automatically by WireGuard as long as at least one server is acting as a public relay with `net.ipv4.ip_forward = 1` enabled, and clients have `AllowIPs = 10.0.0.1/24` set in the relay server `[peer]` (to take traffic for the whole subnet).
-
-More specific (also usually more direct) routes provided by other peers will take precedence when available, otherwise traffic will fall back to the least specific route and use the `10.0.0.1/24` catchall to forward traffic to the bounce server, where it will in turn be routed by the relay server's system routing table back down the VPN to the specific peer that's accepting routes for that traffic.
+More specific (also usually more direct) routes provided by other peers will take precedence when available, otherwise traffic will fall back to the least specific route and use the `192.0.2.1/24` catchall to forward traffic to the bounce server, where it will in turn be routed by the relay server's system routing table (`net.ipv4.ip_forward = 1`) back down the VPN to the specific peer that's accepting routes for that traffic. WireGuard does not automatically find the fastest route or attempt to form direct connections between peers if not already defined, it just goes from the most specific route in `[Peers]` to least specific.
You can figure out which routing method WireGuard is using for a given address by measuring the ping times to figure out the unique length of each hop, and by inspecting the output of:
```bash
@@ -336,9 +353,9 @@ Further reading:
### How WireGuard Manages Keys
-Authentication in both directions is achieved with a simple public/private keypair for each peer. Each peer generates these keys during the setup phase, and shares only the public key with other peers.
+Authentication in both directions is achieved with a simple public/private key pair for each peer. Each peer generates these keys during the setup phase, and shares only the public key with other peers.
-No other certificates or preshared keys are needed beyond the public/private keys for each node.
+No other certificates or pre-shared keys are needed beyond the public/private keys for each node.
Key generation, distribution, and revocation can be handled in larger deployments using a separate service like Ansible or Kubernetes Secrets.
@@ -348,6 +365,8 @@ Some services that help with key distribution and deployment:
- https://github.com/trailofbits/algo
- https://github.com/StreisandEffect/streisand
- https://github.com/its0x08/wg-install
+- https://github.com/brittson/wireguard_config_maker
+- https://www.wireguardconfig.com
You can also read in keys from a file or via command if you don't want to hardcode them in `wg0.conf`, this makes managing keys via 3rd party service much easier:
@@ -356,25 +375,30 @@ You can also read in keys from a file or via command if you don't want to hardco
...
PostUp = wg set %i private-key /etc/wireguard/wg0.key <(cat /some/path/%i/privkey)
```
+
+Technically, multiple servers can share the same private key as long as clients arent connected to two servers with the same key simulatenously.
+An example of a scenario where this is a reasonable setup is if you're using round-robin DNS to load-balance connections between two servers that are pretending to be a single server.
+Most of the time however, every peer should have its own pubic/private keypair so that peers can't read eachothers traffic and can be individually revoked.
+
---
## Usage
-### Quickstart
+### QuickStart
Overview of the general process:
1. Install `apt install wireguard` or `pkg/brew install wireguard-tools` on each node
2. Generate public and private keys locally on each node `wg genkey`+`wg pubkey`
-3. Create a `wg0.conf` wireguard config file on the main relay server
- - `[Interface]` Make sure to specify a CIDR range for the entire VPN subnet when defining the address the server accepts routes for `Address = 10.0.0.1/24`
+3. Create a `wg0.conf` WireGuard config file on the main relay server
+ - `[Interface]` Make sure to specify a CIDR range for the entire VPN subnet when defining the address the server accepts routes for `Address = 192.0.2.1/24`
- `[Peer]` Create a peer section for every client joining the VPN, using their corresponding remote public keys
4. Create a `wg0.conf` on each client node
- - `[Interface]` Make sure to specify only a single IP for client peers that don't relay traffic `Address = 10.0.0.3/32`.
- - `[Peer]` Create a peer section for each public peer not behind a NAT, make sure to specify a CIDR range for the entire VPN subnet when defining the remote peer acting as the bounce server `AllowedIPs = 10.0.0.1/24`. Make sure to specify individual IPs for remote peers that don't relay traffic and only act as simple clients `AllowedIPs = 10.0.0.3/32`.
-5. Start wireguard on the main relay server with `wg-quick up /full/path/to/wg0.conf`
-6. Start wireguard on all the client peers with `wg-quick up /full/path/to/wg0.conf`
-7. Traffic is routed from peer to peer using most optimal route over the WireGuard interface, e.g. `ping 10.0.0.3` checks for local direct route first, then checks for route via public internet, then finally tries to route by bouncing through the public relay server.
+ - `[Interface]` Make sure to specify only a single IP for client peers that don't relay traffic `Address = 192.0.2.3/32`.
+ - `[Peer]` Create a peer section for each public peer not behind a NAT, make sure to specify a CIDR range for the entire VPN subnet when defining the remote peer acting as the bounce server `AllowedIPs = 192.0.2.1/24`. Make sure to specify individual IPs for remote peers that don't relay traffic and only act as simple clients `AllowedIPs = 192.0.2.3/32`.
+5. Start WireGuard on the main relay server with `wg-quick up /full/path/to/wg0.conf`
+6. Start WireGuard on all the client peers with `wg-quick up /full/path/to/wg0.conf`
+7. Traffic is routed from peer to peer using most specific route first over the WireGuard interface, e.g. `ping 192.0.2.3` checks for a direct route to a peer with `AllowedIPs = 192.0.2.3/32` first, then falls back to a relay server that's accepting IPs in the whole subnet
### Setup
@@ -389,7 +413,7 @@ brew install wireguard-tools
# install on FreeBSD
pkg install wireguard
-# install on iOS/Andoid using Apple App Store/Google Play Store
+# install on iOS/Android using Apple App Store/Google Play Store
# install on other systems using https://www.wireguard.com/install/#installation
```
@@ -403,12 +427,12 @@ sudo sysctl -p /etc/sysctl.conf
iptables -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i wg0 -o wg0 -m conntrack --ctstate NEW -j ACCEPT
-iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -o eth0 -j MASQUERADE
+iptables -t nat -A POSTROUTING -s 192.0.2.0/24 -o eth0 -j MASQUERADE
```
### Config Creation
```bash
-nano wg0.conf # can be placed anywhere, must be referred to using absolute path
+nano wg0.conf # can be placed anywhere, must be referred to using absolute path (usually placed in /etc/wireguard/wg0.conf on most Linux systems)
```
### Key Generation
@@ -439,12 +463,12 @@ ip link add dev wg0 type wireguard
ip link delete dev wg0
# register/unregister local VPN address
-ip address add dev wg0 10.0.0.3/32
-ip address delete dev wg0 10.0.0.3/32
+ip address add dev wg0 192.0.2.3/32
+ip address delete dev wg0 192.0.2.3/32
# register/unregister VPN route
-ip route add 10.0.0.3/32 dev wg0
-ip route delete 10.0.0.3/32 dev wg0
+ip route add 192.0.2.3/32 dev wg0
+ip route delete 192.0.2.3/32 dev wg0
```
@@ -461,7 +485,7 @@ ip address show
ifconfig wg0
ip link show wg0
-# show wireguard VPN interfaces
+# show WireGuard VPN interfaces
wg show all
wg show wg0
```
@@ -469,19 +493,19 @@ wg show wg0
#### Addresses
```bash
-# show public ip address
+# show public IP address
ifconfig eth0
ip address show eth0
dig -4 +short myip.opendns.com @resolver1.opendns.com
-# show VPN ip address
+# show VPN IP address
ip address show wg0
```
#### Routes
```bash
-# show wireguard routing table and peer connections
+# show WireGuard routing table and peer connections
wg show
wg show wg0 allowed-ips
@@ -490,7 +514,7 @@ ip route show table main
ip route show table local
# show system route to specific address
-ip route get 10.0.0.3
+ip route get 192.0.2.3
```
### Testing
@@ -501,16 +525,16 @@ ip route get 10.0.0.3
ping public-server1.example-vpn.dev
# check that the main relay server is available via VPN
-ping 10.0.0.1
+ping 192.0.2.1
# check that public peers are available via VPN
-ping 10.0.0.2
+ping 192.0.2.2
# check that remote NAT-ed peers are available via VPN
-ping 10.0.0.3
+ping 192.0.2.3
-# check that NAT-ed peers in your local lan are available via VPN
-ping 10.0.0.4
+# check that NAT-ed peers in your local LAN are available via VPN
+ping 192.0.2.4
```
#### Bandwidth
@@ -526,19 +550,19 @@ iperf -c public-server1.example-vpn.dev # on local client
# check bandwidth over VPN to relay server
iperf -s # on public relay server
-iperf -c 10.0.0.1 # on local client
+iperf -c 192.0.2.1 # on local client
# check bandwidth over VPN to remote public peer
iperf -s # on remote public peer
-iperf -c 10.0.0.2 # on local client
+iperf -c 192.0.2.2 # on local client
# check bandwidth over VPN to remote NAT-ed peer
iperf -s # on remote NAT-ed peer
-iperf -c 10.0.0.3 # on local client
+iperf -c 192.0.2.3 # on local client
# check bandwidth over VPN to local NAT-ed peer (on same LAN)
iperf -s # on local NAT-ed peer
-iperf -c 10.0.0.4 # on local client
+iperf -c 192.0.2.4 # on local client
```
#### DNS
@@ -552,12 +576,22 @@ dig example.com A
## Config Reference
+### Overview
+
+WireGuard config is in [INI syntax](https://en.wikipedia.org/wiki/INI_file), defined in a file usually called `wg0.conf`. It can be placed anywhere on the system, but is often placed in `/etc/wireguard/wg0.conf`.
+
+The config path is specified as an argument when running any `wg-quick` command, e.g:
+`wg-quick up /etc/wireguard/wg0.conf` (always specify the full, absolute path)
+
+The config file name must be in the format `${name of the new WireGuard interface}.conf`. WireGuard interface names are typically prefixed with `wg` and numbered starting at `0`, but you can use any name that matches the regex `^[a-zA-Z0-9_=+.-]{1,15}$`.
+
+Config files can opt to use the limited set of `wg` config options, or the more extended `wg-quick` options, depending on what command is preferred to start WireGuard. These docs recommend sticking to `wg-quick` as it provides a more powerful and user-friendly config experience.
**Jump to definition:**
¶ `[Interface]`
¶ `# Name = node1.example.tld`
-¶ `Address = 10.0.0.3/32`
+¶ `Address = 192.0.2.3/32`
¶ `ListenPort = 51820`
¶ `PrivateKey = localPrivateKeyAbcAbcAbc=`
¶ `DNS = 1.1.1.1,8.8.8.8`
@@ -571,7 +605,7 @@ dig example.com A
¶ `[Peer]`
¶ `# Name = node2-node.example.tld`
-¶ `AllowedIPs = 10.0.0.1/24`
+¶ `AllowedIPs = 192.0.2.1/24`
¶ `Endpoint = node1.example.tld:51820`
¶ `PublicKey = remotePublicKeyAbcAbcAbc=`
¶ `PersistentKeepalive = 25`
@@ -586,14 +620,14 @@ Defines the VPN settings for the local node.
```ini
[Interface]
# Name = phone.example-vpn.dev
-Address = 10.0.0.5/32
+Address = 192.0.2.5/32
PrivateKey =
```
* Node is a public bounce server that can relay traffic to other peers and exposes route for entire VPN subnet
```ini
[Interface]
# Name = public-server1.example-vpn.tld
-Address = 10.0.0.1/24
+Address = 192.0.2.1/24
ListenPort = 51820
PrivateKey =
DNS = 1.1.1.1
@@ -605,20 +639,20 @@ This is just a standard comment in INI syntax used to help keep track of which c
#### `Address`
-Defines what address range the local node should route traffic for. Depending on whether the node is a simple client joining the VPN subnet, or a bounce server that's relaying traffic between multiple clients, this can be set to a single IP of the node itself (specified with CIDR notation), e.g. 10.0.0.3/32), or a range of IPv4/IPv6 subnets that the node can route traffic for.
+Defines what address range the local node should route traffic for. Depending on whether the node is a simple client joining the VPN subnet, or a bounce server that's relaying traffic between multiple clients, this can be set to a single IP of the node itself (specified with CIDR notation), e.g. 192.0.2.3/32), or a range of IPv4/IPv6 subnets that the node can route traffic for.
**Examples**
* Node is a client that only routes traffic for itself
-`Address = 10.0.0.3/32`
+`Address = 192.0.2.3/32`
* Node is a public bounce server that can relay traffic to other peers
When the node is acting as the public bounce server, it should set this to be the entire subnet that it can route traffic, not just a single IP for itself.
-`Address = 10.0.0.1/24`
+`Address = 192.0.2.1/24`
* You can also specify multiple subnets or IPv6 subnets like so:
-`Address = 10.0.0.1/24,fd42:42:42::1/64`
+`Address = 192.0.2.1/24,2001:DB8::/64`
#### `ListenPort`
@@ -690,7 +724,7 @@ This option can be specified multiple times, with commands executed in the order
**Examples**
-* Add an ip route
+* Add an IP route
`PreUp = ip rule add ipproto tcp dport 22 table 1234`
#### `PostUp`
@@ -716,7 +750,7 @@ This option can appear multiple times, as with PreUp
`PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE`
* Force WireGuard to re-resolve IP address for peer domain
-`PostUp = resolvectl domain %i "~."; resolvectl dns %i 10.0.0.1; resolvectl dnssec %i yes`
+`PostUp = resolvectl domain %i "~."; resolvectl dns %i 192.0.2.1; resolvectl dnssec %i yes`
#### `PreDown`
@@ -751,11 +785,11 @@ This option can appear multiple times, as with PreUp
### `[Peer]`
-Defines the VPN settings for a remote peer capable of routing traffic for one or more addresses (itself and/or other peers). Peers can be either a public bounce server that relays traffic to other peers, or a directly accessible client via lan/internet that is not behind a NAT and only routes traffic for itself.
+Defines the VPN settings for a remote peer capable of routing traffic for one or more addresses (itself and/or other peers). Peers can be either a public bounce server that relays traffic to other peers, or a directly accessible client via LAN/internet that is not behind a NAT and only routes traffic for itself.
-All clients must be defined as peers on the public bounce server. Simple clients that only route traffic for themselves, only need to define peers for the public relay, and any other nodes directly accessible. Nodes that are behind separate NATs should _not_ be defined as peers outside of the public server config, as no direct route is available between separate NATs. Instead, nodes behind NATs should only define the public relay servers and other public clients as their peers, and should specify `AllowedIPs = 10.0.0.1/24` on the public server that accept routes and bounce traffic for the VPN subnet to the remote NAT-ed peers.
+All clients must be defined as peers on the public bounce server. Simple clients that only route traffic for themselves, only need to define peers for the public relay, and any other nodes directly accessible. Nodes that are behind separate NATs should _not_ be defined as peers outside of the public server config, as no direct route is available between separate NATs. Instead, nodes behind NATs should only define the public relay servers and other public clients as their peers, and should specify `AllowedIPs = 192.0.2.1/24` on the public server that accept routes and bounce traffic for the VPN subnet to the remote NAT-ed peers.
-In summary, all nodes must be defined on the main bounce server. On client servers, only peers that are directly accessible from a node should be defined as peers of that node, any peers that must be relayed by a bounce sherver should be left out and will be handled by the relay server's catchall route.
+In summary, all nodes must be defined on the main bounce server. On client servers, only peers that are directly accessible from a node should be defined as peers of that node, any peers that must be relayed by a bounce server should be left out and will be handled by the relay server's catchall route.
In the configuration outlined in the docs below, a single server `public-server1` acts as the relay bounce server for a mix of publicly accessible and NAT-ed clients, and peers are configured on each node accordingly:
@@ -765,13 +799,13 @@ In the configuration outlined in the docs below, a single server `public-server1
- **in `public-server2` `wg0.conf` (simple public client)**
`[peer]` list: `public-server1`
-- **in `home-server` `wg0.conf` (simple client behind nat)**
+- **in `home-server` `wg0.conf` (simple client behind NAT)**
`[peer]` list: `public-server1`, `public-server2`
-- **in `laptop` `wg0.conf` (simple client behind nat)**
+- **in `laptop` `wg0.conf` (simple client behind NAT)**
`[peer]` list: `public-server1`, `public-server2`
-- **in `phone` `wg0.conf` (simple client behind nat)**
+- **in `phone` `wg0.conf` (simple client behind NAT)**
`[peer]` list: `public-server1`, `public-server2`
**Examples**
@@ -782,7 +816,7 @@ In the configuration outlined in the docs below, a single server `public-server1
# Name = public-server2.example-vpn.dev
Endpoint = public-server2.example-vpn.dev:51820
PublicKey =
-AllowedIPs = 10.0.0.2/32
+AllowedIPs = 192.0.2.2/32
```
- Peer is a simple client behind a NAT that only routes traffic for itself
@@ -791,7 +825,7 @@ AllowedIPs = 10.0.0.2/32
# Name = home-server.example-vpn.dev
Endpoint = home-server.example-vpn.dev:51820
PublicKey =
-AllowedIPs = 10.0.0.3/32
+AllowedIPs = 192.0.2.3/32
```
- Peer is a public bounce server that can relay traffic to other peers
@@ -801,7 +835,7 @@ AllowedIPs = 10.0.0.3/32
Endpoint = public-server1.example-vpn.tld:51820
PublicKey =
# routes traffic to itself and entire subnet of peers as bounce server
-AllowedIPs = 10.0.0.1/24
+AllowedIPs = 192.0.2.1/24
PersistentKeepalive = 25
```
@@ -824,25 +858,25 @@ Defines the publicly accessible address for a remote peer. This should be left
This defines the IP ranges for which a peer will route traffic. On simple clients, this is usually a single address (the VPN address of the simple client itself). For bounce servers this will be a range of the IPs or subnets that the relay server is capable of routing traffic for. Multiple IPs and subnets may be specified using comma-separated IPv4 or IPv6 CIDR notation (from a single /32 or /128 address, all the way up to `0.0.0.0/0` and `::/0` to indicate a default route to send all internet and VPN traffic through that peer). This option may be specified multiple times.
-When deciding how to route a packet, the system chooses the most specific route first, and falls back to broader routes. So for a packet destined to `10.0.0.3`, the system would first look for a peer advertising `10.0.0.3/32` specifically, and would fall back to a peer advertising `10.0.0.1/24` or a larger range like `0.0.0.0/0` as a last resort.
+When deciding how to route a packet, the system chooses the most specific route first, and falls back to broader routes. So for a packet destined to `192.0.2.3`, the system would first look for a peer advertising `192.0.2.3/32` specifically, and would fall back to a peer advertising `192.0.2.1/24` or a larger range like `0.0.0.0/0` as a last resort.
**Examples**
- peer is a simple client that only accepts traffic to/from itself
-`AllowedIPs = 10.0.0.3/32`
+`AllowedIPs = 192.0.2.3/32`
- peer is a relay server that can bounce VPN traffic to all other peers
-`AllowedIPs = 10.0.0.1/24`
+`AllowedIPs = 192.0.2.1/24`
- peer is a relay server that bounces all internet & VPN traffic (like a proxy), including IPv6
`AllowedIPs = 0.0.0.0/0,::/0`
- peer is a relay server that routes to itself and only one other peer
-`AllowedIPs = 10.0.0.3/32,10.0.0.4/32`
+`AllowedIPs = 192.0.2.3/32,192.0.2.4/32`
- peer is a relay server that routes to itself and all nodes on its local LAN
-`AllowedIPs = 10.0.0.3/32,192.168.1.1/24`
+`AllowedIPs = 192.0.2.3/32,192.168.1.1/24`
#### `PublicKey`
@@ -877,13 +911,13 @@ If the connection is going from a NAT-ed peer to a public peer, the node behind
### IPv6
-The examples in these docs primarily use IPv4, but Wireguard natively supports IPv6 CIDR notation and addresses everywhere that it supports IPv4, simply add them as you would any other subnet range or address.
+The examples in these docs primarily use IPv4, but WireGuard natively supports IPv6 CIDR notation and addresses everywhere that it supports IPv4, simply add them as you would any other subnet range or address.
**Example**
```ini
[Interface]
-AllowedIps = 10.0.0.3/24, fd42:42:42::1/64
+AllowedIps = 192.0.2.3/24, 2001:DB8::/64
[Peer]
...
@@ -902,7 +936,7 @@ https://www.reddit.com/r/WireGuard/comments/b0m5g2/ipv6_leaks_psa_for_anyone_her
```ini
[Interface]
# Name = phone.example-vpn.dev
-Address = 10.0.0.3/32
+Address = 192.0.2.3/32
PrivateKey =
[Peer]
@@ -914,30 +948,63 @@ AllowedIPs = 0.0.0.0/0, ::/0
### NAT To NAT Connections
-WireGuard can natively make connections between two clients behind NATs, without need of a public relay server. This is achieved by hardcoding a `ListenPort` on both sides (and enabling `PersistentKeepalive`) so that both peers don't need a separate publicly-accesible signaling server to determine where to send the initial UDP packets.
+WireGuard can sometimes natively make connections between two clients behind NATs without the need for a public relay server, but in most cases this is not possible. NAT-to-NAT connections are only possible if at least one host has a stable, publicly-accessible IP address:port pair that can be hardcoded ahead of time, whether that's using a FQDN updated with Dynamic DNS, or a static public IP with a non-randomized NAT port opened by outgoing packets, anything works as long as all peers can communicate it beforehand and it doesn't change once the connection is initiated.
-The connection process looks like this:
+A known port and address need to be configured ahead of time because WireGuard doesn't have a signalling layer or public STUN servers that can be used to search for other hosts dynamically. WebRTC is an example of a protocol that can dynamically configure a connection between two NATs, but it does this by using an out-of-band signaling server to detect the IP:port combo of each host. WireGuard doesn't have this, so it only works with a hardcoded `Endpoint` + `ListenPort` (and `PersistentKeepalive` so it doesn't drop after inactivity).
+
+#### Requirements for NAT-to-NAT setups
+
+ - At least one peer has to have to have a hardcoded, directly-accessible `Endpoint` defined. If they're both behind NATs without stable IP addresses, then you'll need to use Dynamic DNS or another solution to have a stable, publicly accessibly domain/IP for at least one peer
+ - At least one peer has to have a hardcoded UDP `ListenPort` defined, and it's NAT router must not do UDP source port randomization, otherwise return packets will be sent to the hardcoded `ListenPort` and dropped by the router, instead of using the random port assigned by the NAT on the outgoing packet
+ - All NAT'ed peers must have `PersistentKeepalive` enabled on all other peers, so that they continually send outgoing pings to keep connections persisted in their NAT's routing table
+
+#### The hole-punching connection process
1. Peer1 sends a UDP packet to Peer2, it's rejected Peer2's NAT router immediately, but that's ok, the only purpose was to get Peer1's NAT to start forwarding any expected UDP responses back to Peer1 behind its NAT
- 2. Peer2 sends a UDP packet to Peer1, it's accepted and fowarded to Peer1 as Peer1's NAT server is already expecting responses from Peer2 because of the initial outgoing packet
+ 2. Peer2 sends a UDP packet to Peer1, it's accepted and forwarded to Peer1 as Peer1's NAT server is already expecting responses from Peer2 because of the initial outgoing packet
3. Peer1 sends a UDP response to Peer2's packet, it's accepted and forwarded by Peer2's NAT server as it's also expecting responses because of the initial outgoing packet
This process of sending an initial packet that gets rejected, then using the fact that the router has now created a forwarding rule to accept responses is called "UDP hole-punching".
-When you send a UDP packet out, the router (usually) creates a temporary rule mapping your source address and port to the destination address and port, and vice versa. UDP packets returning from the destination address and port (and no other) are passed through to the original source address and port (and no other). This is how most UDP applications function behind NATs (e.g. Bittorent, Skype, etc). This rule will timeout after some minutes of inactivity, so the client behind the NAT must send regular outgoing packets to keep it open (see `PersistentKeepalive`).
+When you send a UDP packet out, the router (usually) creates a temporary rule mapping your source address and port to the destination address and port, and vice versa. UDP packets returning from the destination address and port (and no other) are passed through to the original source address and port (and no other). This is how most UDP applications function behind NATs (e.g. BitTorrent, Skype, etc). This rule will timeout after some minutes of inactivity, so the client behind the NAT must send regular outgoing packets to keep it open (see `PersistentKeepalive`).
-Getting this to work when both end-points are behind NATs or firewalls would require that both end-points send packets to each-other at about the same time. This means that both sides need to know each-other's public IP addresses and port numbers and need to communicate this to each-other by some other means (in our case by hard-coding them in `wg0.conf` in advance). WebRTC requires a STUN signaling server to communicate the hole-punching port because it would be impossible for browsers to hardcode listening ports for all possible connections in advance.
+Getting this to work when both end-points are behind NATs or firewalls requires that both end-points send packets to each-other at about the same time. This means that both sides need to know each-other's public IP addresses and port numbers ahead of time, in WireGuard's case this is achieved by hard-coding pre-defined ports for both sides in `wg0.conf`.
-WireGuard punches holes through NATs natively as a side effect of it's UDP-based design, but it only works if a `ListenPort` is hardcoded for the peer behind the NAT. It does not search for a hole-punching port dynamically like WebRTC/N2N as it has no concept of a signaling server to communicate the port to the other side, it only works with a hardcoded port and `PersistentKeepalive` set to some non-null value on both sides.
+#### Drawbacks and limitations
-This approach has some limitations, which is why having a fallback public relay server is still advised, see:
+As of 2019, many of the old hole-punching methods used that used to work are no longer effective. One example was a novel method pioneered by [pwnat](https://github.com/samyk/pwnat) that faked an ICMP Time Exceeded response from outside the NAT to get a packet back through to a NAT'ed peer, thereby leaking its own source port. Hardcoding UDP ports and public IPs for both sides of a NAT-to-NAT connection (as described above) still works on a small percentage of networks. Generally the more "enterprisey" a network is, the less likely you'll be able to hole punch public UDP ports (commercial public Wi-Fi and cell data NATs often don't work for example).
+##### Source port randomization
+
+NAT-to-NAT connections are not possible if all endpoints are behind NAT's with strict UDP source port randomization (e.g. most cellular data networks). Since neither side is able to hardcode a `ListenPort` and guarantee that their NAT will accept traffic on that port after the outgoing ping, you cannot coordinate a port for the initial hole-punch between peers and connections will fail. For this reason, you generally cannot do phone-to-phone connections on LTE/3g networks, but you might be able to do phone-to-office or phone-to-home where the office or home has a stable public IP and doesn't do source port randomization.
+
+##### Using a signaling server
+
+NAT-to-NAT connections from behind NATs with strict source-port randomization is possible, you just need a signaling server to tell each side the other's IP:port tuple. Here are a few implementations that achieve this with WireGuard:
+
+- https://github.com/takutakahashi/wg-connect
+- https://git.zx2c4.com/wireguard-tools/tree/contrib/nat-hole-punching/
+
+##### Dynamic IP addresses
+Many users report having to restart WireGuard whenever a dynamic IP changes, as it only resolves hostnames on startup. To force WireGuard to re-resolve dynamic DNS `Endpoint` hostnames more often, you may want to use a `PostUp` hook to restart WireGuard every few minutes or hours.
+
+
+#### Testing it out
+
+You can see if a hole-punching setup is feasible by using netcat on the client and server to see what ports and connection order work to get a bidirectional connection open: run `nc -v -u -p 51820 51820` (on peer1) and `nc -v -u -l 0.0.0.0 51820` (on peer2), then type in both windows to see if you can get bidirectional traffic going. If it doesn't work regardless of which peer sends the initial packet, then WireGuard won't be unable to work between the peers without a public relay server.
+
+NAT-to-NAT connections are often more unstable and have other limitations, which is why having a fallback public relay server is still advised.
+
+#### Further reading
+
+ - https://github.com/samyk/pwnat
- https://en.wikipedia.org/wiki/UDP_hole_punching
- https://stackoverflow.com/questions/8892142/udp-hole-punching-algorithm
- https://stackoverflow.com/questions/12359502/udp-hole-punching-not-going-through-on-3g
- https://stackoverflow.com/questions/11819349/udp-hole-punching-not-possible-with-mobile-provider
- https://github.com/WireGuard/WireGuard/tree/master/contrib/examples/nat-hole-punching
- https://staaldraad.github.io/2017/04/17/nat-to-nat-with-wireguard/
+ - https://golb.hplar.ch/2019/01/expose-server-vpn.html
**Example**
@@ -967,7 +1034,9 @@ PersistentKeepalive = 25
### Dynamic IP Allocation
-Dynamic allocation of IPs (instead of only having fixed peers) is being developed, the WIP implementation is available here:
+*Note: this section is about dynamic peer IPs within the VPN subnet, not dynamic public `Endpoint` addresses*.
+
+Dynamic allocation of peer IPs (instead of only having fixed peers) is being developed, the WIP implementation is available here:
https://github.com/WireGuard/wg-dynamic
You can also build a dynamic allocation system yourself by reading in IP values from files at runtime by using `PostUp` (see below).
@@ -976,36 +1045,57 @@ You can also build a dynamic allocation system yourself by reading in IP values
```ini
[Interface]
...
-PostUp = PostUp = wg set %i allowed-ips /etc/wireguard/wg0.key <(some command)
+PostUp = wg set %i allowed-ips /etc/wireguard/wg0.key <(some command)
```
### Other WireGuard Implementations
-
- https://git.zx2c4.com/wireguard-go/about/
A compliant userland WireGuard implementation written in Go.
+- https://git.zx2c4.com/wireguard-rs/about/
+An incomplete, insecure userspace implementation of WireGuard written in Rust (not ready for the public).
+
+- https://git.zx2c4.com/wireguard-hs/about/
+An incomplete, insecure userspace implementation of WireGuard written in Haskell (not ready for the public).
+
- https://github.com/cloudflare/boringtun
-A compliant WireGuard implementation with the exact same API, written in Rust.
+A non-compliant, independent WireGuard implementation written in Rust (a separate fork written by CloudFlare).
See https://blog.cloudflare.com/boringtun-userspace-wireguard-rust/
+- Platform-specific WireGuard apps
+https://git.zx2c4.com/wireguard-ios/about/
+https://git.zx2c4.com/wireguard-android/about/
+https://git.zx2c4.com/wireguard-windows/about/
-Both of these are slower than the native C version that runs in kernel land, but provide other benefits by running in userland (e.g. easier containerization).
+All of the userspace implementations are slower than the native C version that runs in kernel-land, but provide other benefits by running in userland (e.g. easier containerization, compatibility, etc.).
### WireGuard Setup Tools
These are some GUI and CLI tools that wrap WireGuard to assist with config, deployment, key management, and connection.
- https://github.com/BrunIF/wg-ccg
+ - https://github.com/seashell/drago
+ - https://github.com/vx3r/wg-gen-web
- https://github.com/subspacecloud/subspace
- https://github.com/corrad1nho/qomui
- https://github.com/max-moser/network-manager-wireguard
- https://github.com/its0x08/wg-install
- https://github.com/sowbug/mkwgconf
+ - https://github.com/brittson/wireguard_config_maker
+ - https://github.com/SirToffski/WireGuard-Ligase/
- https://pypi.org/project/wireguard-p2p/
- https://github.com/trailofbits/algo
- https://github.com/StreisandEffect/streisand
- https://www.veeam.com/blog/veeam-pn-v2-wireguard.html
+ - https://github.com/wg-dashboard/wg-dashboard
+ - https://www.wireguardconfig.com
+ - https://github.com/complexorganizations/wireguard-manager
+ - https://github.com/influxdata/wirey
+ - https://github.com/apognu/wgctl
+ - https://github.com/naggie/dsnet
+ - https://github.com/perara/wg-manager
+ - https://github.com/pivpn/pivpn
### Config Shortcuts
@@ -1021,7 +1111,7 @@ See: https://lists.zx2c4.com/pipermail/wireguard/2018-December/003703.html
You can combine this with `wg addconf` like this:
-* Each peer has its own `/etc/wireguard/wg0.conf` file, which only contains it's `[Interface]` section.
+* Each peer has its own `/etc/wireguard/wg0.conf` file, which only contains its `[Interface]` section.
* Each peer also has a shared `/etc/wireguard/peers.conf` file, which contains all the peers.
@@ -1044,309 +1134,87 @@ You can read in a file as the `PrivateKey` by doing something like:
### Containerization
-WireGuard can be run in Docker with varying degrees of ease. In the simplest case, `--privileged` and `--cap-add=all` args can be added to the docker commands to enable the loading of the kernel module.
+WireGuard can be run in Docker with varying degrees of ease. In the simplest case, `--privileged` and `--cap-add=all` arguments can be added to the docker commands to enable the loading of the kernel module.
-Setups can get somewhat complex are are highly dependent on what you're trying to achieve. You can have WireGuard itself run in a container and expose a network interface to the host, or you can have WireGuard running on the host exposing an interface to specific containers.
+Setups can get somewhat complex and are highly dependent on what you're trying to achieve. You can have WireGuard itself run in a container and expose a network interface to the host, or you can have WireGuard running on the host exposing an interface to specific containers.
-**Further Reading**
+See below for an example of a Docker container `vpn_test` routing all its traffic through a WireGuard relay server.
-- https://www.wireguard.com/#ready-for-containers
-- https://medium.com/@mdp/securing-docker-with-wireguard-82ad45004f4d
-- https://blog.jessfraz.com/post/installing-and-using-wireguard/
-- https://github.com/cmulk/wireguard-docker
-- https://github.com/activeeos/wireguard-docker
-- https://github.com/ironhalik/docker-wireguard
-- https://nbsoftsolutions.com/blog/routing-select-docker-containers-through-wireguard-vpn
+#### Example Relay Server Setup
----
+```yaml
+version: '3'
-# Example Server-To-Server Config with Roaming Devices
-
-The complete example config for the setup below can be found here: https://github.com/pirate/wireguard-docs/tree/master/full-example (WARNING: do not use it on your devices without changing the public/private keys!).
-
-## Overview
-
-### Network Topology
-
-These 5 devices are used in our example setup to explain how WireGuard supports bridging across a variety of network conditions, they're all under an example domain `example-vpn.dev`, with the following short hostnames:
-
-- `public-server1` (not behind a NAT, acts as the main VPN bounce server)
-- `public-server2` (not behind a NAT, joins as a peer without bouncing traffic)
-- `home-server` (behind a NAT, joins as a peer without bouncing traffic)
-- `laptop` (behind NAT, sometimes shared w/ home-server/phone, sometimes roaming)
-- `phone` (behind NAT, sometimes shared w/ home-server/laptop, sometimes roaming)
-
-### Explanation
-
-This VPN config simulates setting up a small VPN subnet `10.0.0.1/24` shared by 5 nodes. Two of the nodes (public-server1 and public-server2) are VPS instances living in a cloud somewhere, with public IPs accessible to the internet. home-server is a stationary node that lives behind a NAT with a dynamic IP, but it doesn't change frequently. Phone and laptop are both roaming nodes, that can either be at home in the same LAN as home-server, or out-and-about using public wifi or cell service to connect to the VPN.
-
-Whenever possible, nodes should connect directly to each other, depending on whether nodes are directly accessible or NATs are between them, traffic will route accordingly:
-
-### The Public Relay
-
-`public-server1` acts as an intermediate relay server between any VPN clients behind NATs, it will forward any 10.0.0.1/24 traffic it receives to the correct peer at the system level (WireGuard doesn't care how this happens, it's handled by the kernel `net.ipv4.ip_forward = 1` and the iptables routing rules).
-
-Each client only needs to define the publicly accessible servers/peers in it's config, any traffic bound to other peers behind NATs will go to the catchall `10.0.0.1/24` for the server and will be forwarded accordingly once it hits the main server.
-
-In summary: only direct connections between clients should be configured, any connections that need to be bounced should not be defined as peers, as they should head to the bounce server first and be routed from there back down the vpn to the correct client.
-
-## Full Example Code
-
-To run this full example, simply copy the `full wg0.conf config file for node` section from each node onto each server, enable IP forwarding on the public relay, and then start WireGuard on all the machines.
-
-For more detailed instructions, see the [Quickstart](#Quickstart) guide and API reference above. You can also download the complete example setup here: https://github.com/pirate/wireguard-docs/tree/master/full-example (WARNING: do not use it on your devices without changing the public/private keys!).
-
-## Node Config
-
-### public-server1.example-vpn.tld
- * public endpoint: `public-server1.example-vpn.tld:51820`
- * own vpn ip address: `10.0.0.1`
- * can accept traffic for ips: `10.0.0.1/24`
- * priv key: ``
- * pub key: ``
- * setup required:
- 1. install wireguard
- 2. generate public/private keypair
- 3. create wg0.conf (see below)
- 4. enable kernel ip & arp forwarding, add iptables forwarding rules
- 5. start wireguard
- * config as remote peer:
-```ini
-[Peer]
-# Name = public-server1.example-vpn.tld
-Endpoint = public-server1.example-vpn.tld:51820
-PublicKey =
-# routes traffic to itself and entire subnet of peers as bounce server
-AllowedIPs = 10.0.0.1/24
-PersistentKeepalive = 25
+services:
+ wireguard:
+ image: linuxserver/wireguard
+ ports:
+ - 51820:51820/udp
+ cap_add:
+ - NET_ADMIN
+ - SYS_MODULE
+ volumes:
+ - /lib/modules:/lib/modules
+ - ./wg0.conf:/config/wg0.conf:ro
```
- * config as local interface:
+**`wg0.conf`:**
```ini
[Interface]
-# Name = public-server1.example-vpn.tld
-Address = 10.0.0.1/24
+# Name = relay1.wg.example.com
+Address = 192.0.2.1/24
ListenPort = 51820
-PrivateKey =
-DNS = 1.1.1.1
+PrivateKey = oJpRt2Oq27vIB5/UVb7BRqCwad2YMReQgH5tlxz8YmI=
+DNS = 1.1.1.1,8.8.8.8
+PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; ip6tables -A FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
+PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE; ip6tables -D FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
+
+[Peer]
+# Name = peer1.wg.example.com
+PublicKey = I+hXRAJOG/UE2IQvIHsou2zTgkUyPve2pzvHTnd/2Gg=
+AllowedIPs = 192.0.2.2/32
```
- * peers: public-server2, home-server, laptop, phone
- * full `wg0.conf` config file for node:
+
+#### Example Client Container Setup
+
+In this example *all* the traffic from inside the `speedtest` container will go through the wireguard VPN.
+To only route some traffic, replace `0.0.0.0/0` in `wg0.conf` below with the subnet ranges you want to route via the VPN.
+
+**`docker-compose.yml`:**
+```yaml
+version: '3'
+
+services:
+ wireguard:
+ image: linuxserver/wireguard
+ cap_add:
+ - NET_ADMIN
+ - SYS_MODULE
+ volumes:
+ - /lib/modules:/lib/modules
+ - ./wg0.conf:/config/wg0.conf:ro
+
+ vpn_test:
+ image: curlimages/curl
+ entrypoint: curl -s http://whatismyip.akamai.com/
+ network_mode: 'service:wireguard'
+```
+**`wg0.conf`:**
```ini
[Interface]
-# Name = public-server1.example-vpn.tld
-Address = 10.0.0.1/24
-ListenPort = 51820
-PrivateKey =
-DNS = 1.1.1.1
+# Name = peer1.wg.example.com
+Address = 192.0.2.2/32
+PrivateKey = YCW76edD4W7nZrPbWZxPZhcs32CsBLIi1sEhsV/sgk8=
+DNS = 1.1.1.1,8.8.8.8
[Peer]
-# Name = public-server2.example-vpn.dev
-Endpoint = public-server2.example-vpn.dev:51820
-PublicKey =
-AllowedIPs = 10.0.0.2/32
-
-[Peer]
-# Name = home-server.example-vpn.dev
-Endpoint = home-server.example-vpn.dev:51820
-PublicKey =
-AllowedIPs = 10.0.0.3/32
-
-[Peer]
-# Name = laptop.example-vpn.dev
-PublicKey =
-AllowedIPs = 10.0.0.4/32
-
-[Peer]
-# phone.example-vpn.dev
-PublicKey =
-AllowedIPs = 10.0.0.5/32
+# Name = relay1.wg.example.com
+Endpoint = relay1.wg.example.com:51820
+PublicKey = zJNKewtL3gcHdG62V3GaBkErFtapJWsAx+2um0c0B1s=
+AllowedIPs = 192.0.2.1/24,0.0.0.0/0
+PersistentKeepalive = 21
```
-### public-server2.example-vpn.dev
- * public endpoint: `public-server2.example-vpn.dev:51820`
- * own vpn ip address: `10.0.0.2`
- * can accept traffic for ips: `10.0.0.2/32`
- * priv key: ``
- * pub key: ``
- * setup required:
- 1. install wireguard
- 2. generate public/private keypair
- 3. create wg0.conf (see below)
- 4. confirm main public relay server is directly accessible
- 4. start wireguard
- * config as local interface:
-```ini
-[Interface]
-# Name = public-server2.example-vpn.dev
-Address = 10.0.0.2/32
-ListenPort = 51820
-PrivateKey =
-DNS = 1.1.1.1
-```
- * config as peer:
-```ini
-[Peer]
-# Name = public-server2.example-vpn.dev
-Endpoint = public-server2.example-vpn.dev:51820
-PublicKey =
-AllowedIPs = 10.0.0.2/32
-```
- * peers: public-server1
- * full `wg0.conf` config file for node:
-```ini
-[Interface]
-# Name = public-server2.example-vpn.dev
-Address = 10.0.0.2/32
-ListenPort = 51820
-PrivateKey =
-DNS = 1.1.1.1
-
-[Peer]
-# Name = public-server1.example-vpn.tld
-Endpoint = public-server1.example-vpn.tld:51820
-PublicKey =
-# routes traffic to itself and entire subnet of peers as bounce server
-AllowedIPs = 10.0.0.1/24
-PersistentKeepalive = 25
-```
-
-### home-server.example-vpn.dev
- * public endpoint: (none, behind NAT)
- * own vpn ip address: `10.0.0.3`
- * can accept traffic for ips: `10.0.0.3/32`
- * priv key: ``
- * pub key: ``
- * setup required:
- 1. install wireguard
- 2. generate public/private keypair
- 3. create wg0.conf (see below)
- 4. confirm main public relay server is directly accessible
- 4. start wireguard
- * config as local interface:
-```ini
-[Interface]
-# Name = home-server.example-vpn.dev
-Address = 10.0.0.3/32
-ListenPort = 51820
-PrivateKey =
-DNS = 1.1.1.1
-```
- * config as peer:
-```ini
-[Peer]
-# Name = home-server.example-vpn.dev
-Endpoint = home-server.example-vpn.dev:51820
-PublicKey =
-AllowedIPs = 10.0.0.3/32
-```
- * peers: public-server1
- * full `wg0.conf` config file for node:
-```ini
-[Interface]
-# Name = home-server.example-vpn.dev
-Address = 10.0.0.3/32
-ListenPort = 51820
-PrivateKey =
-DNS = 1.1.1.1
-
-[Peer]
-# Name = public-server1.example-vpn.tld
-Endpoint = public-server1.example-vpn.tld:51820
-PublicKey =
-# routes traffic to itself and entire subnet of peers as bounce server
-AllowedIPs = 10.0.0.1/24
-PersistentKeepalive = 25
-```
-
-### laptop.example-vpn.dev
- * public endpoint: (none, behind NAT)
- * own vpn ip address: `10.0.0.4`
- * can accept traffic for ips: `10.0.0.4/32`
- * priv key: ``
- * pub key: ``
- * setup required:
- 1. install wireguard
- 2. generate public/private keypair
- 3. create wg0.conf (see below)
- 4. confirm main public relay server is directly accessible
- 4. start wireguard
- * config as local interface:
-```ini
-[Interface]
-# Name = laptop.example-vpn.dev
-Address = 10.0.0.4/32
-PrivateKey =
-DNS = 1.1.1.1
-```
- * config as peer:
-```ini
-[Peer]
-# Name = laptop.example-vpn.dev
-PublicKey =
-AllowedIPs = 10.0.0.4/32
-```
- * peers: public-server1
- * full `wg0.conf` config file for node:
-```ini
-[Interface]
-# Name = laptop.example-vpn.dev
-Address = 10.0.0.4/32
-PrivateKey =
-DNS = 1.1.1.1
-
-[Peer]
-# Name = public-server1.example-vpn.tld
-Endpoint = public-server1.example-vpn.tld:51820
-PublicKey =
-# routes traffic to itself and entire subnet of peers as bounce server
-AllowedIPs = 10.0.0.1/24
-PersistentKeepalive = 25
-```
-
-### phone.example-vpn.dev
- * public endpoint: (none, behind NAT)
- * own vpn ip address: `10.0.0.5`
- * can accept traffic for ips: `10.0.0.5/32`
- * priv key: ``
- * pub key: ``
- * setup required:
- 1. install wireguard
- 2. generate public/private keypair
- 3. create wg0.conf (see below)
- 4. confirm main public relay server is directly accessible
- 4. start wireguard
- * config as local interface:
-```ini
-[Interface]
-# Name = phone.example-vpn.dev
-Address = 10.0.0.5/32
-PrivateKey =
-DNS = 1.1.1.1
-```
- * config as peer:
-```ini
-[Peer]
-# phone.example-vpn.dev
-PublicKey =
-AllowedIPs = 10.0.0.5/32
-```
- * peers: public-server1
- * full `wg0.conf` config file for node:
-```ini
-[Interface]
-# Name = phone.example-vpn.dev
-Address = 10.0.0.5/32
-PrivateKey =
-DNS = 1.1.1.1
-
-[Peer]
-# Name = public-server1.example-vpn.tld
-Endpoint = public-server1.example-vpn.tld:51820
-PublicKey =
-# routes traffic to itself and entire subnet of peers as bounce server
-AllowedIPs = 10.0.0.1/24
-PersistentKeepalive = 25
-```
+For more details see the Further Reading: Docker section below.
---
@@ -1365,6 +1233,7 @@ PersistentKeepalive = 25
- https://www.wireguard.com/quickstart/
- https://www.stavros.io/posts/how-to-configure-wireguard/
- https://nbsoftsolutions.com/blog/wireguard-vpn-walkthrough
+- https://networkhobo.com/building-a-wireguard-router/
- https://proprivacy.com/guides/wireguard-hands-on-guide
- https://angristan.xyz/how-to-setup-vpn-server-wireguard-nat-ipv6/
- https://medium.com/@headquartershq/setting-up-wireguard-on-a-mac-8a121bfe9d86
@@ -1376,10 +1245,19 @@ PersistentKeepalive = 25
- https://vincent.bernat.ch/en/blog/2018-route-based-vpn-wireguard
- https://staaldraad.github.io/2017/04/17/nat-to-nat-with-wireguard
- https://try.popho.be/wg.html
+- https://docs.artemix.org/sysadmin/wireguard-management/
- https://github.com/adrianmihalko/raspberrypiwireguard
- https://www.ericlight.com/wireguard-part-one-installation.html
- https://www.ericlight.com/wireguard-part-two-vpn-routing.html
- https://www.ericlight.com/wireguard-part-three-troubleshooting.html
+- https://wiki.dd-wrt.com/wiki/index.php/The_Easiest_Tunnel_Ever
+- https://www.reddit.com/r/pihole/comments/bnihyz/guide_how_to_install_wireguard_on_a_raspberry_pi/
+- https://jwillmer.de/blog/tutorial/wireguard-proxy-configuration
+- https://www.maths.tcd.ie/~fionn/misc/wireguard.php
+- https://www.linode.com/docs/networking/vpn/set-up-wireguard-vpn-on-debian/
+- https://golb.hplar.ch/2019/01/expose-server-vpn.html
+- https://medium.com/@jmarhee/configuring-and-managing-routes-between-multiple-networks-with-wireguard-61ad995c887c
+- https://stanislas.blog/2019/01/how-to-setup-vpn-server-wireguard-nat-ipv6/
### Papers, Articles, and Talks
@@ -1392,11 +1270,14 @@ PersistentKeepalive = 25
### Related Projects
+- https://github.com/complexorganizations/wireguard-manager
- https://github.com/subspacecloud/subspace
- https://github.com/trailofbits/algo
- https://github.com/StreisandEffect/streisand
- https://github.com/its0x08/wg-install
- https://github.com/sowbug/mkwgconf
+- https://github.com/brittson/wireguard_config_maker
+- https://github.com/SirToffski/WireGuard-Ligase/
- https://pypi.org/project/wireguard-p2p/
- https://github.com/cloudflare/boringtun
- https://git.zx2c4.com/wireguard-go/about/
@@ -1406,19 +1287,38 @@ PersistentKeepalive = 25
- https://github.com/WireGuard/wireguard-rs
- https://github.com/WireGuard/wireguard-go
- https://www.veeam.com/blog/veeam-pn-v2-wireguard.html
+- https://github.com/wg-dashboard/wg-dashboard
+- https://wirt.network
+- https://github.com/seashell/drago
+- https://www.wireguardconfig.com
+- https://github.com/angristan/wireguard-install
+- https://github.com/complexorganizations/wireguard-manager
+- https://github.com/influxdata/wirey
+- https://github.com/apognu/wgctl
+- https://github.com/tailscale/tailscale
+- https://github.com/pivpn/pivpn
### Docker
-- https://www.wireguard.com/#ready-for-containers
-- https://medium.com/@mdp/securing-docker-with-wireguard-82ad45004f4d
+
- https://blog.jessfraz.com/post/installing-and-using-wireguard/
-- https://nbsoftsolutions.com/blog/leaning-on-algo-to-route-docker-traffic-through-wireguard
-- https://github.com/cmulk/wireguard-docker
+- https://codeopolis.com/posts/installing-wireguard-in-docker/
+- http://tiven.wang/articles/wireguard-setup-server-in-docker/
- https://github.com/activeeos/wireguard-docker
+- https://github.com/cmulk/wireguard-docker
- https://github.com/ironhalik/docker-wireguard
+- https://github.com/linuxserver/docker-wireguard
+- https://github.com/squat/kilo
+- https://github.com/gravitational/wormhole
+- https://medium.com/@mdp/securing-docker-with-wireguard-82ad45004f4d
+- https://nbsoftsolutions.com/blog/leaning-on-algo-to-route-docker-traffic-through-wireguard
- https://nbsoftsolutions.com/blog/routing-select-docker-containers-through-wireguard-vpn
- https://www.net.in.tum.de/fileadmin/bibtex/publications/theses/2018-pudelko-vpn-performance.pdf
-
+- https://www.wireguard.com/#ready-for-containers
+- https://discuss.linuxcontainers.org/t/solved-wireguard-in-macvlan-container-on-ubuntu-18-04/4445
+- https://www.reddit.com/r/WireGuard/comments/gdhcej/trouble_tunneling_docker_containers_through_a/
+- https://forums.unraid.net/topic/91367-partially-working-wireguard-docker/
+- https://saasbootstrap.com/how-to-setup-a-vpn-with-wireguard-that-only-routes-traffic-from-a-specific-docker-container-or-specific-ip/
### Other
@@ -1434,6 +1334,7 @@ PersistentKeepalive = 25
- https://www.wireguard.com/performance/
- https://blogs.gnome.org/thaller/2019/03/15/wireguard-in-networkmanager/
- https://github.com/max-moser/network-manager-wireguard
+- https://blog.linuxserver.io/2019/11/24/connect-an-ubuntu-client-to-opnsense-wireguard-tunnel-with-a-gui-toggle-in-gnome/
### Discussions
@@ -1445,12 +1346,15 @@ PersistentKeepalive = 25
- https://www.reddit.com/r/VPN/comments/au4owb/how_secure_is_wireguard_vpn_protocol/
- https://www.reddit.com/r/WireGuard/comments/ap33df/wireguard_what_is_so_special_about_it_and_why/
- https://www.reddit.com/r/VPN/comments/9hgs2x/what_is_the_difference_between_wireguard_openvpn/
+- https://www.reddit.com/r/WireGuard/comments/d3thxp/port_forwarding_on_the_router_with_wireguard_is/
- https://www.reddit.com/r/privacytoolsIO/comments/8l0vxt/what_do_you_think_guys_of_wireguard/
+- https://community.ui.com/questions/Edgerouter-with-remote-Wireguard-access-issue/03e4f2e2-3871-437f-8632-3c5c7fb1c7a4
+- https://discuss.linuxcontainers.org/t/solved-wireguard-in-macvlan-container-on-ubuntu-18-04/4445
- https://news.ycombinator.com/item?id=20036194
- https://news.ycombinator.com/item?id=17659983
- https://news.ycombinator.com/item?id=17846387
-For more detailed instructions, see the [Quickstart](#Quickstart) guide and API reference above. You can also download the complete example setup here: https://github.com/pirate/wireguard-example.
+For more detailed instructions, see the [QuickStart](#QuickStart) guide and API reference above. You can also download the complete example setup here: https://github.com/pirate/wireguard-example.
---
diff --git a/example-full/README.md b/example-full/README.md
new file mode 100644
index 0000000..1216dc8
--- /dev/null
+++ b/example-full/README.md
@@ -0,0 +1,303 @@
+# Example Server-To-Server Config with Roaming Devices
+
+WARNING: **Make sure to change the IP addresses and ranges in your configs before running!**
+The blocks used in these examples are reserved for documentation purposes by the IETF and should never be used in real network setups.
+
+ - **`192.0.2.0/24`** (TEST-NET-1) IPv4 example range [RFC5737](https://tools.ietf.org/html/rfc5737)
+ - **`2001:DB8::/32`** IPv6 example range [RFC3849](https://tools.ietf.org/html/rfc3849)
+
+You can use any private range you want instead, e.g. `10.0.44.0/24`, just make sure
+it doesn't conflict with any of the LAN subnet ranges your peers are on.
+
+The complete example config for the setup below can be found here: https://github.com/pirate/wireguard-docs/tree/master/full-example (WARNING: do not use it on your devices without changing the public/private keys!).
+
+## Overview
+
+### Network Topology
+
+These 5 devices are used in our example setup to explain how WireGuard supports bridging across a variety of network conditions, they're all under an example domain `example-vpn.dev`, with the following short hostnames:
+
+- `public-server1` (not behind a NAT, acts as the main VPN bounce server)
+- `public-server2` (not behind a NAT, joins as a peer without bouncing traffic)
+- `home-server` (behind a NAT, joins as a peer without bouncing traffic)
+- `laptop` (behind NAT, sometimes shared w/ home-server/phone, sometimes roaming)
+- `phone` (behind NAT, sometimes shared w/ home-server/laptop, sometimes roaming)
+
+### Explanation
+
+This VPN config simulates setting up a small VPN subnet `192.0.2.1/24` shared by 5 nodes. Two of the nodes (public-server1 and public-server2) are VPS instances living in a cloud somewhere, with public IPs accessible to the internet. home-server is a stationary node that lives behind a NAT with a dynamic IP, but it doesn't change frequently. Phone and laptop are both roaming nodes, that can either be at home in the same LAN as home-server, or out-and-about using public wifi or cell service to connect to the VPN.
+
+Whenever possible, nodes should connect directly to each other, depending on whether nodes are directly accessible or NATs are between them, traffic will route accordingly:
+
+### The Public Relay
+
+`public-server1` acts as an intermediate relay server between any VPN clients behind NATs, it will forward any 192.0.2.1/24 traffic it receives to the correct peer at the system level (WireGuard doesn't care how this happens, it's handled by the kernel `net.ipv4.ip_forward = 1` and the iptables routing rules).
+
+Each client only needs to define the publicly accessible servers/peers in its config, any traffic bound to other peers behind NATs will go to the catchall `192.0.2.1/24` for the server and will be forwarded accordingly once it hits the main server.
+
+In summary: only direct connections between clients should be configured, any connections that need to be bounced should not be defined as peers, as they should head to the bounce server first and be routed from there back down the vpn to the correct client.
+
+## Full Example Code
+
+To run this full example, simply copy the `full wg0.conf config file for node` section from each node onto each server, enable IP forwarding on the public relay, and then start WireGuard on all the machines.
+
+For more detailed instructions, see the [Quickstart](#Quickstart) guide and API reference above. You can also download the complete example setup here: https://github.com/pirate/wireguard-docs/tree/master/full-example (WARNING: do not use it on your devices without changing the public/private keys!).
+
+## Node Config
+
+### public-server1.example-vpn.tld
+ * public endpoint: `public-server1.example-vpn.tld:51820`
+ * own vpn ip address: `192.0.2.1`
+ * can accept traffic for ips: `192.0.2.1/24`
+ * priv key: ``
+ * pub key: ``
+ * setup required:
+ 1. install wireguard
+ 2. generate public/private keypair
+ 3. create wg0.conf (see below)
+ 4. enable kernel ip & arp forwarding, add iptables forwarding rules
+ 5. start wireguard
+ * config as remote peer:
+```ini
+[Peer]
+# Name = public-server1.example-vpn.tld
+Endpoint = public-server1.example-vpn.tld:51820
+PublicKey =
+# routes traffic to itself and entire subnet of peers as bounce server
+AllowedIPs = 192.0.2.1/24
+PersistentKeepalive = 25
+```
+ * config as local interface:
+```ini
+[Interface]
+# Name = public-server1.example-vpn.tld
+Address = 192.0.2.1/24
+ListenPort = 51820
+PrivateKey =
+DNS = 1.1.1.1
+```
+ * peers: public-server2, home-server, laptop, phone
+ * full `wg0.conf` config file for node:
+```ini
+[Interface]
+# Name = public-server1.example-vpn.tld
+Address = 192.0.2.1/24
+ListenPort = 51820
+PrivateKey =
+DNS = 1.1.1.1
+
+[Peer]
+# Name = public-server2.example-vpn.dev
+Endpoint = public-server2.example-vpn.dev:51820
+PublicKey =
+AllowedIPs = 192.0.2.2/32
+
+[Peer]
+# Name = home-server.example-vpn.dev
+Endpoint = home-server.example-vpn.dev:51820
+PublicKey =
+AllowedIPs = 192.0.2.3/32
+
+[Peer]
+# Name = laptop.example-vpn.dev
+PublicKey =
+AllowedIPs = 192.0.2.4/32
+
+[Peer]
+# phone.example-vpn.dev
+PublicKey =
+AllowedIPs = 192.0.2.5/32
+```
+
+### public-server2.example-vpn.dev
+ * public endpoint: `public-server2.example-vpn.dev:51820`
+ * own vpn ip address: `192.0.2.2`
+ * can accept traffic for ips: `192.0.2.2/32`
+ * priv key: ``
+ * pub key: ``
+ * setup required:
+ 1. install wireguard
+ 2. generate public/private keypair
+ 3. create wg0.conf (see below)
+ 4. confirm main public relay server is directly accessible
+ 4. start wireguard
+ * config as local interface:
+```ini
+[Interface]
+# Name = public-server2.example-vpn.dev
+Address = 192.0.2.2/32
+ListenPort = 51820
+PrivateKey =
+DNS = 1.1.1.1
+```
+ * config as peer:
+```ini
+[Peer]
+# Name = public-server2.example-vpn.dev
+Endpoint = public-server2.example-vpn.dev:51820
+PublicKey =
+AllowedIPs = 192.0.2.2/32
+```
+ * peers: public-server1
+ * full `wg0.conf` config file for node:
+```ini
+[Interface]
+# Name = public-server2.example-vpn.dev
+Address = 192.0.2.2/32
+ListenPort = 51820
+PrivateKey =
+DNS = 1.1.1.1
+
+[Peer]
+# Name = public-server1.example-vpn.tld
+Endpoint = public-server1.example-vpn.tld:51820
+PublicKey =
+# routes traffic to itself and entire subnet of peers as bounce server
+AllowedIPs = 192.0.2.1/24
+PersistentKeepalive = 25
+```
+
+### home-server.example-vpn.dev
+ * public endpoint: (none, behind NAT)
+ * own vpn ip address: `192.0.2.3`
+ * can accept traffic for ips: `192.0.2.3/32`
+ * priv key: ``
+ * pub key: ``
+ * setup required:
+ 1. install wireguard
+ 2. generate public/private keypair
+ 3. create wg0.conf (see below)
+ 4. confirm main public relay server is directly accessible
+ 4. start wireguard
+ * config as local interface:
+```ini
+[Interface]
+# Name = home-server.example-vpn.dev
+Address = 192.0.2.3/32
+ListenPort = 51820
+PrivateKey =
+DNS = 1.1.1.1
+```
+ * config as peer:
+```ini
+[Peer]
+# Name = home-server.example-vpn.dev
+Endpoint = home-server.example-vpn.dev:51820
+PublicKey =
+AllowedIPs = 192.0.2.3/32
+```
+ * peers: public-server1
+ * full `wg0.conf` config file for node:
+```ini
+[Interface]
+# Name = home-server.example-vpn.dev
+Address = 192.0.2.3/32
+ListenPort = 51820
+PrivateKey =
+DNS = 1.1.1.1
+
+[Peer]
+# Name = public-server1.example-vpn.tld
+Endpoint = public-server1.example-vpn.tld:51820
+PublicKey =
+# routes traffic to itself and entire subnet of peers as bounce server
+AllowedIPs = 192.0.2.1/24
+PersistentKeepalive = 25
+```
+
+### laptop.example-vpn.dev
+ * public endpoint: (none, behind NAT)
+ * own vpn ip address: `192.0.2.4`
+ * can accept traffic for ips: `192.0.2.4/32`
+ * priv key: ``
+ * pub key: ``
+ * setup required:
+ 1. install wireguard
+ 2. generate public/private keypair
+ 3. create wg0.conf (see below)
+ 4. confirm main public relay server is directly accessible
+ 4. start wireguard
+ * config as local interface:
+```ini
+[Interface]
+# Name = laptop.example-vpn.dev
+Address = 192.0.2.4/32
+PrivateKey =
+DNS = 1.1.1.1
+```
+ * config as peer:
+```ini
+[Peer]
+# Name = laptop.example-vpn.dev
+PublicKey =
+AllowedIPs = 192.0.2.4/32
+```
+ * peers: public-server1
+ * full `wg0.conf` config file for node:
+```ini
+[Interface]
+# Name = laptop.example-vpn.dev
+Address = 192.0.2.4/32
+PrivateKey =
+DNS = 1.1.1.1
+
+[Peer]
+# Name = public-server1.example-vpn.tld
+Endpoint = public-server1.example-vpn.tld:51820
+PublicKey =
+# routes traffic to itself and entire subnet of peers as bounce server
+AllowedIPs = 192.0.2.1/24
+PersistentKeepalive = 25
+```
+
+### phone.example-vpn.dev
+ * public endpoint: (none, behind NAT)
+ * own vpn ip address: `192.0.2.5`
+ * can accept traffic for ips: `192.0.2.5/32`
+ * priv key: ``
+ * pub key: ``
+ * setup required:
+ 1. install wireguard
+ 2. generate public/private keypair
+ 3. create wg0.conf (see below)
+ 4. confirm main public relay server is directly accessible
+ 4. start wireguard
+ * config as local interface:
+```ini
+[Interface]
+# Name = phone.example-vpn.dev
+Address = 192.0.2.5/32
+PrivateKey =
+DNS = 1.1.1.1
+```
+ * config as peer:
+```ini
+[Peer]
+# phone.example-vpn.dev
+PublicKey =
+AllowedIPs = 192.0.2.5/32
+```
+ * peers: public-server1
+ * full `wg0.conf` config file for node:
+```ini
+[Interface]
+# Name = phone.example-vpn.dev
+Address = 192.0.2.5/32
+PrivateKey =
+DNS = 1.1.1.1
+
+[Peer]
+# Name = public-server1.example-vpn.tld
+Endpoint = public-server1.example-vpn.tld:51820
+PublicKey =
+# routes traffic to itself and entire subnet of peers as bounce server
+AllowedIPs = 192.0.2.1/24
+PersistentKeepalive = 25
+```
+
+
+
+
+Suggest changes: https://github.com/pirate/wireguard-docs/issues
+
+
diff --git a/full-example/home-server/home-server.key b/example-full/home-server/home-server.key
similarity index 100%
rename from full-example/home-server/home-server.key
rename to example-full/home-server/home-server.key
diff --git a/full-example/home-server/home-server.key.pub b/example-full/home-server/home-server.key.pub
similarity index 100%
rename from full-example/home-server/home-server.key.pub
rename to example-full/home-server/home-server.key.pub
diff --git a/full-example/home-server/setup.sh b/example-full/home-server/setup.sh
similarity index 100%
rename from full-example/home-server/setup.sh
rename to example-full/home-server/setup.sh
diff --git a/full-example/home-server/start.sh b/example-full/home-server/start.sh
similarity index 100%
rename from full-example/home-server/start.sh
rename to example-full/home-server/start.sh
diff --git a/full-example/home-server/stop.sh b/example-full/home-server/stop.sh
similarity index 100%
rename from full-example/home-server/stop.sh
rename to example-full/home-server/stop.sh
diff --git a/full-example/home-server/wg0.conf b/example-full/home-server/wg0.conf
similarity index 88%
rename from full-example/home-server/wg0.conf
rename to example-full/home-server/wg0.conf
index 2373455..b4f77fc 100644
--- a/full-example/home-server/wg0.conf
+++ b/example-full/home-server/wg0.conf
@@ -1,6 +1,6 @@
[Interface]
# Name = home-server.example-vpn.dev
-Address = 10.0.0.3/32
+Address = 10.0.44.3/32
ListenPort = 51820
PrivateKey = WN+bvd3PCWs5Pk3bvl7abWR0c1L6PCWKYRX56mjVYGo=
DNS = 1.1.1.1
@@ -10,5 +10,5 @@ DNS = 1.1.1.1
Endpoint = public-server1.example-vpn.tld:51820
PublicKey = q/+jwmL5tNuYSB3z+t9Caj00Pc1YQ8zf+uNPu/UE1wE=
# routes traffic to itself and entire subnet of peers as bounce server
-AllowedIPs = 10.0.0.1/24
+AllowedIPs = 10.0.44.1/24
PersistentKeepalive = 25
diff --git a/full-example/laptop/laptop.key b/example-full/laptop/laptop.key
similarity index 100%
rename from full-example/laptop/laptop.key
rename to example-full/laptop/laptop.key
diff --git a/full-example/laptop/laptop.key.pub b/example-full/laptop/laptop.key.pub
similarity index 100%
rename from full-example/laptop/laptop.key.pub
rename to example-full/laptop/laptop.key.pub
diff --git a/full-example/laptop/setup.sh b/example-full/laptop/setup.sh
similarity index 100%
rename from full-example/laptop/setup.sh
rename to example-full/laptop/setup.sh
diff --git a/full-example/laptop/start.sh b/example-full/laptop/start.sh
similarity index 100%
rename from full-example/laptop/start.sh
rename to example-full/laptop/start.sh
diff --git a/full-example/laptop/stop.sh b/example-full/laptop/stop.sh
similarity index 100%
rename from full-example/laptop/stop.sh
rename to example-full/laptop/stop.sh
diff --git a/full-example/laptop/wg0.conf b/example-full/laptop/wg0.conf
similarity index 88%
rename from full-example/laptop/wg0.conf
rename to example-full/laptop/wg0.conf
index d2f625d..384d0e6 100644
--- a/full-example/laptop/wg0.conf
+++ b/example-full/laptop/wg0.conf
@@ -1,6 +1,6 @@
[Interface]
# Name = laptop.example-vpn.dev
-Address = 10.0.0.4/32
+Address = 10.0.44.4/32
PrivateKey = OPmibSXYAAcMIYKNsWqr77zY06Kl750AEB1nWQi1T2o=
DNS = 1.1.1.1
@@ -9,5 +9,5 @@ DNS = 1.1.1.1
Endpoint = public-server1.example-vpn.tld:51820
PublicKey = q/+jwmL5tNuYSB3z+t9Caj00Pc1YQ8zf+uNPu/UE1wE=
# routes traffic to itself and entire subnet of peers as bounce server
-AllowedIPs = 10.0.0.1/24
+AllowedIPs = 10.0.44.1/24
PersistentKeepalive = 25
diff --git a/full-example/phone/phone.key b/example-full/phone/phone.key
similarity index 100%
rename from full-example/phone/phone.key
rename to example-full/phone/phone.key
diff --git a/full-example/phone/phone.key.pub b/example-full/phone/phone.key.pub
similarity index 100%
rename from full-example/phone/phone.key.pub
rename to example-full/phone/phone.key.pub
diff --git a/full-example/phone/setup.sh b/example-full/phone/setup.sh
similarity index 100%
rename from full-example/phone/setup.sh
rename to example-full/phone/setup.sh
diff --git a/full-example/phone/start.sh b/example-full/phone/start.sh
similarity index 100%
rename from full-example/phone/start.sh
rename to example-full/phone/start.sh
diff --git a/full-example/phone/stop.sh b/example-full/phone/stop.sh
similarity index 100%
rename from full-example/phone/stop.sh
rename to example-full/phone/stop.sh
diff --git a/full-example/phone/wg0.conf b/example-full/phone/wg0.conf
similarity index 88%
rename from full-example/phone/wg0.conf
rename to example-full/phone/wg0.conf
index 47cf7a1..f74fa1b 100644
--- a/full-example/phone/wg0.conf
+++ b/example-full/phone/wg0.conf
@@ -1,6 +1,6 @@
[Interface]
# Name = phone.example-vpn.dev
-Address = 10.0.0.5/32
+Address = 10.0.44.5/32
PrivateKey = WH98AvjKKZ584ZLb69G912bNry2wOda9+kfzm+qbnUw=
DNS = 1.1.1.1
@@ -9,5 +9,5 @@ DNS = 1.1.1.1
Endpoint = public-server1.example-vpn.tld:51820
PublicKey = q/+jwmL5tNuYSB3z+t9Caj00Pc1YQ8zf+uNPu/UE1wE=
# routes traffic to itself and entire subnet of peers as bounce server
-AllowedIPs = 10.0.0.1/24
+AllowedIPs = 10.0.44.1/24
PersistentKeepalive = 25
diff --git a/full-example/public-server1/public-server1.key b/example-full/public-server1/public-server1.key
similarity index 100%
rename from full-example/public-server1/public-server1.key
rename to example-full/public-server1/public-server1.key
diff --git a/full-example/public-server1/public-server1.key.pub b/example-full/public-server1/public-server1.key.pub
similarity index 100%
rename from full-example/public-server1/public-server1.key.pub
rename to example-full/public-server1/public-server1.key.pub
diff --git a/full-example/public-server1/setup.sh b/example-full/public-server1/setup.sh
similarity index 89%
rename from full-example/public-server1/setup.sh
rename to example-full/public-server1/setup.sh
index b9991f8..385c4d8 100644
--- a/full-example/public-server1/setup.sh
+++ b/example-full/public-server1/setup.sh
@@ -14,4 +14,4 @@ sudo sysctl -p /etc/sysctl.conf
iptables -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i wg0 -o wg0 -m conntrack --ctstate NEW -j ACCEPT
-iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -o eth0 -j MASQUERADE
+iptables -t nat -A POSTROUTING -s 10.0.44.0/24 -o eth0 -j MASQUERADE
diff --git a/full-example/public-server1/start.sh b/example-full/public-server1/start.sh
similarity index 100%
rename from full-example/public-server1/start.sh
rename to example-full/public-server1/start.sh
diff --git a/full-example/public-server1/stop.sh b/example-full/public-server1/stop.sh
similarity index 100%
rename from full-example/public-server1/stop.sh
rename to example-full/public-server1/stop.sh
diff --git a/full-example/public-server1/wg0.conf b/example-full/public-server1/wg0.conf
similarity index 83%
rename from full-example/public-server1/wg0.conf
rename to example-full/public-server1/wg0.conf
index 7e28ae4..c821daa 100644
--- a/full-example/public-server1/wg0.conf
+++ b/example-full/public-server1/wg0.conf
@@ -1,6 +1,6 @@
[Interface]
# Name = public-server1.example-vpn.tld
-Address = 10.0.0.1/24
+Address = 10.0.44.1/24
ListenPort = 51820
PrivateKey = 2P/3ll/TxGTjGqwcWnqJMnjwPqGw7oX1RaXlPfsf2FQ=
DNS = 1.1.1.1
@@ -9,20 +9,20 @@ DNS = 1.1.1.1
# Name = public-server2.example-vpn.dev
Endpoint = public-server2.example-vpn.dev:51820
PublicKey = SceMEaVZaZfOGtGXjMsoJjhwxKHkb++9wjxqN1vm32s=
-AllowedIPs = 10.0.0.2/32
+AllowedIPs = 10.0.44.2/32
[Peer]
# Name = home-server.example-vpn.dev
Endpoint = home-server.example-vpn.dev:51820
PublicKey = 8bSk5fATxg9qdxbK20iTGdrQ7SWvxIBhxdMo+W54pEg=
-AllowedIPs = 10.0.0.3/32
+AllowedIPs = 10.0.44.3/32
[Peer]
# Name = laptop.example-vpn.dev
PublicKey = BV5DjXeCugIrjvEZLo4sZ0hN5wveFTH8kOfZ1AIQ5js=
-AllowedIPs = 10.0.0.4/32
+AllowedIPs = 10.0.44.4/32
[Peer]
# Name = phone.example-vpn.dev
PublicKey = VpjKa2MQKXuvttXRwJIe0LLYrtFYGQRTtmt8okUGm3A=
-AllowedIPs = 10.0.0.5/32
+AllowedIPs = 10.0.44.5/32
diff --git a/full-example/public-server2/public-server2.key b/example-full/public-server2/public-server2.key
similarity index 100%
rename from full-example/public-server2/public-server2.key
rename to example-full/public-server2/public-server2.key
diff --git a/full-example/public-server2/public-server2.key.pub b/example-full/public-server2/public-server2.key.pub
similarity index 100%
rename from full-example/public-server2/public-server2.key.pub
rename to example-full/public-server2/public-server2.key.pub
diff --git a/full-example/public-server2/setup.sh b/example-full/public-server2/setup.sh
similarity index 100%
rename from full-example/public-server2/setup.sh
rename to example-full/public-server2/setup.sh
diff --git a/full-example/public-server2/start.sh b/example-full/public-server2/start.sh
similarity index 100%
rename from full-example/public-server2/start.sh
rename to example-full/public-server2/start.sh
diff --git a/full-example/public-server2/stop.sh b/example-full/public-server2/stop.sh
similarity index 100%
rename from full-example/public-server2/stop.sh
rename to example-full/public-server2/stop.sh
diff --git a/full-example/public-server2/wg0.conf b/example-full/public-server2/wg0.conf
similarity index 88%
rename from full-example/public-server2/wg0.conf
rename to example-full/public-server2/wg0.conf
index fa8cf16..f2dabff 100644
--- a/full-example/public-server2/wg0.conf
+++ b/example-full/public-server2/wg0.conf
@@ -1,6 +1,6 @@
[Interface]
# Name = public-server2.example-vpn.dev
-Address = 10.0.0.2/32
+Address = 10.0.44.2/32
ListenPort = 51820
PrivateKey = eDwURfg8PhpUAdPp+OA9pQ5oZQYqGqY3LToUORMh220=
DNS = 1.1.1.1
@@ -10,5 +10,5 @@ DNS = 1.1.1.1
Endpoint = public-server1.example-vpn.tld:51820
PublicKey = q/+jwmL5tNuYSB3z+t9Caj00Pc1YQ8zf+uNPu/UE1wE=
# routes traffic to itself and entire subnet of peers as bounce server
-AllowedIPs = 10.0.0.1/24
+AllowedIPs = 10.0.44.1/24
PersistentKeepalive = 25
diff --git a/example-internet-browsing-vpn/laptop/laptop.key b/example-internet-browsing-vpn/laptop/laptop.key
new file mode 100644
index 0000000..686b3d9
--- /dev/null
+++ b/example-internet-browsing-vpn/laptop/laptop.key
@@ -0,0 +1 @@
+OPmibSXYAAcMIYKNsWqr77zY06Kl750AEB1nWQi1T2o=
diff --git a/example-internet-browsing-vpn/laptop/laptop.key.pub b/example-internet-browsing-vpn/laptop/laptop.key.pub
new file mode 100644
index 0000000..4165fa8
--- /dev/null
+++ b/example-internet-browsing-vpn/laptop/laptop.key.pub
@@ -0,0 +1 @@
+BV5DjXeCugIrjvEZLo4sZ0hN5wveFTH8kOfZ1AIQ5js=
diff --git a/example-internet-browsing-vpn/laptop/setup.sh b/example-internet-browsing-vpn/laptop/setup.sh
new file mode 100644
index 0000000..5fb0157
--- /dev/null
+++ b/example-internet-browsing-vpn/laptop/setup.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+# install wireguard on Ubuntu
+#add-apt-repository ppa:wireguard/wireguard
+#apt update
+#apt install wireguard
+
+# install wireguard on macOS
+brew install wireguard-tools
diff --git a/example-internet-browsing-vpn/laptop/start.sh b/example-internet-browsing-vpn/laptop/start.sh
new file mode 100644
index 0000000..9e6a2fb
--- /dev/null
+++ b/example-internet-browsing-vpn/laptop/start.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+PEER_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+wg-quick up "$PEER_DIR"/wg0.conf
+wg show
diff --git a/example-internet-browsing-vpn/laptop/stop.sh b/example-internet-browsing-vpn/laptop/stop.sh
new file mode 100644
index 0000000..2faef2c
--- /dev/null
+++ b/example-internet-browsing-vpn/laptop/stop.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+PEER_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+wg-quick down "$PEER_DIR"/wg0.conf
+wg show
diff --git a/example-internet-browsing-vpn/laptop/wg0.conf b/example-internet-browsing-vpn/laptop/wg0.conf
new file mode 100644
index 0000000..38e6187
--- /dev/null
+++ b/example-internet-browsing-vpn/laptop/wg0.conf
@@ -0,0 +1,12 @@
+[Interface]
+# Name = laptop.example-vpn.dev
+Address = 10.0.44.2/32
+PrivateKey = OPmibSXYAAcMIYKNsWqr77zY06Kl750AEB1nWQi1T2o=
+DNS = 1.1.1.1
+
+[Peer]
+# Name = server.example-vpn.tld
+Endpoint = server.example-vpn.tld:51820
+PublicKey = q/+jwmL5tNuYSB3z+t9Caj00Pc1YQ8zf+uNPu/UE1wE=
+AllowedIPs = 0.0.0.0/0, ::/0
+PersistentKeepalive = 25
diff --git a/example-internet-browsing-vpn/phone/phone.key b/example-internet-browsing-vpn/phone/phone.key
new file mode 100644
index 0000000..a855da1
--- /dev/null
+++ b/example-internet-browsing-vpn/phone/phone.key
@@ -0,0 +1 @@
+WH98AvjKKZ584ZLb69G912bNry2wOda9+kfzm+qbnUw=
diff --git a/example-internet-browsing-vpn/phone/phone.key.pub b/example-internet-browsing-vpn/phone/phone.key.pub
new file mode 100644
index 0000000..0d67922
--- /dev/null
+++ b/example-internet-browsing-vpn/phone/phone.key.pub
@@ -0,0 +1 @@
+VpjKa2MQKXuvttXRwJIe0LLYrtFYGQRTtmt8okUGm3A=
diff --git a/example-internet-browsing-vpn/phone/setup.sh b/example-internet-browsing-vpn/phone/setup.sh
new file mode 100644
index 0000000..fdbf4f4
--- /dev/null
+++ b/example-internet-browsing-vpn/phone/setup.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+# install wireguard on iOS/Android
+echo "Use the iOS App Store / Google Play Store to install WireGuard on your mobile device"
diff --git a/example-internet-browsing-vpn/phone/start.sh b/example-internet-browsing-vpn/phone/start.sh
new file mode 100644
index 0000000..de47355
--- /dev/null
+++ b/example-internet-browsing-vpn/phone/start.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+echo "Use the iOS/Android app to load the wg0.conf file and start Wireguard"
diff --git a/example-internet-browsing-vpn/phone/stop.sh b/example-internet-browsing-vpn/phone/stop.sh
new file mode 100644
index 0000000..4fc7f4a
--- /dev/null
+++ b/example-internet-browsing-vpn/phone/stop.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+echo "Use the iOS/Android app to load the wg0.conf file and stop Wireguard"
diff --git a/example-internet-browsing-vpn/phone/wg0.conf b/example-internet-browsing-vpn/phone/wg0.conf
new file mode 100644
index 0000000..5af3804
--- /dev/null
+++ b/example-internet-browsing-vpn/phone/wg0.conf
@@ -0,0 +1,12 @@
+[Interface]
+# Name = phone.example-vpn.dev
+Address = 10.0.44.3/32
+PrivateKey = WH98AvjKKZ584ZLb69G912bNry2wOda9+kfzm+qbnUw=
+DNS = 1.1.1.1
+
+[Peer]
+# Name = server.example-vpn.tld
+Endpoint = server.example-vpn.tld:51820
+PublicKey = q/+jwmL5tNuYSB3z+t9Caj00Pc1YQ8zf+uNPu/UE1wE=
+AllowedIPs = 0.0.0.0/0, ::/0
+PersistentKeepalive = 25
diff --git a/example-internet-browsing-vpn/server/server.key b/example-internet-browsing-vpn/server/server.key
new file mode 100644
index 0000000..e97b37e
--- /dev/null
+++ b/example-internet-browsing-vpn/server/server.key
@@ -0,0 +1 @@
+2P/3ll/TxGTjGqwcWnqJMnjwPqGw7oX1RaXlPfsf2FQ=
diff --git a/example-internet-browsing-vpn/server/server.key.pub b/example-internet-browsing-vpn/server/server.key.pub
new file mode 100644
index 0000000..5912f3f
--- /dev/null
+++ b/example-internet-browsing-vpn/server/server.key.pub
@@ -0,0 +1 @@
+q/+jwmL5tNuYSB3z+t9Caj00Pc1YQ8zf+uNPu/UE1wE=
diff --git a/example-internet-browsing-vpn/server/setup.sh b/example-internet-browsing-vpn/server/setup.sh
new file mode 100644
index 0000000..385c4d8
--- /dev/null
+++ b/example-internet-browsing-vpn/server/setup.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+# install wireguard
+add-apt-repository ppa:wireguard/wireguard
+apt update
+apt install wireguard
+
+# to enable kernel relaying/forwarding ability on bounce servers
+echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
+echo "net.ipv4.conf.all.proxy_arp" >> /etc/sysctl.conf
+sudo sysctl -p /etc/sysctl.conf
+
+# to add iptables forwarding rules on bounce servers
+iptables -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
+iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
+iptables -A FORWARD -i wg0 -o wg0 -m conntrack --ctstate NEW -j ACCEPT
+iptables -t nat -A POSTROUTING -s 10.0.44.0/24 -o eth0 -j MASQUERADE
diff --git a/example-internet-browsing-vpn/server/start.sh b/example-internet-browsing-vpn/server/start.sh
new file mode 100644
index 0000000..9e6a2fb
--- /dev/null
+++ b/example-internet-browsing-vpn/server/start.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+PEER_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+wg-quick up "$PEER_DIR"/wg0.conf
+wg show
diff --git a/example-internet-browsing-vpn/server/stop.sh b/example-internet-browsing-vpn/server/stop.sh
new file mode 100644
index 0000000..2faef2c
--- /dev/null
+++ b/example-internet-browsing-vpn/server/stop.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+PEER_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+wg-quick down "$PEER_DIR"/wg0.conf
+wg show
diff --git a/example-internet-browsing-vpn/server/wg0.conf b/example-internet-browsing-vpn/server/wg0.conf
new file mode 100644
index 0000000..0b0d6b8
--- /dev/null
+++ b/example-internet-browsing-vpn/server/wg0.conf
@@ -0,0 +1,18 @@
+[Interface]
+# Name = server.example-vpn.tld
+Address = 10.0.44.1/24
+ListenPort = 51820
+PrivateKey = 2P/3ll/TxGTjGqwcWnqJMnjwPqGw7oX1RaXlPfsf2FQ=
+DNS = 1.1.1.1
+PostUp = sysctl -w net.ipv4.ip_forward=1
+PostUp = sysctl -w net.ipv6.conf.all.forwarding=1
+
+[Peer]
+# Name = laptop.example-vpn.dev
+PublicKey = BV5DjXeCugIrjvEZLo4sZ0hN5wveFTH8kOfZ1AIQ5js=
+AllowedIPs = 10.0.44.2/32
+
+[Peer]
+# Name = phone.example-vpn.dev
+PublicKey = VpjKa2MQKXuvttXRwJIe0LLYrtFYGQRTtmt8okUGm3A=
+AllowedIPs = 10.0.44.3/32
diff --git a/example-lan-briding/montreal/montreal.key b/example-lan-briding/montreal/montreal.key
new file mode 100644
index 0000000..e97b37e
--- /dev/null
+++ b/example-lan-briding/montreal/montreal.key
@@ -0,0 +1 @@
+2P/3ll/TxGTjGqwcWnqJMnjwPqGw7oX1RaXlPfsf2FQ=
diff --git a/example-lan-briding/montreal/montreal.key.pub b/example-lan-briding/montreal/montreal.key.pub
new file mode 100644
index 0000000..5912f3f
--- /dev/null
+++ b/example-lan-briding/montreal/montreal.key.pub
@@ -0,0 +1 @@
+q/+jwmL5tNuYSB3z+t9Caj00Pc1YQ8zf+uNPu/UE1wE=
diff --git a/example-lan-briding/montreal/setup.sh b/example-lan-briding/montreal/setup.sh
new file mode 100644
index 0000000..385c4d8
--- /dev/null
+++ b/example-lan-briding/montreal/setup.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+# install wireguard
+add-apt-repository ppa:wireguard/wireguard
+apt update
+apt install wireguard
+
+# to enable kernel relaying/forwarding ability on bounce servers
+echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
+echo "net.ipv4.conf.all.proxy_arp" >> /etc/sysctl.conf
+sudo sysctl -p /etc/sysctl.conf
+
+# to add iptables forwarding rules on bounce servers
+iptables -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
+iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
+iptables -A FORWARD -i wg0 -o wg0 -m conntrack --ctstate NEW -j ACCEPT
+iptables -t nat -A POSTROUTING -s 10.0.44.0/24 -o eth0 -j MASQUERADE
diff --git a/example-lan-briding/montreal/start.sh b/example-lan-briding/montreal/start.sh
new file mode 100644
index 0000000..9e6a2fb
--- /dev/null
+++ b/example-lan-briding/montreal/start.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+PEER_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+wg-quick up "$PEER_DIR"/wg0.conf
+wg show
diff --git a/example-lan-briding/montreal/stop.sh b/example-lan-briding/montreal/stop.sh
new file mode 100644
index 0000000..2faef2c
--- /dev/null
+++ b/example-lan-briding/montreal/stop.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+PEER_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+wg-quick down "$PEER_DIR"/wg0.conf
+wg show
diff --git a/example-lan-briding/montreal/wg0.conf b/example-lan-briding/montreal/wg0.conf
new file mode 100644
index 0000000..d97f824
--- /dev/null
+++ b/example-lan-briding/montreal/wg0.conf
@@ -0,0 +1,26 @@
+[Interface]
+# Name = montreal.example-vpn.tld
+# LAN = 192.168.1.1/24
+Address = 10.0.44.1/24
+ListenPort = 51820
+PrivateKey = 2P/3ll/TxGTjGqwcWnqJMnjwPqGw7oX1RaXlPfsf2FQ=
+DNS = 1.1.1.1
+PostUp = sysctl -w net.ipv4.ip_forward=1
+PostUp = sysctl -w net.ipv6.conf.all.forwarding=1
+PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
+PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
+
+
+[Peer]
+# Name = newyork.example-vpn.dev
+# LAN = 192.168.2.1/24
+Endpoint = newyork.example-vpn.dev:51820
+PublicKey = SceMEaVZaZfOGtGXjMsoJjhwxKHkb++9wjxqN1vm32s=
+AllowedIPs = 10.0.44.2/32, 192.168.2.1/24
+
+[Peer]
+# Name = vancouver.example-vpn.dev
+# LAN = 192.168.3.1/24
+Endpoint = vancouver.example-vpn.dev:51820
+PublicKey = 8bSk5fATxg9qdxbK20iTGdrQ7SWvxIBhxdMo+W54pEg=
+AllowedIPs = 10.0.44.3/32, 192.168.3.1/24
diff --git a/example-lan-briding/newyork/newyork.key b/example-lan-briding/newyork/newyork.key
new file mode 100644
index 0000000..44ad287
--- /dev/null
+++ b/example-lan-briding/newyork/newyork.key
@@ -0,0 +1 @@
+eDwURfg8PhpUAdPp+OA9pQ5oZQYqGqY3LToUORMh220=
diff --git a/example-lan-briding/newyork/newyork.key.pub b/example-lan-briding/newyork/newyork.key.pub
new file mode 100644
index 0000000..52e4ce1
--- /dev/null
+++ b/example-lan-briding/newyork/newyork.key.pub
@@ -0,0 +1 @@
+SceMEaVZaZfOGtGXjMsoJjhwxKHkb++9wjxqN1vm32s=
diff --git a/example-lan-briding/newyork/setup.sh b/example-lan-briding/newyork/setup.sh
new file mode 100644
index 0000000..5bfea98
--- /dev/null
+++ b/example-lan-briding/newyork/setup.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+# install wireguard
+add-apt-repository ppa:wireguard/wireguard
+apt update
+apt install wireguard
diff --git a/example-lan-briding/newyork/start.sh b/example-lan-briding/newyork/start.sh
new file mode 100644
index 0000000..9e6a2fb
--- /dev/null
+++ b/example-lan-briding/newyork/start.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+PEER_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+wg-quick up "$PEER_DIR"/wg0.conf
+wg show
diff --git a/example-lan-briding/newyork/stop.sh b/example-lan-briding/newyork/stop.sh
new file mode 100644
index 0000000..2faef2c
--- /dev/null
+++ b/example-lan-briding/newyork/stop.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+PEER_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+wg-quick down "$PEER_DIR"/wg0.conf
+wg show
diff --git a/example-lan-briding/newyork/wg0.conf b/example-lan-briding/newyork/wg0.conf
new file mode 100644
index 0000000..e1546ca
--- /dev/null
+++ b/example-lan-briding/newyork/wg0.conf
@@ -0,0 +1,26 @@
+[Interface]
+# Name = newyork.example-vpn.dev
+# LAN = 192.168.2.1/24
+Address = 10.0.44.2/32
+ListenPort = 51820
+PrivateKey = eDwURfg8PhpUAdPp+OA9pQ5oZQYqGqY3LToUORMh220=
+DNS = 1.1.1.1
+PostUp = sysctl -w net.ipv4.ip_forward=1
+PostUp = sysctl -w net.ipv6.conf.all.forwarding=1
+PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
+PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
+
+
+[Peer]
+# Name = montreal.example-vpn.dev
+# LAN = 192.168.1.1/24
+Endpoint = montreal.example-vpn.dev:51820
+PublicKey = q/+jwmL5tNuYSB3z+t9Caj00Pc1YQ8zf+uNPu/UE1wE=
+AllowedIPs = 10.0.44.1/32, 192.168.1.1/24
+
+[Peer]
+# Name = vancouver.example-vpn.dev
+# LAN = 192.168.3.1/24
+Endpoint = vancouver.example-vpn.dev:51820
+PublicKey = 8bSk5fATxg9qdxbK20iTGdrQ7SWvxIBhxdMo+W54pEg=
+AllowedIPs = 10.0.44.3/32, 192.168.3.1/24
diff --git a/example-lan-briding/vancouver/setup.sh b/example-lan-briding/vancouver/setup.sh
new file mode 100644
index 0000000..385c4d8
--- /dev/null
+++ b/example-lan-briding/vancouver/setup.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+# install wireguard
+add-apt-repository ppa:wireguard/wireguard
+apt update
+apt install wireguard
+
+# to enable kernel relaying/forwarding ability on bounce servers
+echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
+echo "net.ipv4.conf.all.proxy_arp" >> /etc/sysctl.conf
+sudo sysctl -p /etc/sysctl.conf
+
+# to add iptables forwarding rules on bounce servers
+iptables -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
+iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
+iptables -A FORWARD -i wg0 -o wg0 -m conntrack --ctstate NEW -j ACCEPT
+iptables -t nat -A POSTROUTING -s 10.0.44.0/24 -o eth0 -j MASQUERADE
diff --git a/example-lan-briding/vancouver/start.sh b/example-lan-briding/vancouver/start.sh
new file mode 100644
index 0000000..9e6a2fb
--- /dev/null
+++ b/example-lan-briding/vancouver/start.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+PEER_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+wg-quick up "$PEER_DIR"/wg0.conf
+wg show
diff --git a/example-lan-briding/vancouver/stop.sh b/example-lan-briding/vancouver/stop.sh
new file mode 100644
index 0000000..2faef2c
--- /dev/null
+++ b/example-lan-briding/vancouver/stop.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+PEER_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+wg-quick down "$PEER_DIR"/wg0.conf
+wg show
diff --git a/example-lan-briding/vancouver/vancouver.key b/example-lan-briding/vancouver/vancouver.key
new file mode 100644
index 0000000..e97b37e
--- /dev/null
+++ b/example-lan-briding/vancouver/vancouver.key
@@ -0,0 +1 @@
+2P/3ll/TxGTjGqwcWnqJMnjwPqGw7oX1RaXlPfsf2FQ=
diff --git a/example-lan-briding/vancouver/vancouver.key.pub b/example-lan-briding/vancouver/vancouver.key.pub
new file mode 100644
index 0000000..5912f3f
--- /dev/null
+++ b/example-lan-briding/vancouver/vancouver.key.pub
@@ -0,0 +1 @@
+q/+jwmL5tNuYSB3z+t9Caj00Pc1YQ8zf+uNPu/UE1wE=
diff --git a/example-lan-briding/vancouver/wg0.conf b/example-lan-briding/vancouver/wg0.conf
new file mode 100644
index 0000000..f1d755c
--- /dev/null
+++ b/example-lan-briding/vancouver/wg0.conf
@@ -0,0 +1,26 @@
+[Interface]
+# Name = vancouver.example-vpn.tld
+# LAN = 192.168.3.1/24
+Address = 10.0.44.3/24
+ListenPort = 51820
+PrivateKey = WN+bvd3PCWs5Pk3bvl7abWR0c1L6PCWKYRX56mjVYGo=
+DNS = 1.1.1.1
+PostUp = sysctl -w net.ipv4.ip_forward=1
+PostUp = sysctl -w net.ipv6.conf.all.forwarding=1
+PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
+PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
+
+
+[Peer]
+# Name = montreal.example-vpn.dev
+# LAN = 192.168.1.1/24
+Endpoint = montreal.example-vpn.dev:51820
+PublicKey = q/+jwmL5tNuYSB3z+t9Caj00Pc1YQ8zf+uNPu/UE1wE=
+AllowedIPs = 10.0.44.1/32, 192.168.1.1/24
+
+[Peer]
+# Name = newyork.example-vpn.dev
+# LAN = 192.168.2.1/24
+Endpoint = newyork.example-vpn.dev:51820
+PublicKey = SceMEaVZaZfOGtGXjMsoJjhwxKHkb++9wjxqN1vm32s=
+AllowedIPs = 10.0.44.2/32, 192.168.2.1/24
diff --git a/example-simple-client-to-server/client/client.key b/example-simple-client-to-server/client/client.key
new file mode 100644
index 0000000..686b3d9
--- /dev/null
+++ b/example-simple-client-to-server/client/client.key
@@ -0,0 +1 @@
+OPmibSXYAAcMIYKNsWqr77zY06Kl750AEB1nWQi1T2o=
diff --git a/example-simple-client-to-server/client/client.key.pub b/example-simple-client-to-server/client/client.key.pub
new file mode 100644
index 0000000..4165fa8
--- /dev/null
+++ b/example-simple-client-to-server/client/client.key.pub
@@ -0,0 +1 @@
+BV5DjXeCugIrjvEZLo4sZ0hN5wveFTH8kOfZ1AIQ5js=
diff --git a/example-simple-client-to-server/client/setup.sh b/example-simple-client-to-server/client/setup.sh
new file mode 100644
index 0000000..5fb0157
--- /dev/null
+++ b/example-simple-client-to-server/client/setup.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+# install wireguard on Ubuntu
+#add-apt-repository ppa:wireguard/wireguard
+#apt update
+#apt install wireguard
+
+# install wireguard on macOS
+brew install wireguard-tools
diff --git a/example-simple-client-to-server/client/start.sh b/example-simple-client-to-server/client/start.sh
new file mode 100644
index 0000000..9e6a2fb
--- /dev/null
+++ b/example-simple-client-to-server/client/start.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+PEER_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+wg-quick up "$PEER_DIR"/wg0.conf
+wg show
diff --git a/example-simple-client-to-server/client/stop.sh b/example-simple-client-to-server/client/stop.sh
new file mode 100644
index 0000000..2faef2c
--- /dev/null
+++ b/example-simple-client-to-server/client/stop.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+PEER_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+wg-quick down "$PEER_DIR"/wg0.conf
+wg show
diff --git a/example-simple-client-to-server/client/wg0.conf b/example-simple-client-to-server/client/wg0.conf
new file mode 100644
index 0000000..fd3fdc3
--- /dev/null
+++ b/example-simple-client-to-server/client/wg0.conf
@@ -0,0 +1,12 @@
+[Interface]
+# Name = laptop.example-vpn.dev
+Address = 10.0.44.2/32
+PrivateKey = OPmibSXYAAcMIYKNsWqr77zY06Kl750AEB1nWQi1T2o=
+DNS = 1.1.1.1
+
+[Peer]
+# Name = server.example-vpn.tld
+Endpoint = server.example-vpn.tld:51820
+PublicKey = q/+jwmL5tNuYSB3z+t9Caj00Pc1YQ8zf+uNPu/UE1wE=
+AllowedIPs = 10.0.44.1/24
+PersistentKeepalive = 25
diff --git a/example-simple-client-to-server/server/server.key b/example-simple-client-to-server/server/server.key
new file mode 100644
index 0000000..e97b37e
--- /dev/null
+++ b/example-simple-client-to-server/server/server.key
@@ -0,0 +1 @@
+2P/3ll/TxGTjGqwcWnqJMnjwPqGw7oX1RaXlPfsf2FQ=
diff --git a/example-simple-client-to-server/server/server.key.pub b/example-simple-client-to-server/server/server.key.pub
new file mode 100644
index 0000000..5912f3f
--- /dev/null
+++ b/example-simple-client-to-server/server/server.key.pub
@@ -0,0 +1 @@
+q/+jwmL5tNuYSB3z+t9Caj00Pc1YQ8zf+uNPu/UE1wE=
diff --git a/example-simple-client-to-server/server/setup.sh b/example-simple-client-to-server/server/setup.sh
new file mode 100644
index 0000000..385c4d8
--- /dev/null
+++ b/example-simple-client-to-server/server/setup.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+# install wireguard
+add-apt-repository ppa:wireguard/wireguard
+apt update
+apt install wireguard
+
+# to enable kernel relaying/forwarding ability on bounce servers
+echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
+echo "net.ipv4.conf.all.proxy_arp" >> /etc/sysctl.conf
+sudo sysctl -p /etc/sysctl.conf
+
+# to add iptables forwarding rules on bounce servers
+iptables -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
+iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
+iptables -A FORWARD -i wg0 -o wg0 -m conntrack --ctstate NEW -j ACCEPT
+iptables -t nat -A POSTROUTING -s 10.0.44.0/24 -o eth0 -j MASQUERADE
diff --git a/example-simple-client-to-server/server/start.sh b/example-simple-client-to-server/server/start.sh
new file mode 100644
index 0000000..9e6a2fb
--- /dev/null
+++ b/example-simple-client-to-server/server/start.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+PEER_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+wg-quick up "$PEER_DIR"/wg0.conf
+wg show
diff --git a/example-simple-client-to-server/server/stop.sh b/example-simple-client-to-server/server/stop.sh
new file mode 100644
index 0000000..2faef2c
--- /dev/null
+++ b/example-simple-client-to-server/server/stop.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+PEER_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+wg-quick down "$PEER_DIR"/wg0.conf
+wg show
diff --git a/example-simple-client-to-server/server/wg0.conf b/example-simple-client-to-server/server/wg0.conf
new file mode 100644
index 0000000..24db5bf
--- /dev/null
+++ b/example-simple-client-to-server/server/wg0.conf
@@ -0,0 +1,11 @@
+[Interface]
+# Name = public-server1.example-vpn.tld
+Address = 10.0.44.1/24
+ListenPort = 51820
+PrivateKey = 2P/3ll/TxGTjGqwcWnqJMnjwPqGw7oX1RaXlPfsf2FQ=
+DNS = 1.1.1.1
+
+[Peer]
+# Name = client.example-vpn.dev
+PublicKey = BV5DjXeCugIrjvEZLo4sZ0hN5wveFTH8kOfZ1AIQ5js=
+AllowedIPs = 10.0.44.2/32
diff --git a/example-simple-server-to-server/server1/server1.key b/example-simple-server-to-server/server1/server1.key
new file mode 100644
index 0000000..e97b37e
--- /dev/null
+++ b/example-simple-server-to-server/server1/server1.key
@@ -0,0 +1 @@
+2P/3ll/TxGTjGqwcWnqJMnjwPqGw7oX1RaXlPfsf2FQ=
diff --git a/example-simple-server-to-server/server1/server1.key.pub b/example-simple-server-to-server/server1/server1.key.pub
new file mode 100644
index 0000000..5912f3f
--- /dev/null
+++ b/example-simple-server-to-server/server1/server1.key.pub
@@ -0,0 +1 @@
+q/+jwmL5tNuYSB3z+t9Caj00Pc1YQ8zf+uNPu/UE1wE=
diff --git a/example-simple-server-to-server/server1/setup.sh b/example-simple-server-to-server/server1/setup.sh
new file mode 100644
index 0000000..385c4d8
--- /dev/null
+++ b/example-simple-server-to-server/server1/setup.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+# install wireguard
+add-apt-repository ppa:wireguard/wireguard
+apt update
+apt install wireguard
+
+# to enable kernel relaying/forwarding ability on bounce servers
+echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
+echo "net.ipv4.conf.all.proxy_arp" >> /etc/sysctl.conf
+sudo sysctl -p /etc/sysctl.conf
+
+# to add iptables forwarding rules on bounce servers
+iptables -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
+iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
+iptables -A FORWARD -i wg0 -o wg0 -m conntrack --ctstate NEW -j ACCEPT
+iptables -t nat -A POSTROUTING -s 10.0.44.0/24 -o eth0 -j MASQUERADE
diff --git a/example-simple-server-to-server/server1/start.sh b/example-simple-server-to-server/server1/start.sh
new file mode 100644
index 0000000..9e6a2fb
--- /dev/null
+++ b/example-simple-server-to-server/server1/start.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+PEER_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+wg-quick up "$PEER_DIR"/wg0.conf
+wg show
diff --git a/example-simple-server-to-server/server1/stop.sh b/example-simple-server-to-server/server1/stop.sh
new file mode 100644
index 0000000..2faef2c
--- /dev/null
+++ b/example-simple-server-to-server/server1/stop.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+PEER_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+wg-quick down "$PEER_DIR"/wg0.conf
+wg show
diff --git a/example-simple-server-to-server/server1/wg0.conf b/example-simple-server-to-server/server1/wg0.conf
new file mode 100644
index 0000000..efd9d06
--- /dev/null
+++ b/example-simple-server-to-server/server1/wg0.conf
@@ -0,0 +1,12 @@
+[Interface]
+# Name = server1.example-vpn.tld
+Address = 10.0.44.1/24
+ListenPort = 51820
+PrivateKey = 2P/3ll/TxGTjGqwcWnqJMnjwPqGw7oX1RaXlPfsf2FQ=
+DNS = 1.1.1.1
+
+[Peer]
+# Name = server2.example-vpn.dev
+Endpoint = server2.example-vpn.dev:51820
+PublicKey = SceMEaVZaZfOGtGXjMsoJjhwxKHkb++9wjxqN1vm32s=
+AllowedIPs = 10.0.44.2/32
diff --git a/example-simple-server-to-server/server2/server2.key b/example-simple-server-to-server/server2/server2.key
new file mode 100644
index 0000000..44ad287
--- /dev/null
+++ b/example-simple-server-to-server/server2/server2.key
@@ -0,0 +1 @@
+eDwURfg8PhpUAdPp+OA9pQ5oZQYqGqY3LToUORMh220=
diff --git a/example-simple-server-to-server/server2/server2.key.pub b/example-simple-server-to-server/server2/server2.key.pub
new file mode 100644
index 0000000..52e4ce1
--- /dev/null
+++ b/example-simple-server-to-server/server2/server2.key.pub
@@ -0,0 +1 @@
+SceMEaVZaZfOGtGXjMsoJjhwxKHkb++9wjxqN1vm32s=
diff --git a/example-simple-server-to-server/server2/setup.sh b/example-simple-server-to-server/server2/setup.sh
new file mode 100644
index 0000000..5bfea98
--- /dev/null
+++ b/example-simple-server-to-server/server2/setup.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+# install wireguard
+add-apt-repository ppa:wireguard/wireguard
+apt update
+apt install wireguard
diff --git a/example-simple-server-to-server/server2/start.sh b/example-simple-server-to-server/server2/start.sh
new file mode 100644
index 0000000..9e6a2fb
--- /dev/null
+++ b/example-simple-server-to-server/server2/start.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+PEER_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+wg-quick up "$PEER_DIR"/wg0.conf
+wg show
diff --git a/example-simple-server-to-server/server2/stop.sh b/example-simple-server-to-server/server2/stop.sh
new file mode 100644
index 0000000..2faef2c
--- /dev/null
+++ b/example-simple-server-to-server/server2/stop.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+PEER_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+wg-quick down "$PEER_DIR"/wg0.conf
+wg show
diff --git a/example-simple-server-to-server/server2/wg0.conf b/example-simple-server-to-server/server2/wg0.conf
new file mode 100644
index 0000000..5758827
--- /dev/null
+++ b/example-simple-server-to-server/server2/wg0.conf
@@ -0,0 +1,12 @@
+[Interface]
+# Name = server2.example-vpn.dev
+Address = 10.0.44.2/32
+ListenPort = 51820
+PrivateKey = eDwURfg8PhpUAdPp+OA9pQ5oZQYqGqY3LToUORMh220=
+DNS = 1.1.1.1
+
+[Peer]
+# Name = server1.example-vpn.tld
+Endpoint = server1.example-vpn.tld:51820
+PublicKey = q/+jwmL5tNuYSB3z+t9Caj00Pc1YQ8zf+uNPu/UE1wE=
+AllowedIPs = 10.0.44.1/24