summaryrefslogtreecommitdiffstats
path: root/roles/network/templates
diff options
context:
space:
mode:
authorAhmed Abdelhalim <[email protected]>2025-09-01 22:24:41 +0200
committerAhmed Abdelhalim <[email protected]>2025-09-01 23:44:24 +0200
commit17f10052bdbc4cf5bfd0e2fa335f13c0165284a5 (patch)
treed3ca8c539c7f0d0e9a4a115de4e6be1bf24f3f5d /roles/network/templates
parent38b83b874e91027449e2ffcc2f8ee9e50d4c6554 (diff)
Fix networking issues when VPN isn't active
Diffstat (limited to 'roles/network/templates')
-rw-r--r--roles/network/templates/eth0-connection.nmconnection.j24
-rw-r--r--roles/network/templates/resolved.conf.j210
-rw-r--r--roles/network/templates/wifi-connection.nmconnection.j24
3 files changed, 15 insertions, 3 deletions
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 %}