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 restart: unless-stopped
networks: networks:
- default - default
- gateway
- internal_services - internal_services
networks: networks:
gateway:
external: true
internal_services: internal_services:
name: internal_services name: internal_services
internal: true internal: true

View File

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