ansible-role-common/templates/networking.j2

67 lines
2.2 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 {{ networking_main_iface }}
{% if bridged_network is defined and bridged_network %}
{% if bridged_network != "true" %}
{% for iface in bridged_network.split(" ") %}
auto {{ iface }}
{% endfor %}
{% endif %}
auto br0
iface br0
requires {{ networking_main_iface }}{% if bridged_network != "true" %} {{ bridged_network }}{% endif +%}
bridge-ports {{ networking_main_iface }}{% if bridged_network != "true" %} {{ bridged_network }}{% endif +%}
bridge-fd 0
bridge-stp off
{% if hw_address is defined %}
pre-up ip link set dev {{ networking_main_iface }} address {{ hw_address }}
{% endif %}
{% else %}
iface {{ networking_main_iface }}
{% endif %}
{% if bridged_network is not defined and hw_address is defined %}
hwaddress ether {{ hw_address }}
{% endif %}
{% if wanted_ip4 is defined %}
address {{ wanted_ip4 }}/24
gateway {{ local_network.gateway }}
{% else %}
use dhcp
{% endif %}
{% if wanted_ip6_suffix is defined %}
iface br0 inet6 auto
up ip token set {{ wanted_ip6_suffix }}/64 dev {% if bridged_network is defined and bridged_network %}br0{% else %}{{ networking_main_iface }}{% endif %}
{% endif %}
{% if wanted_ip6 is defined %}
{% if local_network.gateway6 is defined %}
address {{ wanted_ip6 }}/64
gateway {{ local_network.gateway6 }}
{% if bridged_network is defined and bridged_network %}
up echo 0 > /proc/sys/net/ipv6/conf/br0/accept_ra
{% else %}
pre-up echo 0 > /proc/sys/net/ipv6/conf/{{ networking_main_iface }}/accept_ra
{% endif %}
{% 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