Community discussions

MikroTik App
 
Beelze
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 60
Joined: Tue Mar 04, 2014 12:21 pm

statements to run after DHCP IP-address

Tue May 06, 2014 4:41 pm

I have a CPE with a script that runs when powered on. Ether1 is a DHCP client that gets an IP-address from a DHCP server.
What I want to accomplish is that the script only continues when it can reach the internet on ether1.
After being able to connect to the internet, the CPE needs to download a file from an external server.

How can i automate this?
 
Beelze
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 60
Joined: Tue Mar 04, 2014 12:21 pm

Re: statements to run after DHCP IP-address

Tue May 06, 2014 5:50 pm

i want to do something like this:

:global test
:set test [resolve www.google.nl]
:put $test

nothing is stored in - test - ..
 
JJCinAZ
Member
Member
Posts: 475
Joined: Fri Oct 22, 2004 8:03 am
Location: Tucson, AZ

Re: statements to run after DHCP IP-address

Tue May 06, 2014 6:14 pm

Try:
:global test
:set test [:resolve www.google.nl]
:put $test
 
Beelze
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 60
Joined: Tue Mar 04, 2014 12:21 pm

Re: statements to run after DHCP IP-address

Tue May 06, 2014 6:18 pm

Thx, but it does the same thing. I've seen this somewhere else, but then with ping. Same result though.
 
jarda
Forum Guru
Forum Guru
Posts: 7756
Joined: Mon Oct 22, 2012 4:46 pm

Re: statements to run after DHCP IP-address

Tue May 06, 2014 6:21 pm

Check the internet address by netwatch regularly and put your script into UP statement.
 
Beelze
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 60
Joined: Tue Mar 04, 2014 12:21 pm

Re: statements to run after DHCP IP-address

Tue May 06, 2014 6:31 pm

Ahh, that is very clever, I will try that out, thx for your response!
 
jarda
Forum Guru
Forum Guru
Posts: 7756
Joined: Mon Oct 22, 2012 4:46 pm

Re: statements to run after DHCP IP-address

Tue May 06, 2014 6:40 pm

If you need it only once per boot, add netwatch disable at the end of the script and make new script with netwatch enable at router startup. Then it boots, enables netwatch, waits for response, do what you want and disables itself.
 
Beelze
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 60
Joined: Tue Mar 04, 2014 12:21 pm

Re: statements to run after DHCP IP-address

Wed May 07, 2014 10:21 am

Yea, i need something like that. I still wonder why resolving a domain is not stored in the variable.
 
jarda
Forum Guru
Forum Guru
Posts: 7756
Joined: Mon Oct 22, 2012 4:46 pm

Re: statements to run after DHCP IP-address

Wed May 07, 2014 10:36 am

Resolved domain is stored in dns cache.
 
Beelze
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 60
Joined: Tue Mar 04, 2014 12:21 pm

Re: statements to run after DHCP IP-address

Wed May 07, 2014 10:50 am

Resolved domain is stored in dns cache.
Right, but I if don't use netwatch, i want to check connectivity live. Using the dns cache is not exactly live.
 
jarda
Forum Guru
Forum Guru
Posts: 7756
Joined: Mon Oct 22, 2012 4:46 pm

Re: statements to run after DHCP IP-address

Wed May 07, 2014 11:03 am

So chain of two netwatches. First checks the dns server and then resolves ip into second netwatch and enables it.

Who is online

Users browsing this forum: No registered users and 20 guests