ansible-role-common/templates/networking.j2

67 lines
2.2 KiB
Plaintext
Raw Permalink Normal View History

2023-02-15 00:55:08 +00:00
# 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
2023-11-14 09:02:44 +00:00
auto {{ networking_main_iface }}
2023-03-15 18:15:47 +00:00
{% if bridged_network is defined and bridged_network %}
2023-11-14 09:03:01 +00:00
{% if bridged_network != "true" %}
{% for iface in bridged_network.split(" ") %}
auto {{ iface }}
{% endfor %}
{% endif %}
2023-03-15 18:15:47 +00:00
auto br0
iface br0
2023-11-14 09:02:44 +00:00
requires {{ networking_main_iface }}{% if bridged_network != "true" %} {{ bridged_network }}{% endif +%}
bridge-ports {{ networking_main_iface }}{% if bridged_network != "true" %} {{ bridged_network }}{% endif +%}
2023-03-15 18:15:47 +00:00
bridge-fd 0
bridge-stp off
2023-11-14 09:03:01 +00:00
{% if hw_address is defined %}
pre-up ip link set dev {{ networking_main_iface }} address {{ hw_address }}
{% endif %}
2023-03-15 18:15:47 +00:00
{% else %}
2023-11-14 09:02:44 +00:00
iface {{ networking_main_iface }}
2023-03-15 18:15:47 +00:00
{% endif %}
2023-11-14 09:03:01 +00:00
{% if bridged_network is not defined and hw_address is defined %}
2023-03-25 15:46:28 +00:00
hwaddress ether {{ hw_address }}
{% endif %}
2023-02-15 00:55:08 +00:00
{% if wanted_ip4 is defined %}
address {{ wanted_ip4 }}/24
gateway {{ local_network.gateway }}
{% else %}
2023-03-15 18:15:47 +00:00
use dhcp
2023-02-15 00:55:08 +00:00
{% endif %}
2023-11-14 09:03:01 +00:00
{% if wanted_ip6_suffix is defined %}
2024-04-04 06:18:54 +00:00
iface br0 inet6 auto
2023-11-14 09:03:01 +00:00
up ip token set {{ wanted_ip6_suffix }}/64 dev {% if bridged_network is defined and bridged_network %}br0{% else %}{{ networking_main_iface }}{% endif %}
{% endif %}
2023-02-15 00:55:08 +00:00
{% if wanted_ip6 is defined %}
{% if local_network.gateway6 is defined %}
address {{ wanted_ip6 }}/64
gateway {{ local_network.gateway6 }}
2023-05-02 13:23:31 +00:00
{% if bridged_network is defined and bridged_network %}
up echo 0 > /proc/sys/net/ipv6/conf/br0/accept_ra
2023-05-02 13:23:31 +00:00
{% else %}
2023-11-14 09:02:44 +00:00
pre-up echo 0 > /proc/sys/net/ipv6/conf/{{ networking_main_iface }}/accept_ra
2023-05-02 13:23:31 +00:00
{% endif %}
2023-02-15 00:55:08 +00:00
{% 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