ansible-roles/vpn/wireguard/templates/server/IFACE

49 lines
1.9 KiB
Plaintext
Raw Normal View History

2023-07-20 20:27:37 +02:00
auto {{ vpn_wireguard_iface }}
2023-07-28 22:30:55 +02:00
iface {{ vpn_wireguard_iface }} inet6 static
2022-12-20 19:47:11 +01:00
pre-up /usr/local/sbin/ip-link-add.sh $IFACE type wireguard
pre-up wg setconf $IFACE /etc/wireguard/$IFACE.conf
2023-07-20 20:50:42 +02:00
pre-up ip link set mtu {{ vpn_wireguard_mtu }} dev $IFACE
2022-12-20 19:47:11 +01:00
post-up /usr/local/sbin/post-up-$IFACE-inet.nft
2023-07-22 12:28:49 +02:00
{% if vpn_wireguard_routing_table is defined %}
post-up ip -6 rule add sport {{ vpn_wireguard_port }} ipproto udp table {{ vpn_wireguard_routing_table }}
{% endif %}
2022-12-20 19:47:11 +01:00
{% for client in vpn_wireguard_clients %}
2023-07-28 22:30:55 +02:00
{% if 'inet6_subnet' in client %}
post-up ip route add {{ client.inet6_subnet }} dev $IFACE
2022-12-20 19:47:11 +01:00
{% endif %}
{% endfor %}
{% for client in vpn_wireguard_clients %}
2023-07-28 22:30:55 +02:00
{% if 'inet6_subnet' in client %}
pre-down ip route del {{ client.inet6_subnet }} dev $IFACE
2022-12-20 19:47:11 +01:00
{% endif %}
{% endfor %}
2023-07-22 12:28:49 +02:00
{% if vpn_wireguard_routing_table is defined %}
pre-down ip -6 rule del sport {{ vpn_wireguard_port }} ipproto udp table {{ vpn_wireguard_routing_table }}
2022-12-20 19:47:11 +01:00
{% endif %}
pre-down /usr/local/sbin/pre-down-$IFACE-inet.nft
2023-07-28 22:30:55 +02:00
address {{ vpn_wireguard_inet6_address }}/{{ vpn_wireguard_inet6_prefixlen }}
iface {{ vpn_wireguard_iface }} inet static
{% if vpn_wireguard_routing_table is defined %}
post-up ip rule add sport {{ vpn_wireguard_port }} ipproto udp table {{ vpn_wireguard_routing_table }}
{% endif %}
{% for client in vpn_wireguard_clients %}
{% if 'inet_subnet' in client %}
post-up ip route add {{ client.inet_subnet }} dev $IFACE
{% endif %}
{% endfor %}
{% for client in vpn_wireguard_clients %}
{% if 'inet_subnet' in client %}
pre-down ip route del {{ client.inet_subnet }} dev $IFACE
2023-07-22 12:28:49 +02:00
{% endif %}
2023-07-28 22:30:55 +02:00
{% endfor %}
{% if vpn_wireguard_routing_table is defined %}
pre-down ip rule del sport {{ vpn_wireguard_port }} ipproto udp table {{ vpn_wireguard_routing_table }}
{% endif %}
address {{ vpn_wireguard_inet_address }}/{{ vpn_wireguard_inet_prefixlen }}