aboutsummaryrefslogtreecommitdiff
path: root/roles/wireguard/templates
diff options
context:
space:
mode:
authorKumar <kumar@kumardamani.xyz>2021-11-23 14:59:08 +0000
committerKumar Damani <me@kumardamani.net>2022-03-25 19:45:25 +0000
commita857eb82ec9c4a79ad5e41462e2ab82c2660982e (patch)
tree9ca51ddfb551322bd4d2fa3f949fa8898032632d /roles/wireguard/templates
initial commit
Diffstat (limited to 'roles/wireguard/templates')
-rw-r--r--roles/wireguard/templates/wg0.conf.j217
1 files changed, 17 insertions, 0 deletions
diff --git a/roles/wireguard/templates/wg0.conf.j2 b/roles/wireguard/templates/wg0.conf.j2
new file mode 100644
index 0000000..6e7bcc1
--- /dev/null
+++ b/roles/wireguard/templates/wg0.conf.j2
@@ -0,0 +1,17 @@
+# {{ ansible_managed }}
+
+[Interface]
+Address = {{ wireguard_server_ip }}
+ListenPort = {{ wireguard_server_listen_port }}
+PrivateKey = {{ wireguard_server_priv_key }}
+PostUp = iptables -A FORWARD -i wg0 -o wg0 -j ACCEPT
+PostUp = iptables -w -t nat -A POSTROUTING -o eth0 -j MASQUERADE; ip6tables -w -t nat -A POSTROUTING -o eth0 -j MASQUERADE
+PostDown = iptables -w -t nat -D POSTROUTING -o eth0 -j MASQUERADE; ip6tables -w -t nat -D POSTROUTING -o eth0 -j MASQUERADE
+
+
+{% for peer in wireguard_peers %}
+[Peer]
+PublicKey = {{ peer.peer_key }}
+AllowedIPs = {{ peer.peer_ip}}
+
+{% endfor %}