Skip to content

Commit

Permalink
coredns: use DNS provided by network manager if enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
xddxdd committed Jan 5, 2025
1 parent 64ed593 commit 363e60c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
11 changes: 11 additions & 0 deletions nixos/client-components/network-manager.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
pkgs,
LT,
lib,
config,
Expand Down Expand Up @@ -33,6 +34,16 @@ in
powersave = true;
};
settings.main.rc-manager = "resolvconf";

dispatcherScripts = [
{
type = "basic";
source = pkgs.writeShellScript "coredns" ''
echo "Reloading CoreDNS"
${pkgs.systemd}/bin/systemctl reload coredns.service
'';
}
];
};

systemd.services.NetworkManager-wait-online.enable = false;
Expand Down
18 changes: 16 additions & 2 deletions nixos/common-apps/coredns.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ in
cache
}
'';
forwardToResolvConf = zone: ''
${zone} {
any
bufsize 1232
loadbalance round_robin
prometheus ${config.lantian.netns.coredns-client.ipv4}:${LT.portStr.Prometheus.CoreDNS}
forward . /run/NetworkManager/no-stub-resolv.conf 8.8.8.8 {
prefer_udp
policy sequential
}
cache
}
'';
forwardTo114DNS = zone: ''
${zone} {
any
Expand Down Expand Up @@ -79,7 +93,7 @@ in

cfgEntries =
[
(forwardToGoogleDNS ".")
((if config.networking.networkmanager.enable then forwardToResolvConf else forwardToGoogleDNS) ".")
(forwardTo114DNS "kuxi.tech")
(forwardToAzurePrivateDNS "database.azure.com")
(block "upos-sz-mirroraliov.bilivideo.com")
Expand All @@ -90,7 +104,7 @@ in
with LT.constants.zones; (DN42 ++ NeoNetwork ++ OpenNIC ++ Emercoin ++ CRXN ++ Ltnet)
));
in
builtins.concatStringsSep "\n" (cfgEntries ++ [ "" ]);
lib.concatStrings cfgEntries;
};

systemd.services.coredns = netns.bind { };
Expand Down

0 comments on commit 363e60c

Please sign in to comment.