Community discussions

MikroTik App
 
soydekra
just joined
Topic Author
Posts: 13
Joined: Fri Jan 06, 2017 9:03 pm

This script for ipip tunnel works with v.7.1?

Wed Dec 15, 2021 10:23 am

Hi! I use this script for a ipip tunnel in a 6.49.2 version for update the DDNS, because i have in both sites dynamic public IP . Someone knows if it will work with the new version 7.1? Thank you!

local LocalAddr "XXXXXXXXXXXXX.sn.mynetname.net"
:local RemoteAddr "ZZZZZZZZZZZZZ.sn.mynetname.net"
:local CommentIDF "tunnel1"

##########################################

:local NewLocalAddr [:resolve $LocalAddr]
:local NewRemoteAddr [:resolve $RemoteAddr]

:local OldLocalAddr [/interface ipip get [find comment=$CommentIDF ] local-address]
:local OldRemoteAddr [/interface ipip get [find comment=$CommentIDF ] remote-address]

if ($NewLocalAddr != $OldLocalAddr) do={
/interface ipip set [find comment=$CommentIDF] local-address=$NewLocalAddr
/log info "Local tunnel IP for $CommentIDF has changed from $OldLocalAddr to $NewLocalAddr"
}

if ($NewRemoteAddr != $OldRemoteAddr) do={
/interface ipip set [find comment=$CommentIDF] remote-address=$NewRemoteAddr
/log info "Remote tunnel IP for $CommentIDF has changed from $OldRemoteAddr to $NewRemoteAddr"
}
 
Sob
Forum Guru
Forum Guru
Posts: 9119
Joined: Mon Apr 20, 2009 9:11 pm

Re: This script for ipip tunnel works with v.7.1?

Wed Dec 15, 2021 6:05 pm

Yes, it will work. You can easily test things like this yourself, even if you don't have spare router, simply get free CHR, run in it VM, and test anything you want.

Question is whether you need it at all. You can use hostname for remote address directly, IPIP tunnel supports it for some time already. And unless you have some multi-WAN config or several addresses on WAN for any other reason, you shouldn't need to set local address at all.
 
soydekra
just joined
Topic Author
Posts: 13
Joined: Fri Jan 06, 2017 9:03 pm

Re: This script for ipip tunnel works with v.7.1?

Thu Dec 16, 2021 9:58 am

Thanks for your answer Sob.

The problem about not use the script, I think, is that if my ISP changes the IP once the router is started, the tunnel will not change by itself. Also, some time ago I tried to put the ddns in the ip tunnel configuration and if I reboot the router and changes the public IPs in the tunnels, the ip's are not updated, so they do not connect with each other.

I think that where I have to put the ddns so that it works as you indicate is in the red fields of the photo, right?
You do not have the required permissions to view the files attached to this post.
 
User avatar
nichky
Forum Guru
Forum Guru
Posts: 1275
Joined: Tue Jun 23, 2015 2:35 pm

Re: This script for ipip tunnel works with v.7.1?

Thu Dec 16, 2021 11:37 am

if you use DNS name, than why you need that script?
 
Sob
Forum Guru
Forum Guru
Posts: 9119
Joined: Mon Apr 20, 2009 9:11 pm

Re: This script for ipip tunnel works with v.7.1?

Thu Dec 16, 2021 6:51 pm

I didn't test exact behaviour, how it deals with address changes, so maybe there is some unexpected glitch. Test it, don't set Local Address at all (close the field with arrow at the right), put remote hostname in Remote Address, and see how it works. If it does, good. If not, you can either try to debug what wrong, in case it's some bug. Or just go back to script, if it works for you.

Who is online

Users browsing this forum: jaclaz and 19 guests