[HOWTO] Detect Dynamic Internet IP Address

Since my Internet IP address is dynamic, and I wanted to create firewall rules that act using it, I created the following script:

/ system script add name=gw-inet policy=test source=“/ ping > 195.170.0.2 > count=1 size=28”

/ system scheduler add comment=“” disabled=no interval=1m name=“Detect Internet Address” on-event=“/ system script run gw-inet” start-date=jan/01/1970 start-time=00:00:00

/ ip firewall filter add action=add-src-to-address-list address-list=InternetAddress address-list-timeout=2d chain=output comment=“Detect Internet Address” disabled=no dst-address=> 195.170.0.2 > out-interface=> gw-inet > protocol=icmp src-address-list=!InternetAddress

… which creates a script, that pings a host (a ns at my case), there is also a scheduler for that script, and finally a firewall output rule that catches the ping to host.

could use this instead of ping ?

:put [/ip dhcp-client get gw-inet address]