aboutsummaryrefslogtreecommitdiffstats
path: root/modules/by-name/un/unbound
diff options
context:
space:
mode:
Diffstat (limited to 'modules/by-name/un/unbound')
-rw-r--r--modules/by-name/un/unbound/module.nix64
1 files changed, 64 insertions, 0 deletions
diff --git a/modules/by-name/un/unbound/module.nix b/modules/by-name/un/unbound/module.nix
new file mode 100644
index 0000000..5fb3cbe
--- /dev/null
+++ b/modules/by-name/un/unbound/module.nix
@@ -0,0 +1,64 @@
+# nixos-config - My current NixOS configuration
+#
+# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# This file is part of my nixos-config.
+#
+# You should have received a copy of the License along with this program.
+# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
+{
+ lib,
+ config,
+ pkgs,
+ ...
+}: let
+ cfg = config.vhack.unbound;
+in {
+ options.vhack.unbound = {
+ enable = lib.mkEnableOption "local unbound, a resolving dns server";
+ };
+
+ config = lib.mkIf cfg.enable {
+ vhack.persist.directories = [
+ {
+ directory = "/var/lib/unbound";
+ user = "unbound";
+ group = "unbound";
+ mode = "0700";
+ }
+ ];
+
+ services.unbound = {
+ enable = true;
+ stateDir = "/var/lib/unbound";
+ resolveLocalQueries = true;
+ settings = {
+ server = {
+ hide-identity = true;
+ hide-version = true;
+ harden-glue = true;
+ harden-dnssec-stripped = true;
+ # 0x20-encoded randomization
+ use-caps-for-id = true;
+
+ # DNSSEC - enabled by default with auto-trust-anchor-file
+ # auto-trust-anchor-file = "/var/lib/unbound/root.key";
+ };
+ };
+ };
+ users = {
+ users = {
+ unbound = {
+ uid = config.vhack.constants.ids.uids.unbound;
+ group = "unbound";
+ };
+ };
+ groups = {
+ unbound = {
+ gid = config.vhack.constants.ids.gids.unbound;
+ };
+ };
+ };
+ };
+}