mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-22 14:45:27 +00:00
networkmanager: Expand dns description, integrate with other services (#41898)
Rather than special-casing the dns options in networkmanager.nix, use the module system to let unbound and systemd-resolved contribute to the newtorkmanager config.
This commit is contained in:
parent
25342cd6bd
commit
dca7e24a11
|
@ -9,18 +9,11 @@ let
|
||||||
# /var/lib/misc is for dnsmasq.leases.
|
# /var/lib/misc is for dnsmasq.leases.
|
||||||
stateDirs = "/var/lib/NetworkManager /var/lib/dhclient /var/lib/misc";
|
stateDirs = "/var/lib/NetworkManager /var/lib/dhclient /var/lib/misc";
|
||||||
|
|
||||||
dns =
|
|
||||||
if cfg.dns == "none" then "none"
|
|
||||||
else if cfg.dns == "dnsmasq" then "dnsmasq"
|
|
||||||
else if config.services.resolved.enable then "systemd-resolved"
|
|
||||||
else if config.services.unbound.enable then "unbound"
|
|
||||||
else "default";
|
|
||||||
|
|
||||||
configFile = writeText "NetworkManager.conf" ''
|
configFile = writeText "NetworkManager.conf" ''
|
||||||
[main]
|
[main]
|
||||||
plugins=keyfile
|
plugins=keyfile
|
||||||
dhcp=${cfg.dhcp}
|
dhcp=${cfg.dhcp}
|
||||||
dns=${dns}
|
dns=${cfg.dns}
|
||||||
|
|
||||||
[keyfile]
|
[keyfile]
|
||||||
${optionalString (cfg.unmanaged != [])
|
${optionalString (cfg.unmanaged != [])
|
||||||
|
@ -217,19 +210,73 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
dns = mkOption {
|
dns = mkOption {
|
||||||
type = types.enum [ "auto" "dnsmasq" "none" ];
|
type = types.enum [ "default" "dnsmasq" "unbound" "systemd-resolved" "none" ];
|
||||||
default = "auto";
|
default = "default";
|
||||||
description = ''
|
description = ''
|
||||||
|
Set the DNS (<literal>resolv.conf</literal>) processing mode.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
Options:
|
Options:
|
||||||
- auto: Check for systemd-resolved, unbound, or use default.
|
<variablelist>
|
||||||
- dnsmasq:
|
<varlistentry>
|
||||||
Enable NetworkManager's dnsmasq integration. NetworkManager will run
|
<term><literal>"default"</literal></term>
|
||||||
dnsmasq as a local caching nameserver, using a "split DNS"
|
<listitem><para>
|
||||||
configuration if you are connected to a VPN, and then update
|
NetworkManager will update <literal>/etc/resolv.conf</literal> to
|
||||||
resolv.conf to point to the local nameserver.
|
reflect the nameservers provided by currently active connections.
|
||||||
- none:
|
</para></listitem>
|
||||||
Disable NetworkManager's DNS integration completely.
|
</varlistentry>
|
||||||
It will not touch your /etc/resolv.conf.
|
<varlistentry>
|
||||||
|
<term><literal>"dnsmasq"</literal></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Enable NetworkManager's dnsmasq integration. NetworkManager will
|
||||||
|
run dnsmasq as a local caching nameserver, using a "split DNS"
|
||||||
|
configuration if you are connected to a VPN, and then update
|
||||||
|
<literal>resolv.conf</literal> to point to the local nameserver.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
It is possible to pass custom options to the dnsmasq instance by
|
||||||
|
adding them to files in the
|
||||||
|
<literal>/etc/NetworkManager/dnsmasq.d/</literal> directory.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
When multiple upstream servers are available, dnsmasq will
|
||||||
|
initially contact them in parallel and then use the fastest to
|
||||||
|
respond, probing again other servers after some time. This
|
||||||
|
behavior can be modified passing the
|
||||||
|
<literal>all-servers</literal> or <literal>strict-order</literal>
|
||||||
|
options to dnsmasq (see the manual page for more details).
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
Note that this option causes NetworkManager to launch and manage
|
||||||
|
its own instance of the dnsmasq daemon, which is
|
||||||
|
<emphasis>not</emphasis> the same as setting
|
||||||
|
<literal>services.dnsmasq.enable = true;</literal>.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><literal>"unbound"</literal></term>
|
||||||
|
<listitem><para>
|
||||||
|
NetworkManager will talk to unbound and dnssec-triggerd,
|
||||||
|
providing a "split DNS" configuration with DNSSEC support.
|
||||||
|
<literal>/etc/resolv.conf</literal> will be managed by
|
||||||
|
dnssec-trigger daemon.
|
||||||
|
</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><literal>"systemd-resolved"</literal></term>
|
||||||
|
<listitem><para>
|
||||||
|
NetworkManager will push the DNS configuration to systemd-resolved.
|
||||||
|
</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><literal>"none"</literal></term>
|
||||||
|
<listitem><para>
|
||||||
|
NetworkManager will not modify resolv.conf.
|
||||||
|
</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -131,6 +131,9 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# If networkmanager is enabled, ask it to interface with unbound.
|
||||||
|
networking.networkmanager.dns = "unbound";
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,6 +147,8 @@ in
|
||||||
${config.services.resolved.extraConfig}
|
${config.services.resolved.extraConfig}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
# If networkmanager is enabled, ask it to interface with resolved.
|
||||||
|
networking.networkmanager.dns = "systemd-resolved";
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue