Script for Router Login DNS record

Hi
I am fairly new to scripting and would like some help of direction.
I have a cell router and i have enabled IP Pass-through so my RB2011 is being issued the IP(sometimes Public sometimes Private) from the Provider this means i cant manage the cellular Router from the configured IP i have to use the Gateway assigned to manage this means i have to login to the Router to pick the Gateway and login.
I am thinking i can have a DNS record that i use and this is updated with the Gateway of the DHCP Client connected to my router by Mikrotik

  1. is this possible?
    2 if Yes a guide would be ok then i can work on it on my own so that i learn

Also need it to change when the DHCP Client gets a new IP

I am not a 100% sure i understand your needs…


This will always keep your DNS-Record up to date
with the actual Internet IPv4 address.

/ip cloud
set ddns-enabled=yes ddns-update-interval=20m

If you want your DNS-Record to contain the local
IP-Adresse use the following :

/ip cloud
set ddns-enabled=yes ddns-update-interval=20m
/ip cloud advanced
set use-local-address=yes

Sorry not DDNS plain dns record this is for LAN use.
I see script in DHCP client config but not sure how it works

the comand should be
/ip dns static add name=cellrouter.lan address= gateway from the dhcp client

Basic script can be for example:

/ip dns static remove [find where name=cellrouter.lan]
:if ($bound=1) do={
  /ip dns static add name=cellrouter.lan address=$"gateway-address"
}