Wireguard: More Peer Config

This commit is contained in:
Tobias Manske 2023-03-05 04:26:29 +01:00
parent e5867a12f4
commit 98a3f8178c
Signed by: tobias
GPG Key ID: E83C743C1FC2F79A
2 changed files with 10 additions and 6 deletions

View File

@ -25,12 +25,9 @@ services:
restart: unless-stopped
networks:
- default
- gateway
- internal_services
networks:
gateway:
external: true
internal_services:
name: internal_services
internal: true

View File

@ -1,11 +1,12 @@
[Interface]
Address = 10.2.0.1/16
Address = fd10:4000::1/32
{% for addr in wireguard.cidr %}
Address = {{ addr }}
{% endfor %}
MTU = 1420
SaveConfig = true
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
ListenPort = 51820
ListenPort = {{ wireguard.port }}
PrivateKey = {{ wireguard.private_key }}
{% for peer in wireguard_peers %}
@ -13,5 +14,11 @@ PrivateKey = {{ wireguard.private_key }}
[Peer]
PublicKey = {{ peer.pubkey }}
AllowedIPs = {{ peer.allowedips | join(", ") }}
{% if peer.endpoint is defined %}
Endpoint = {{ peer.endpoint }}
{% endif %}
{% if peer.keepalive is defined %}
PersistentKeepalive = {{ peer.keepalive }}
{% endif %}
{% endfor %}