sync-containers3: fix dns issues

This commit is contained in:
lassulus 2024-01-09 00:59:13 +01:00
parent 3ab426ea5b
commit cc61ce4080

View File

@ -58,6 +58,8 @@ in {
pkgs.jq pkgs.jq
]; ];
networking.useDHCP = lib.mkForce true; networking.useDHCP = lib.mkForce true;
networking.useHostResolvConf = false;
services.resolved.enable = true;
systemd.services.autoswitch = { systemd.services.autoswitch = {
environment = { environment = {
NIX_REMOTE = "daemon"; NIX_REMOTE = "daemon";
@ -297,9 +299,6 @@ in {
(lib.mkIf (cfg.containers != {}) { (lib.mkIf (cfg.containers != {}) {
# networking # networking
# needed because otherwise we lose local dns
environment.etc."resolv.conf".source = lib.mkForce "/run/systemd/resolve/resolv.conf";
boot.kernel.sysctl."net.ipv4.ip_forward" = lib.mkForce 1; boot.kernel.sysctl."net.ipv4.ip_forward" = lib.mkForce 1;
systemd.network.networks.ctr0 = { systemd.network.networks.ctr0 = {
name = "ctr0"; name = "ctr0";
@ -312,6 +311,9 @@ in {
ConfigureWithoutCarrier = true; ConfigureWithoutCarrier = true;
DHCPServer = "yes"; DHCPServer = "yes";
}; };
dhcpServerConfig = {
DNS = "9.9.9.9";
};
}; };
systemd.network.netdevs.ctr0.netdevConfig = { systemd.network.netdevs.ctr0.netdevConfig = {
Kind = "bridge"; Kind = "bridge";
@ -344,6 +346,12 @@ in {
networking.useHostResolvConf = false; networking.useHostResolvConf = false;
networking.useNetworkd = true; networking.useNetworkd = true;
services.resolved = {
enable = true;
extraConfig = ''
Domains=~.
'';
};
systemd.network = { systemd.network = {
enable = true; enable = true;
networks.eth0 = { networks.eth0 = {