Community discussions

MikroTik App
 
supportalpha
just joined
Topic Author
Posts: 3
Joined: Tue Mar 02, 2021 5:49 pm

Reset and load a custom save.rsc file

Tue Mar 02, 2021 6:07 pm

Hello,

OS version :
MikroTik RouterOS 6.45.9 (c) 1999-2020

I try to reset my Mikrotik hAP ac2 and make it load my save.rsc file :

/system reset-configuration no-defaults=yes run-after-reset=flash/save.rsc
Dangerous! Reset anyway? [y/N]:
y
system configuration will be reset
Received disconnect from 192.168.88.1 port 22:11: shutdown/reboot
Disconnected from 192.168.88.1 port 22

In the file save.rsc, I put this line at the top of the file (after the line "# serial number = A9.....") :
/delay delay-time=15

Unfortunately, after validation with "y", the router reboot but none of the LAN ports got an IP address, so the file save.rsc has not been loaded.

Is someone could help me please ?

Thanks.
 
sindy
Forum Guru
Forum Guru
Posts: 10205
Joined: Mon Dec 04, 2017 9:19 pm

Re: Reset and load a custom save.rsc file

Thu Mar 04, 2021 3:04 pm

15 seconds of delay may not be enough, 60s or 1m should be safe.

But more important, this typically happens if there is a mistake in the .rsc file. I know it sounds strange, but I've seen cases where some configuration was allowed in one RouterOS version, and later it stopped being accepted, but survived both the upgrade from the version allowing it to the newer one and the later export. So the fact that the export threw no error is not a sufficient guarantee that the import will succeed.

If this is the reason, the import breaks on the first error. So connect using Winbox or mac-telnet and copy-paste the export in groups of lines to see which one causes the issue.
 
supportalpha
just joined
Topic Author
Posts: 3
Joined: Tue Mar 02, 2021 5:49 pm

Re: Reset and load a custom save.rsc file

Wed Mar 10, 2021 3:10 pm

Thank you for your answer.

I'm going to check the lines of my file save.rsc, and put the delay on 60.

I'll be back in 2 weeks.

Kind regards
 
supportalpha
just joined
Topic Author
Posts: 3
Joined: Tue Mar 02, 2021 5:49 pm

Re: Reset and load a custom save.rsc file

Fri Mar 26, 2021 1:54 pm

Hello,

I tried with a delay to 60s without success.

I downgraded the OS of the Router to be the same of the file save.rsc, but it still doesn't work.

Is someone could help please ?
Thanks a lot.
 
sindy
Forum Guru
Forum Guru
Posts: 10205
Joined: Mon Dec 04, 2017 9:19 pm

Re: Reset and load a custom save.rsc file

Fri Mar 26, 2021 2:04 pm

As I wrote, unfortunately there are configuration element values which could be entered in older RouterOS versions, survived the subsequent upgrades, and survived the export, but aren't accepted in the current version when input. So even if you export a file from a machine running a particular version and then try to import it at exactly the same version, it fails due to these values added before the upgrade to the version you export from.

So you have to take the export and copy-paste it to the machine manually line by line (or at least section by section) to see what the issue is. "Object with such name already exists" is a consequence of the fact that you cannot connect to a device whose configuration is completely empty (mac-telnet access must be permitted by adding the management interface as a member of an interface list to which /tool mac-server allowed-interface-list and/or /tool mac-server allowed-interface-list refer, but other errors are important.
 
pe1chl
Forum Guru
Forum Guru
Posts: 10195
Joined: Mon Jun 08, 2015 12:09 pm

Re: Reset and load a custom save.rsc file

Fri Mar 26, 2021 4:16 pm

Even with a completely correct export file it is sometimes not possible to import it automatically, because there are mistakes in the sequence of the commands in export where some command refers to an item that is created only further down the file.
What I found when trying to import an export from a CCR into a CHR (which I keep as a fallback in case of hardware failure):
You can connect to the console (in the virtualization environment of the CHR or by connecting to MAC address in a hardware router) and clear the entire config, then you can do:
/import filename verbose=yes
Then it will print all the commands while it is importing, and when there is an error you do not get the error message like "instance already exists" without context, but you can see on the screen to which line this error actually refers!

Still it would be nice when the router would write a logfile when it does the run-after-reset because it is impossible to see what is going on.
It should write the error output (and the executed commands) to a file so you can look there what went wrong.
Also, it would be very welcome when the import just continued after minor errors, instead of halting at the first problem found and leaving the router only half configured and possibly difficult to reach.
It is so frustrating to debug these things without such info...
 
sindy
Forum Guru
Forum Guru
Posts: 10205
Joined: Mon Dec 04, 2017 9:19 pm

Re: Reset and load a custom save.rsc file

Fri Mar 26, 2021 4:27 pm

... by connecting to MAC address in a hardware router) and clear the entire config, ...
There's that caveat I've mentioned above, it seems that when the configuration is totally empty, MAC access is blocked.

So a dedicated .rsc file enabling just the MAC access may have to be used as run-after-reset:

:delay 60s
/tool mac-server
set allowed-interface-list=all
/tool mac-server mac-winbox
set allowed-interface-list=all


to allow MAC connection to debug the actual .rsc you want to import.
 
pe1chl
Forum Guru
Forum Guru
Posts: 10195
Joined: Mon Jun 08, 2015 12:09 pm

Re: Reset and load a custom save.rsc file

Fri Mar 26, 2021 5:51 pm

Ok, one could actually consider this to be a bug. Probably someone studied the matter of "MAC access available by default and that is insecure" and made this change without considering the situation of a full reset.
allowed-interface-list=all should be the default when no setting, and the default template can then limit that to e.g. allowed-interface-list=LAN.

Who is online

Users browsing this forum: Bing [Bot] and 72 guests