ansible-edda/playbooks/vpn/roles/wireguard/templates/wg0.j2

33 lines
1.1 KiB
Plaintext
Raw Normal View History

2022-12-09 01:16:00 +01:00
auto wg0
iface wg0 inet static
pre-up /usr/local/sbin/ip-link-add.sh $IFACE type wireguard
pre-up wg setconf $IFACE /etc/wireguard/$IFACE.conf
pre-up ip link set mtu 1420 dev $IFACE
post-up /usr/local/sbin/post-up-$IFACE-inet.nft
post-up /usr/local/sbin/post-up-$IFACE-ipv4.nft
{% if vpn_wireguard_role == "server" %}
{% for client in vpn_wireguard_clients %}
{% if 'subnet' in client %}
2022-12-09 01:16:00 +01:00
post-up ip route add {{ client.subnet }} dev $IFACE
{% endif %}
2022-12-09 01:16:00 +01:00
{% endfor %}
{% elif vpn_wireguard_role == "client" %}
post-up ip route add default dev $IFACE table {{ vpn_wireguard_routing_table }}
2022-12-09 01:16:00 +01:00
{% endif %}
{% if vpn_wireguard_role == "server" %}
{% for client in vpn_wireguard_clients %}
{% if 'subnet' in client %}
2022-12-09 01:16:00 +01:00
pre-down ip route del {{ client.subnet }} dev $IFACE
{% endif %}
2022-12-09 01:16:00 +01:00
{% endfor %}
{% elif vpn_wireguard_role == "client" %}
pre-down ip route del default dev $IFACE table {{ vpn_wireguard_routing_table }}
2022-12-09 01:16:00 +01:00
{% endif %}
pre-down /usr/local/sbin/pre-down-$IFACE-ipv4.nft
pre-down /usr/local/sbin/pre-down-$IFACE-inet.nft
address {{ vpn_wireguard_address }}
netmask {{ vpn_wireguard_netmask }}