Community discussions

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

import config files via DHCP

Mon Apr 28, 2014 3:20 pm

Dear,

I would like to know if there's a possibility to import configuration files into a router with RouterOS. What I would like to do is have the router automatically connect to a DHCP server and have this server push a configuration file back to the router. Is this possible or is there another way to get the same results?
 
User avatar
cdiedrich
Forum Veteran
Forum Veteran
Posts: 997
Joined: Thu Feb 13, 2014 2:03 pm
Location: Basel, Switzerland // Bremen, Germany
Contact:

Re: import config files via DHCP

Mon Apr 28, 2014 3:32 pm

I don't think a DHCP server can automagically push a config.
But I do think that it could be done with a lease script (See this Thread here).

In that script you could use the fetch command with the upload=yes option in mode=ftp.
Naming your script something.auto.rsc will it make auto-executed on the remote router as soon as it is there.

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

Re: import config files via DHCP

Mon Apr 28, 2014 4:13 pm

Thanks for your reply.

I might have been unclear in my first post here, sorry about that :)

That is one way to upload configuration files to a remote router. But as I can see in the Tools/Fetch manual you can also retrieve files with ftp from an FTP server that doesn't need to be a device with RouterSO running on it. At the end I want to be able to place a mikrotik router at a customer's premises and let this router get an IP address with DHCP and retrieve a configuration file using Tools/Fetch.

If I name that config file something.auto.rsc and copy that file from an FTP server on a router, then it should be auto-executed on that router as soon as it gets there right?
 
User avatar
cdiedrich
Forum Veteran
Forum Veteran
Posts: 997
Joined: Thu Feb 13, 2014 2:03 pm
Location: Basel, Switzerland // Bremen, Germany
Contact:

Re: import config files via DHCP

Mon Apr 28, 2014 4:24 pm

If I name that config file something.auto.rsc and copy that file from an FTP server on a router, then it should be auto-executed on that router as soon as it gets there right?
Ah :-)
As far as I have understood this, I'd say 'yes'.
I was playing around with exactly this idea last friday - and experienced that scripts named xxx.auto.rsc are NOT automatically executed when fetched by the receiving router.
I don't know if this is either by design or a bug in either RouterOS or my brains...

In your case I'd see a netwatch up-script (be sure you're not looping the script) or a schedule on startup (maybe starting with some seconds delay to ensure it got its IP address from DHCP) for this.

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

Re: import config files via DHCP

Mon Apr 28, 2014 4:30 pm

I have no experience with netwatch up-scripts. I'll look it up.

However, with scheduling a script on startup I think I can achieve what I want. I don't want to do too much on the router because the idea is to place multiple routers at multiple customer premises and have them pull files from one server at a secure location (let's say a datacenter).

If you come across any difficulties or new unexpected behaviour with playing around with this idea (:P) then I'd like to know!

As for now, I think I can go on for a while.
 
Beelze
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 60
Joined: Tue Mar 04, 2014 12:21 pm

Re: import config files via DHCP

Tue Apr 29, 2014 10:35 am


I was playing around with exactly this idea last friday - and experienced that scripts named xxx.auto.rsc are NOT automatically executed when fetched by the receiving router.
It should be working according to other posts. I guess it's a bug or something, luckily there's a way around it.

Who is online

Users browsing this forum: net4gyh, S8T8, sirbryan, smirgo and 80 guests