aboutsummaryrefslogtreecommitdiff
path: root/roles/wireguard_client/templates/wg0.conf.j2
diff options
context:
space:
mode:
Diffstat (limited to 'roles/wireguard_client/templates/wg0.conf.j2')
-rw-r--r--roles/wireguard_client/templates/wg0.conf.j216
1 files changed, 16 insertions, 0 deletions
diff --git a/roles/wireguard_client/templates/wg0.conf.j2 b/roles/wireguard_client/templates/wg0.conf.j2
new file mode 100644
index 0000000..d667d8a
--- /dev/null
+++ b/roles/wireguard_client/templates/wg0.conf.j2
@@ -0,0 +1,16 @@
+# {{ ansible_managed }}
+
+[Interface]
+Address = {{ wireguard_client_peer_ip }}
+PostUp = wg set %i private-key /etc/wireguard/privatekey
+PostUp = ping -c1 192.168.10.1
+{% for port in wireguard_client_port_forwards %}
+PostUp = iptables -t nat -A PREROUTING -p tcp --dport {{ port }} -j DNAT --to-destination 192.168.10.1:{{ port }}
+{% endfor %}
+PostUp = iptables -t nat -A POSTROUTING -j MASQUERADE
+
+[Peer]
+PublicKey = {{ wireguard_client_server_pub_key }}
+AllowedIPs = {{ wireguard_client_server_allowed_ips }}
+Endpoint = {{ wireguard_client_server_endpoint }}:{{ wireguard_client_server_listen_port }}
+PersistentKeepalive = 20