Community discussions

 
Ehman
Member
Member
Topic Author
Posts: 363
Joined: Mon Nov 15, 2010 10:49 pm

ip resolver an change ip if changed -need help

Tue Jul 16, 2013 1:44 am

Hi, can someone help me with a script that resolves a ip and only update it, if the IP changed?

#here is my current script
:local resolvedIP [:resolve "mydomaintoberesolved.com"];
/ip hotspot walled-garden ip set [find comment=mydomainthingy] dst-address $resolvedIP

so every time it updates/resolves it disrupts the connection :(
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: ip resolver an change ip if changed -need help

Tue Jul 16, 2013 3:45 am

Use two walled-garden ip entries.
/ip hotspot walled-garden ip
add dst-address=1.2.3.4 action=accept comment=currentIP
add dst-address=2.3.4.5 action=accept comment=oldIP
Then enter this script and run it. Change the domain name of course.
:local resolvedIP [:resolve www.mydomain.com];
:local currentIP [/ip hotspot walled-garden ip get [find comment=currentIP] dst-address];

:if ($resolvedIP != $currentIP) do={
  /ip hotspot walled-garden ip set [find comment=oldIP] dst-address=$currentIP;
  /ip hotspot walled-garden ip set [find comment=currentIP] dst-address=$resolvedIP;
}
It will keep the current ip and the previous ip in the walled garden in the event a client is still using the previous ip.
 
Ehman
Member
Member
Topic Author
Posts: 363
Joined: Mon Nov 15, 2010 10:49 pm

Re: ip resolver an change ip if changed -need help

Tue Jul 16, 2013 6:41 pm

thx :)

Who is online

Users browsing this forum: No registered users and 17 guests