From 454e58b08575f17e33d203dfc73c34fb87bbf5ec Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Wed, 17 Jul 2024 03:00:20 +0100 Subject: [PATCH] feat: generate the zones directly from teh dns records --- applications/dns/dns.nix | 27 ++++--- config/dns.nix | 161 ++++++++++++++++++++++----------------- 2 files changed, 107 insertions(+), 81 deletions(-) diff --git a/applications/dns/dns.nix b/applications/dns/dns.nix index a2725f3..044632c 100644 --- a/applications/dns/dns.nix +++ b/applications/dns/dns.nix @@ -14,7 +14,7 @@ # this gets a list of all domains we have records for domains = lib.lists.naturalSort ( lib.lists.unique ( - lib.lists.forEach records (record: record.domain) + lib.lists.forEach records (x: x.domain) ) ); @@ -76,8 +76,8 @@ get_config_file = ( domain: '' $TTL 60 ; 1 minute - ; hostmaster@${domain} is an email address that recieves stuff related to dns - @ IN SOA ${nameserver}.${domain}. hostmaster.${domain}. ( + ; hostmaster@skynet.ie is an email address that recieves stuff related to dns + @ IN SOA ${nameserver}.skynet.ie. hostmaster.skynet.ie. ( ; Serial (YYYYMMDDCC) this has to be updated for each time the record is updated ${current_date} 600 ; Refresh (10 minutes) @@ -87,8 +87,8 @@ ) ; @ stands for teh root domain so teh A record below is where ${domain} points to - @ NS ns1.${domain}. - @ NS ns2.${domain}. + @ NS ns1.skynet.ie. + @ NS ns2.skynet.ie. ; ------------------------------------------ ; Server Names (A Records) @@ -274,6 +274,7 @@ details_records ++ [ { + domain = "skynet.ie"; record = "ns1"; r_type = "A"; value = details_server.ip; @@ -284,6 +285,7 @@ details_records ++ [ { + domain = "skynet.ie"; record = "ns2"; r_type = "A"; value = details_server.ip; @@ -351,13 +353,14 @@ in { "ip daddr ${cfg.server.ip} udp dport 53 counter packets 0 bytes 0 accept" ]; - services.bind.zones = - (create_entry_zone "csn.ul.ie") - // (create_entry_zone "skynet.ie") - // (create_entry_zone "ulcompsoc.ie") - // (create_entry_zone "64-64.99.1.193.in-addr.arpa") - // (create_entry_zone "conradcollins.net") - // (create_entry_zone "edelharty.net"); + services.bind.zones = lib.attrsets.mergeAttrsList ( + # uses teh domains lsited in teh records + (lib.lists.forEach domains (domain: (create_entry_zone domain))) + # we have to do a reverse dns + ++ [ + (create_entry_zone "64-64.99.1.193.in-addr.arpa") + ] + ); environment.etc = (create_entry_etc "csn.ul.ie" "owned") diff --git a/config/dns.nix b/config/dns.nix index 931a176..08eeb4c 100644 --- a/config/dns.nix +++ b/config/dns.nix @@ -10,74 +10,97 @@ }; config = { - skynet.records = [ - { - record = "optimus"; - r_type = "A"; - value = "193.1.99.90"; - server = true; - } - { - record = "panel.games"; - r_type = "CNAME"; - value = "optimus"; - } - { - record = "bumblebee"; - r_type = "A"; - value = "193.1.99.91"; - server = true; - } - { - record = "minecraft.compsoc.games"; - r_type = "CNAME"; - value = "bumblebee"; - } - { - record = "_minecraft._tcp.minecraft.compsoc.games.skynet.ie."; - r_type = "SRV"; - value = "0 10 25518 minecraft.compsoc.games.skynet.ie."; - } - { - record = "minecraft-classic.compsoc.games"; - r_type = "CNAME"; - value = "bumblebee"; - } - { - record = "_minecraft._tcp.minecraft-classic.compsoc.games.skynet.ie."; - r_type = "SRV"; - value = "0 10 25518 minecraft-classic.compsoc.games.skynet.ie."; - } - { - record = "minecraft.gsoc.games"; - r_type = "CNAME"; - value = "bumblebee"; - } - { - record = "_minecraft._tcp.minecraft.gsoc.games.skynet.ie."; - r_type = "SRV"; - value = "0 10 25521 minecraft.gsoc.games.skynet.ie."; - } - { - record = "minecraft.phildeb.games"; - r_type = "CNAME"; - value = "bumblebee"; - } - { - record = "_minecraft._tcp.minecraft.phildeb.games.skynet.ie."; - r_type = "SRV"; - value = "0 10 25522 minecraft.phildeb.games.skynet.ie."; - } - { - record = "minecraft-aged.compsoc.games"; - r_type = "CNAME"; - value = "bumblebee"; - } - { - record = "_minecraft._tcp.minecraft-aged.compsoc.games.skynet.ie."; - r_type = "SRV"; - value = "0 10 25519 minecraft.phildeb.games.skynet.ie."; - } - ]; + skynet.records = + [ + { + record = "optimus"; + r_type = "A"; + value = "193.1.99.90"; + server = true; + } + { + record = "panel.games"; + r_type = "CNAME"; + value = "optimus"; + } + { + record = "bumblebee"; + r_type = "A"; + value = "193.1.99.91"; + server = true; + } + { + record = "minecraft.compsoc.games"; + r_type = "CNAME"; + value = "bumblebee"; + } + { + record = "_minecraft._tcp.minecraft.compsoc.games.skynet.ie."; + r_type = "SRV"; + value = "0 10 25518 minecraft.compsoc.games.skynet.ie."; + } + { + record = "minecraft-classic.compsoc.games"; + r_type = "CNAME"; + value = "bumblebee"; + } + { + record = "_minecraft._tcp.minecraft-classic.compsoc.games.skynet.ie."; + r_type = "SRV"; + value = "0 10 25518 minecraft-classic.compsoc.games.skynet.ie."; + } + { + record = "minecraft.gsoc.games"; + r_type = "CNAME"; + value = "bumblebee"; + } + { + record = "_minecraft._tcp.minecraft.gsoc.games.skynet.ie."; + r_type = "SRV"; + value = "0 10 25521 minecraft.gsoc.games.skynet.ie."; + } + { + record = "minecraft.phildeb.games"; + r_type = "CNAME"; + value = "bumblebee"; + } + { + record = "_minecraft._tcp.minecraft.phildeb.games.skynet.ie."; + r_type = "SRV"; + value = "0 10 25522 minecraft.phildeb.games.skynet.ie."; + } + { + record = "minecraft-aged.compsoc.games"; + r_type = "CNAME"; + value = "bumblebee"; + } + { + record = "_minecraft._tcp.minecraft-aged.compsoc.games.skynet.ie."; + r_type = "SRV"; + value = "0 10 25519 minecraft.phildeb.games.skynet.ie."; + } + ] + # non skynet domains + ++ [ + { + domain = "conradcollins.net"; + record = "www"; + r_type = "CNAME"; + value = "skynet.skynet.ie."; + } + + { + domain = "edelharty.net"; + record = "www"; + r_type = "CNAME"; + value = "skynet.skynet.ie."; + } + { + domain = "damienconroy.com"; + record = "www"; + r_type = "CNAME"; + value = "skynet.skynet.ie."; + } + ]; }; }