Implemented proper zone sync
https://blog.technitium.com/2024/10/how-to-configure-catalog-zones-for.html
This commit is contained in:
parent
5535fecea3
commit
6e0f5bb249
2 changed files with 1 additions and 48 deletions
|
|
@ -1,30 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
set -x
|
|
||||||
src_dns_server=192.168.1.2
|
|
||||||
# DHCP scopes to manage - put the name of each scope you have
|
|
||||||
dhcp_scopes=("local-home") # Use this array for one or many scopes
|
|
||||||
|
|
||||||
echo "Checking primary Technitium server status"
|
|
||||||
status_code=$(curl --write-out '%{http_code}' --silent --output /dev/null http://$src_dns_server:5380)
|
|
||||||
|
|
||||||
if [[ "$status_code" -ne 200 ]]; then
|
|
||||||
echo "Primary DNS/DHCP server is not available. Enabling DHCP on the secondary server."
|
|
||||||
action="enable"
|
|
||||||
else
|
|
||||||
echo "Primary DNS/DHCP server is available. Disabling DHCP on the secondary server."
|
|
||||||
action="disable"
|
|
||||||
fi
|
|
||||||
|
|
||||||
for scope in "${dhcp_scopes[@]}"; do
|
|
||||||
echo "Executing API call to $action DHCP scope: $scope"
|
|
||||||
response=$(curl -X POST "http://localhost:5380/api/dhcp/scopes/$action?token=$DNS1_API&name=$scope" \
|
|
||||||
--silent --write-out "%{http_code}")
|
|
||||||
|
|
||||||
echo "HTTP response code: $response"
|
|
||||||
if [[ "$response" == "200" ]]; then
|
|
||||||
echo "Successfully $action DHCP for scope: $scope"
|
|
||||||
else
|
|
||||||
echo "Failed to $action DHCP for scope: $scope. Check the response body for details."
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
@ -6,10 +6,7 @@
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
|
|
||||||
age.secrets = {
|
age.secrets.dns02-admin-password.file = ../../secrets/dns02-admin-password.age;
|
||||||
dns02-admin-password.file = ../../secrets/dns02-admin-password.age;
|
|
||||||
dns02-dhcp-failover.file = ../../secrets/dns02-dhcp-failover.age;
|
|
||||||
};
|
|
||||||
|
|
||||||
my = {
|
my = {
|
||||||
|
|
||||||
|
|
@ -28,19 +25,5 @@
|
||||||
virtualisation.proxmox.enable = true;
|
virtualisation.proxmox.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
# systemd.services.dhcp-failover = {
|
|
||||||
# description = "Set the current server as the primary DHCP server if the other one is down";
|
|
||||||
# wantedBy = [ "multi-user.target" ];
|
|
||||||
# path = [ pkgs.curl ];
|
|
||||||
# serviceConfig = {
|
|
||||||
# EnvironmentFile = config.age.secrets.dns02-dhcp-failover.path;
|
|
||||||
# ExecStart = "${pkgs.writeShellScript "dhcp-failover.sh" (builtins.readFile ./dhcp-failover.sh)}";
|
|
||||||
# Restart = "on-failure";
|
|
||||||
# DynamicUser = true;
|
|
||||||
# StandardOutput = "journal";
|
|
||||||
# StandardError = "journal";
|
|
||||||
# };
|
|
||||||
# };
|
|
||||||
|
|
||||||
system.stateVersion = "24.11";
|
system.stateVersion = "24.11";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue