From 17f10052bdbc4cf5bfd0e2fa335f13c0165284a5 Mon Sep 17 00:00:00 2001 From: Ahmed Abdelhalim Date: Mon, 1 Sep 2025 22:24:41 +0200 Subject: Fix networking issues when VPN isn't active --- roles/network/templates/eth0-connection.nmconnection.j2 | 4 +++- roles/network/templates/resolved.conf.j2 | 10 +++++++++- roles/network/templates/wifi-connection.nmconnection.j2 | 4 +++- 3 files changed, 15 insertions(+), 3 deletions(-) (limited to 'roles/network/templates') diff --git a/roles/network/templates/eth0-connection.nmconnection.j2 b/roles/network/templates/eth0-connection.nmconnection.j2 index b981489a..dab5a6de 100644 --- a/roles/network/templates/eth0-connection.nmconnection.j2 +++ b/roles/network/templates/eth0-connection.nmconnection.j2 @@ -9,7 +9,8 @@ autoconnect=true {% if network_ipv4_address is defined %} method=manual addresses={{ network_ipv4_address }} -gateway={{ network_ipv4_gateway }} +gateway={{ network_ipv4_gateway }} +dns={{ network_ipv4_dns }} {% else %} method=auto {% endif %} @@ -20,6 +21,7 @@ addr-gen-mode=default method=manual addresses={{ network_ipv6_address }} gateway={{ network_ipv6_gateway }} +dns={{ network_ipv6_dns }} {% else %} method=auto {% endif %} diff --git a/roles/network/templates/resolved.conf.j2 b/roles/network/templates/resolved.conf.j2 index cccffff1..5d70fb96 100644 --- a/roles/network/templates/resolved.conf.j2 +++ b/roles/network/templates/resolved.conf.j2 @@ -1,10 +1,18 @@ [Resolve] +{% if not (network_ipv4_dns is defined or network_ipv6_dns is defined) %} +# Only set global DNS (and DoT) if not using Pi-hole # cloudflare-dns.com DNS=1.1.1.1 2606:4700:4700::1111 # dns.google FallbackDNS=8.8.8.8 2001:4860:4860::8888 -DNSSEC=yes DNSOverTLS=yes +DNSSEC=yes +{% else %} +# NetworkManager will provide DNS via Pi-hole, no global DNS needed +# Pi-hole doesn't support DoT/DNSSEC +DNSOverTLS=no +DNSSEC=no +{% endif %} # use interface-specific DNS when available but fall back to global (required for VPN DNS to work) Domains=~. diff --git a/roles/network/templates/wifi-connection.nmconnection.j2 b/roles/network/templates/wifi-connection.nmconnection.j2 index 52cf2d19..c04077c0 100644 --- a/roles/network/templates/wifi-connection.nmconnection.j2 +++ b/roles/network/templates/wifi-connection.nmconnection.j2 @@ -17,7 +17,8 @@ psk={{ network_wifi_pass }} {% if network_ipv4_address is defined %} method=manual addresses={{ network_ipv4_address }} -gateway={{ network_ipv4_gateway }} +gateway={{ network_ipv4_gateway }} +dns={{ network_ipv4_dns }} {% else %} method=auto {% endif %} @@ -28,6 +29,7 @@ addr-gen-mode=default method=manual addresses={{ network_ipv6_address }} gateway={{ network_ipv6_gateway }} +dns={{ network_ipv6_dns }} {% else %} method=auto {% endif %} -- cgit v1.2.3