Page 1 of 1

simple router initial configuration

Posted: Sun Dec 26, 2021 5:13 am
by mvcorrea
Simple wAP router with 2 interfaces (wlan1, ether1)
I just want a minimal setup to start configuring it.
:delay 15s;
:local rtname "router01";
:local pass "sup3rpa$$word";

/system clock set time-zone-name=America/Fortaleza
/system identity set name=$rtname
/user set admin password=$pass

## WAN addr via dhcp
/ip dhcp-client add disabled=no interface=ether1
and named it minimal.rsc and upload to the router.
when /system reset-configuration no-defaults=yes skip-backup=yes run-after-reset=minimal.rsc
I loose the router (need to hard reset it)
What Am I doing wrong? regards,

Re: simple router initial configuration

Posted: Sun Dec 26, 2021 11:32 am
by mkx
Can you connect to device using winbox in MAC mode when drvice is "lost"? Empty configuration should allow it and your extremely simple config should not break that.

Another possible culprit is trying to set admin password with some special characters (e.g. using un-escaped $) which might end up setting password different than what you expect at best and breaking configure script at worst ... so try to set admin password (including setting the local variable) as absolutely last command in your script ... device should receive the rest of config before that (and keep it even if config script breaks at that step).

Re: simple router initial configuration

Posted: Sun Dec 26, 2021 5:46 pm
by mvcorrea
thanks for your help,

So I have the a problem with "unescaped" chars in password? I will remove those :)
I don't understand about putting local variables at the end of the script? shouldn't I set a var prior to using it?
for those local vars (they are extremely handy then configuring multiple routers by changing those vars via python script).
You see any problem with the local variables?
I am going try it again with those modifications :)

regards,

Re: simple router initial configuration

Posted: Sun Dec 26, 2021 8:55 pm
by mkx
So I have the a problem with "unescaped" chars in password? I will remove those :)
I don't understand about putting local variables at the end of the script? shouldn't I set a var prior to using it?

I've no idea which part of your script breaks execution, I'm just mentioning possibilities.
You're right, you need to initialize cariable before using it ... but while you're troubleshooting your script, you might want to move initialization of password variable to the end of the script, and move password seting command immediately after it. As I mentioned, if the script breaks at some certain line, the preceeding configuration will be kept. So if password setting is indeed the culprit, you'll know because you'll see that device will obtain IP address from DHCP server and you will be able to log in with empty password.

When you figure out what exactly is breaking execution of init script, you can return to current script structure.