Auto update script for Hurricane Electric IPv6 Tunnel broker ipv4 endpoint behind NAT

Hello,

I’m using HE tunnel broker on RouterOS to have public ipv6 and my ISP give me only ipv4 which is behind a NAT which means in /ip address you cannot see my public ipv4 only local IP for my ISP however with /ip cloud it does show my public ipv4 correctly. My ipv4 is dynamic and changes from time to time, I know there are quite few scripts online to update the HE tunnel broker ipv4 endpoint when and if my public ipv4 change however they read wan interface to read the ipv4 value. Now I was wandering if there is a way to read and use the public ipv4 that is being reported by /ip cloud?

Some the said scripts:

https://libreddit.kavin.rocks/r/mikrotik/comments/wh1wez/henet_6in4_tunnel_on_mikrotik_with_single_script/
https://buananetpbun.github.io/mikrotik/hurricane-electric-ipv6-tunnel-ipv4-endpoint-updater.html
http://forum.mikrotik.com/t/update-to-hurricane-electric-ipv6toipv4-endpoint-updater/51516/1
https://gist.githubusercontent.com/horzadome/8e5d99d84525ad8a8ccf/raw/39753ed7c422894dc2f58103f0b48df52213ccd5/heupdater.txt


Thanks in advance :slight_smile:

  1. Print all IP Cloud info to terminal
/ip/cloud/print
  1. Assign the IP Cloud IPv4 address to a variable and print it.
{
:local ipv4addr [/ip/cloud/get public-address]
:put $ipv4addr
}
  1. Assign all IP cloud information into an array, pick the IPv4 address, and then print it.
{
:local ipcloud [/ip/cloud/get]
:local ipv4addr ($ipcloud->"public-address")
:put $ipv4addr
}

Thank you.
I’ve tried with first revision of your answer and it worked (Although I had to edit those scripts and remove some parts of them).