ansible-role-common/templates/networking.j2

40 lines
1.1 KiB
Django/Jinja

# The loopback network interface
auto lo
iface lo inet loopback
{% if local_network.dns is defined %}
dns-nameservers {{ local_network.dns }}
{% endif %}
# The main interface
auto eth0
{% if wanted_ip4 is defined %}
iface eth0 inet static
address {{ wanted_ip4 }}/24
gateway {{ local_network.gateway }}
{% else %}
iface eth0 inet dhcp
{% endif %}
{% if wanted_ip6 is defined %}
iface eth0 inet6 static
{% if local_network.gateway6 is defined %}
address {{ wanted_ip6 }}/64
gateway {{ local_network.gateway6 }}
pre-up echo 0 > /proc/sys/net/ipv6/conf/eth0/accept_ra
{% else %}
address {{ wanted_ip6 }}/128
post-up ip addrlabel add prefix {{ wanted_ip6 }}/64 label 99
post-up ip addrlabel add prefix {{ wanted_ip6 }}/128 label 1
{% endif %}
{% endif %}
{% if wanted_serekh is defined %}
auto wg-serekh
iface wg-serekh inet6 static
address {{ wanted_serekh }}/64
pre-up ip link add dev wg-serekh type wireguard
pre-up wg setconf wg-serekh /etc/wireguard/wg-serekh.conf
post-down ip link delete dev wg-serekh
{% endif %}
source-directory /etc/network/interfaces.d