From 3be508bac52338a5fb95c8582b0b4470bd7a494f Mon Sep 17 00:00:00 2001 From: Ahmed Abdelhalim Date: Mon, 13 Jul 2026 17:40:35 +0200 Subject: Configure ipv6/prefer ipv4 switches for network (and all hosts) --- group_vars/all.yml | Bin 26 -> 80 bytes group_vars/all.yml.example | 2 ++ host_vars/rpi5.local.yml | Bin 3629 -> 3602 bytes roles/network/defaults/main.yml | 1 + roles/network/meta/argument_specs.yml | 10 ++++++++++ .../network/templates/eth0-connection.nmconnection.j2 | 8 ++++---- .../network/templates/wifi-connection.nmconnection.j2 | 6 +++++- 7 files changed, 22 insertions(+), 5 deletions(-) diff --git a/group_vars/all.yml b/group_vars/all.yml index 20f84e62..65817773 100644 Binary files a/group_vars/all.yml and b/group_vars/all.yml differ diff --git a/group_vars/all.yml.example b/group_vars/all.yml.example index ed97d539..9d69dea6 100644 --- a/group_vars/all.yml.example +++ b/group_vars/all.yml.example @@ -1 +1,3 @@ --- +network_ipv6_disabled: true +network_prefer_ipv4: true diff --git a/host_vars/rpi5.local.yml b/host_vars/rpi5.local.yml index 83025ca6..27388c7d 100644 Binary files a/host_vars/rpi5.local.yml and b/host_vars/rpi5.local.yml differ diff --git a/roles/network/defaults/main.yml b/roles/network/defaults/main.yml index 9497f83f..20776341 100644 --- a/roles/network/defaults/main.yml +++ b/roles/network/defaults/main.yml @@ -2,3 +2,4 @@ network_wifi_ssid: "" network_wifi_pass: "" network_prefer_ipv4: false +network_ipv6_disabled: false diff --git a/roles/network/meta/argument_specs.yml b/roles/network/meta/argument_specs.yml index 74060d0d..b6c521fe 100644 --- a/roles/network/meta/argument_specs.yml +++ b/roles/network/meta/argument_specs.yml @@ -25,6 +25,16 @@ argument_specs: type: "str" description: "Static IPv6 default route via router link-local — set when router RA is disabled" required: false + network_prefer_ipv4: + type: "bool" + description: "Prefer IPv4 over IPv6 for address resolution" + required: false + default: false + network_ipv6_disabled: + type: "bool" + description: "Disable IPv6 on all network connections" + required: false + default: false network_bridge_interface: type: "str" description: "Physical NIC to enslave as vmbr0 bridge port" diff --git a/roles/network/templates/eth0-connection.nmconnection.j2 b/roles/network/templates/eth0-connection.nmconnection.j2 index d6d2ea86..032b18a3 100644 --- a/roles/network/templates/eth0-connection.nmconnection.j2 +++ b/roles/network/templates/eth0-connection.nmconnection.j2 @@ -28,13 +28,13 @@ method=auto [ipv6] addr-gen-mode=default -{% if network_bridge_interface is defined %} +{% if network_bridge_interface is defined or network_ipv6_disabled %} method=disabled -{% else %} +{% elif network_ipv6_gateway is defined %} method=auto -{% if network_ipv6_gateway is defined %} routes=::/0,{{ network_ipv6_gateway }},100 -{% endif %} +{% else %} +method=auto {% endif %} [proxy] diff --git a/roles/network/templates/wifi-connection.nmconnection.j2 b/roles/network/templates/wifi-connection.nmconnection.j2 index 5b4ab185..01dff2eb 100644 --- a/roles/network/templates/wifi-connection.nmconnection.j2 +++ b/roles/network/templates/wifi-connection.nmconnection.j2 @@ -27,9 +27,13 @@ method=auto [ipv6] addr-gen-mode=default +{% if network_ipv6_disabled %} +method=disabled +{% elif network_ipv6_gateway is defined %} method=auto -{% if network_ipv6_gateway is defined %} routes=::/0,{{ network_ipv6_gateway }},100 +{% else %} +method=auto {% endif %} [proxy] -- cgit v1.2.3