I've configured Conditional Forwarding in Pi-Hole IP 192.168.0.8.
Mikrotik IP 192.168.0.1 and the local domain name ("lan").
i have found this script:
# When "1" all DNS entries with IP address of DHCP lease are removed
:local dnsRemoveAllByIp "1"
# When "1" all DNS entries with hostname of DHCP lease are removed
:local dnsRemoveAllByName "1"
# When "1" addition and removal of DNS entries is always done also for non-FQDN hostname
:local dnsAlwaysNonfqdn "1"
# DNS domain to add after DHCP client hostname
:local dnsDomain "lan"
# DNS TTL to set for DNS entries
:local dnsTtl "00:15:00"
# Source of DHCP client hostname, can be "lease-hostname" or any other lease attribute, like "host-name" or "comment"
:local leaseClientHostnameSource "comment"
:local leaseComment "dhcp-lease-script_$leaseServerName_$leaseClientHostnameSource"
:local leaseClientHostname
:if ($leaseClientHostnameSource = "lease-hostname") do={
:set leaseClientHostname $"lease-hostname"
} else={
:set leaseClientHostname ([:pick \
[/ip dhcp-server lease print as-value where server="$leaseServerName" address="$leaseActIP" mac-address="$leaseActMAC"] \
0]->"$leaseClientHostnameSource")
}
:local leaseClientHostnames "$leaseClientHostname"
:if ([:len [$dnsDomain]] > 0) do={
:if ($dnsAlwaysNonfqdn = "1") do={
:set leaseClientHostnames "$leaseClientHostname.$dnsDomain,$leaseClientHostname"
} else={
:set leaseClientHostnames "$leaseClientHostname.$dnsDomain"
}
}
:if ($dnsRemoveAllByIp = "1") do={
/ip dns static remove [/ip dns static find comment="$leaseComment" and address="$leaseActIP"]
}
:foreach h in=[:toarray value="$leaseClientHostnames"] do={
:if ($dnsRemoveAllByName = "1") do={
/ip dns static remove [/ip dns static find comment="$leaseComment" and name="$h"]
}
/ip dns static remove [/ip dns static find comment="$leaseComment" and address="$leaseActIP" and name="$h"]
:if ($leaseBound = "1") do={
:delay 1
/ip dns static add comment="$leaseComment" address="$leaseActIP" name="$h" ttl="$dnsTtl"
}
}
It's best to post just the debug token URL rather than the whole log, because only Pi-hole staff can access the debug URLs (and they are auto deleted after 48 hours), whereas anyone can view your full log.
Since you posted the full log I looked at it, and there are several entries like this, suggesting a database problem is preventing address to name resolution:
[2023-03-18 18:00:01.766 15095/T15113] getNameFromIP("192.168.0.17") - SQL error prepare: database is locked
[2023-03-18 18:00:02.773 15095/T15113] SQLite3 message: database is locked in "SELECT name FROM network_addresses WHERE name IS NOT NULL AND ip = ?;" (5)
[2023-03-18 18:00:03.751 15095/T15113] getNameFromIP("192.168.0.19") - SQL error prepare: database is locked
[2023-03-18 18:00:04.756 15095/T15113] SQLite3 message: database is locked in "SELECT name FROM network_addresses WHERE name IS NOT NULL AND ip = ?;" (5)
[...]
Have you had a power loss perhaps? try running the command
pihole restartdns
It may require some database surgery or starting with a fresh database instance; the Pi-hole folks will be able to read the log better and advise.
That script you are using is to be deployed on a Mikrotik router.
Some Mikrotik routers are not able to answer DNS requests for local names (as the post you've referred demonstrates).
You should consider checking the source for that script - you may be running a different or newer model, in which case the script may not be working.
Also, you should verify whether your Mikrotik model would exhibit the same flaw, e.g. by running a lookup and a reverse lookup for a known local name via your Mikrotik router: