Community discussions

MikroTik App
 
nibunasah
just joined
Topic Author
Posts: 2
Joined: Tue Mar 31, 2020 10:15 pm

[HELP]Set NAT dst-address not work

Tue Mar 31, 2020 10:51 pm

i'm using this script to update nat dst-address.

/tool fetch url="https://wtfismyip.com/text" mode=http dst-path=mypublicip.txt
:local currentIP1 [/file get mypublicip.txt contents]

:log info "Fetched current IP as $currentIP1"

/ip firewall nat set 1 dst-address=$currentIP1
var $currentIP1 not work, but work if manual input, dst-address="123.123.111.111"

:log info " $currentIP1" <-this work show ip adress

please help..

Thank you
 
User avatar
macsrwe
Forum Guru
Forum Guru
Posts: 1011
Joined: Mon Apr 02, 2007 5:43 am
Location: Arizona, USA
Contact:

Re: [HELP]Set NAT dst-address not work  [SOLVED]

Wed Apr 01, 2020 11:53 pm

Common problem. Use [:tochar ] (correction) [:tostr ] to turn variable contents into a string instead of a numeric address.
Last edited by macsrwe on Fri Apr 03, 2020 3:41 pm, edited 1 time in total.
 
nibunasah
just joined
Topic Author
Posts: 2
Joined: Tue Mar 31, 2020 10:15 pm

Re: [HELP]Set NAT dst-address not work

Thu Apr 02, 2020 2:53 pm

Common problem. Use [:tochar ] to turn variable contents into a string instead of a numeric address.
tks for ur replay that give me idea. "tochar" i count char on txt file, that site have empty line in txt file :shock:
 
User avatar
macsrwe
Forum Guru
Forum Guru
Posts: 1011
Joined: Mon Apr 02, 2007 5:43 am
Location: Arizona, USA
Contact:

Re: [HELP]Set NAT dst-address not work

Fri Apr 03, 2020 3:40 pm

Sorry, I misspoke. The function is :tostr, not :tochar.

https://wiki.mikrotik.com/wiki/Manual:S ... g#Commands

Who is online

Users browsing this forum: LouisdeBussy and 5 guests