Community discussions

MikroTik App
 
dwkwong
just joined
Topic Author
Posts: 2
Joined: Wed Jun 10, 2020 7:15 am

IP cloud public address into variable

Tue Jun 30, 2020 4:39 am

Hi, I am new to scripting in Mikrotik, how to get a non-list type value into a variable, e.g. below, how to get below address into " :global public_ipv4"

[admin@MikroTik] /ip cloud print
ddns-enabled: yes
ddns-update-interval: none
update-time: yes
public-address: 159.148.147.196
public-address-ipv6: 2a02:610:7501:1000::2
dns-name: 529c0491d41c.sn.mynetname.net
status: updated
 
User avatar
vecernik87
Long time Member
Long time Member
Posts: 665
Joined: Fri Nov 10, 2017 8:19 am

Re: IP cloud public address into variable

Tue Jun 30, 2020 4:55 am

print the data into console:
:put [/ip cloud get public-address]
Save into variable:
:global public_ipv4 [/ip cloud get public-address]
Enjoy :)
 
User avatar
nichky
Long time Member
Long time Member
Posts: 602
Joined: Tue Jun 23, 2015 2:35 pm

Re: IP cloud public address into variable

Tue Jun 30, 2020 5:44 am

@vecernik87

What does it do?

/ip cloud advanced set use-local-address=yes

can you give us an example, and on which causes can we use?
Nikola Suminoski
MikroTik Consultan
MTCRE l MTCWE

!) Safe Mode is your friend;
 
User avatar
jvanhambelgium
Member Candidate
Member Candidate
Posts: 292
Joined: Thu Jul 14, 2016 9:29 pm
Location: Belgium

Re: IP cloud public address into variable

Tue Jun 30, 2020 7:55 am

Hi,
RTFM I guess,

use-local-address (yes | no; Default: no)

By default, the DNS name will be assigned to the detected public address (from the UDP packet header). If you wish to send your "local" or "internal" IP address, then set this to yes


So no, you don't want to enable this feature if you intent to use the "published URL" to access public services.
Give it a try and see what IP ends up as registered.

Who is online

Users browsing this forum: Geyonk and 26 guests