Quantcast
Channel: MikroTik
Viewing all articles
Browse latest Browse all 15133

Scripting • Re: Need help modifying a DHCP2DNS script

$
0
0
No replies yet, so I'm trying to figure this out myself.

I've added a local variable dnsComment. Once the script has the dnsDhcpid, I try to use that to derive the comment set in the DNS entry. If there is no comment (len <= 0), I allow the script to remove the entry. if there IS a comment, I do NOT allow the script to delete the entry.

I'm going this route as I've never seen the script actually set the comment field. So I figured if I need to set a DNS entry manually, I could just add a comment like "Do not remove this!" and the script will then leave it alone..

Comments? I don't know how to debug something like this, if I try it.

This is the new bottom of the script, where DNS entries are removed:

Code:
{  /ip dns static  :local dnsDhcpId  :local dnsComment  :set dnsDhcpId [ find address=$leaseActIP ]  :set dnsComment [ get $dnsDhcpID comment ]  :if ( [ :len $dnsDhcpId ] > 0 and [ :len $dnsComment ] <= 0) do=\  {    :log info "DHCP2DNS: removing static domain name(s) for address $leaseActIP"    remove $dnsDhcpId  }  /}

Statistics: Posted by cgallery — Fri Jan 19, 2024 5:34 pm



Viewing all articles
Browse latest Browse all 15133

Trending Articles