Community discussions

MikroTik App
 
Kataius
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 59
Joined: Sun Feb 05, 2023 4:38 pm
Location: Italy

executing script from dhcp failed, nothing change, only upgrade to 7.16

Tue Sep 24, 2024 3:24 pm

Good morning everyone,

since the update to 7.16, the log gives me this error:
executing script from dhcp failed, please check it manually
the script does what it's supposed to do, who can tell me what was changed? Before 7.16 I had no error warnings.

# 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 leaseClientHostnameShort "$leaseClientHostname"
:local leaseClientHostnames "$leaseClientHostname"
:if ([:len [$dnsDomain]] > 0) do={
  :set leaseClientHostname "$leaseClientHostname.$dnsDomain"
  :if ($dnsAlwaysNonfqdn = "1") do={
    :set leaseClientHostnames "$leaseClientHostname,$leaseClientHostnameShort"
  }
}
: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"
  }
}

Thank you
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12632
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: executing script from dhcp failed, nothing change, only upgrade to 7.16

Tue Sep 24, 2024 3:36 pm

[Translation Concentrate: That's not true, the script never worked properly even in previous versions.]

Non è vero, lo script non ha mai funzionato correttamente neanche nelle versioni precedenti. Per esempio la 7.15
viewtopic.php?p=1097575#p1097575

Ovvio che usare uno script per la v6, che all'apparenza nel 2019 funzionava, nella v7 non è garantito il funzionamento.
Contatta l'autore originale:
https://blog.pessoft.com/2019/09/06/mik ... cp-leases/
se ti risponde.

Non mi ci metto neanche a controllarlo, è scritto con i piedi.
 
Kataius
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 59
Joined: Sun Feb 05, 2023 4:38 pm
Location: Italy

Re: executing script from dhcp failed, nothing change, only upgrade to 7.16

Wed Sep 25, 2024 3:46 am

Thanks for the reply, I only noticed it now, that it didn't work even in other versions, because I'm affected by a BUG on IoT devices and every firmware update I test to see if the BUG is finally resolved.
I will try to contact the author of the script, as you suggest.

You seemed to have disappeared from the forum, I'm glad you're back!
Thanks again!