Community discussions

MikroTik App
 
lukkes
Member Candidate
Member Candidate
Topic Author
Posts: 177
Joined: Mon Jun 16, 2008 2:12 am
Location: Venezuela
Contact:

Check if interface has no IP

Wed May 01, 2019 9:17 pm

Hello, I'm trying to update my DDNS interfaces but when I try to obtain the IP of an interface that has no IP, sometimes some interfaces did not get IP by DHCP cause the ISP is down, then the script abort in that interface, this is the line I use to obtain the ip
:local ddnsinterface "wan3_route"
:local ifip;

:set ifip [ /ip address get [/ip address find interface=$ddnsinterface] address ];
:log info "Actual IP is: $ifip
[code]

If wan3_route get an ip, the line works perfect, if not, then the scripts abort or get sucked in that line.

Thanks
 
lukkes
Member Candidate
Member Candidate
Topic Author
Posts: 177
Joined: Mon Jun 16, 2008 2:12 am
Location: Venezuela
Contact:

Re: Check if interface has no IP

Thu May 02, 2019 10:12 pm

Nobody? :shock:
 
User avatar
strods
MikroTik Support
MikroTik Support
Posts: 1633
Joined: Wed Jul 16, 2014 7:22 am
Location: Riga, Latvia

Re: Check if interface has no IP

Thu May 02, 2019 10:28 pm

I would recommend that you put all the script in if clause

If ([:len [/ip adress find where interface=interface_name]] > 0) do={}
 
lukkes
Member Candidate
Member Candidate
Topic Author
Posts: 177
Joined: Mon Jun 16, 2008 2:12 am
Location: Venezuela
Contact:

Re: Check if interface has no IP

Fri May 03, 2019 9:06 pm

The problem its that when the system evaluates the line it stop running the script, to be or not inside the if.
 
lukkes
Member Candidate
Member Candidate
Topic Author
Posts: 177
Joined: Mon Jun 16, 2008 2:12 am
Location: Venezuela
Contact:

Re: Check if interface has no IP

Wed May 08, 2019 2:27 am

163 Views and nobody knows, I can't believe it.
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3305
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Check if interface has no IP

Wed May 08, 2019 8:31 am

Why can you not use the Cloud function on the router?

IP->Clould

Just enable it and then you get a free DNS name from Mikrotik, based on your serial number, some like this
5fa34452b.sn.mynetname.net

It updates automatically all the time.

Then you can just point your outer DNS service to it.
myhost.dyndns.biz -> 5fa34452b.sn.mynetname.net -> your IP

Who is online

Users browsing this forum: No registered users and 7 guests