IP-Update with MikroTik Router

Hello Forum!
I would like to have the IPs updated automatically with my MikroTik router.
Does anyone here already have a script to make this happen?
According to the API I have to call the following page:

But here I have to replace the IPv4 and IPv6 with the current address of the interface.
I have a PPPoE connection, through which I get an IPv4 and a prefix (/56) of which I get an IPv6 address.
Currently I still have no plan how to determine the IPs directly on the router for the query :frowning:

In the end, I need to be able to call it something like this:
/tool fetch url="https://update.dedyn.io/update?username=MYDOMAIN.dedyn.io&password=PASSWORD&myipv4=$MyIpV4&myipv6=$MyIpV6" mode=https

Hi Hoerli!

I do not have any experience with MicroTik devices in particular.

However if they use a *NIX OS then you could probably extract current public IPs from ifconfig output or from a similar command.

You could also use wget, curl, etc. to access https://checkipv4.dedyn.io/ and https://checkipv6.dedyn.io/ which would echo back the IPv4/IPv6 address the request came from.

Either way, for IPv6 the result may not be very useful unless you want to access the router itself. As you stated your provider allocates a /56 subnet to your router. Presumably your LAN clients will use SLAAC to allocate their public IPv6 addresses from this subnet. In a normal setup each client has their own public IPv6 address(es). (NATv6 is very uncommon and unnecessary in most cases.)

Thus the IPv6 address of your router will not help when trying to access a service on a client behind the router. There are more issues when trying to run a public service on a dynamic IPv6 address. Suffice to say: it can be done, but…

BTW: Many providers will actually issue a /64 prefix to the router in addition to a /56 prefix for clients behind the router. Your case may be different though.


Yes that with SLAAC is known.
In fact, I want to first transmit the IPv6 of the router so that I can establish a VPN tunnel via domain.
For internal services I then use ULA addresses and an internal DNS server.

I managed to craft an ugly script.
Unfortunately it just puts data on memory, which will be deleted at the end, I would have preferred something completely in RAM.
But at least it works … :slight_smile:

:log info GO
/tool fetch url="https://checkipv4.dedyn.io/" mode=https src-path="/" dst-path="/deSEC-IPv4.txt"
:delay 1
:local PubIpv4 [/file get deSEC-IPv4.txt contents]

/tool fetch url="https://checkipv6.dedyn.io/" mode=https src-path="/" dst-path="/deSEC-IPv6.txt"
:delay 1
:local PubIpv6 [/file get deSEC-IPv6.txt contents]
:delay 1

/tool fetch url="https://update.dedyn.io/update?username=MYDOMAIN.dedyn.io&password=PASSOWRD&myipv4=$PubIpv4&myipv6=$PubIpv6" mode=https src-path="/" dst-path="/deSEC-Update.txt"
:delay 10

/file remove deSEC-IPv4.txt
/file remove deSEC-IPv6.txt
/file remove deSEC-Update.txt

:log info DONE