feat: add metric support and fix net-persist issues with multiple NICs

This commit is contained in:
Clément Désiles
2025-08-26 00:31:24 +02:00
parent b5886e1a7b
commit 117978fe52
9 changed files with 141 additions and 67 deletions
@@ -1,9 +0,0 @@
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The primary network interface
allow-hotplug {{ interface.name }}
iface {{ interface.name }} inet dhcp
# This is an autoconfigured IPv6 interface
iface {{ interface.name }} inet6 auto
+17 -2
View File
@@ -1,9 +1,24 @@
# {{ ansible_managed }}
# systemd.network(5)
[Match]
Name={{ interface.name }}
[Network]
[Address]
Address={{ interface.ipv4.address }}
Gateway={{ interface.ipv4.gateway }}
{% if interface.ipv4.metric is defined %}
RouteMetric={{ interface.ipv4.metric }}
{% endif %}
[Network]
{% for dns in interface.ipv4.nameservers %}
DNS={{ dns }}
{% endfor %}
{% if interface.ipv4.gateway is defined %}
[Route]
Gateway={{ interface.ipv4.gateway }}
{% if interface.ipv4.metric is defined %}
Metric={{ interface.ipv4.metric }}
{% endif %}
{% endif %}