Setting a custom default configuration after system reset

Hi all,

I have a couple of SXT’s that I like to setup with a certain configuration. I’ve found a topic on this forum that describes this as possible through netinstall (http://forum.mikrotik.com/t/customize-default-configuration-script/25002/1). I’ve written an custom configuration that works when pasting it in the terminal and gets executed, I’m able to use this configuration from Netinstall as well.

However, as I understood from the previous mentioned topic, this would also mean this custom configuration gets deployed when preforming a system reset using the physical button. But this isn’t the case in my test scenario, after doing a netinstall my custom configuration script runs and deploys all settings. But after preforming a reset the configuration completely disappears.

I’ve also done some test with uploading my configuration on the device and selecting it to run after a system reset, but that doesn’t work either. However when running my script as a script or pasting the configuration in the terminal it works as well.

I’m using the latest versions of Netinstall and RouterOS. If you need additional information, let me know. I will add it to my post then.

Paste your configuration here

I’ve also done some test with uploading my configuration on the device and selecting it to run after a system reset, but that doesn’t work either. However when running my script as a script or pasting the configuration in the terminal it works as well.

This leads me to think the script is failing when it’s being loaded early in the boot sequence.

Two tips:

1.- Try adding a

/delay 20

At the beggining of the script. Rationale: it could be wireless driver isn’t loaded at the time the script tries to set wlanX devices (no wlanX devices in the system at that point). This gives the OS time to load and initialize interfaces.

2.- Insert /beep commands with different frequencies along the script, that way you will know how far is reaching in the script.

Here is the configuration I have used. I’ve replaced my wpa-key with stars but it’s an actual value in the real script of course.

When using this configuration as a script it works, when pasting it in the terminal it works, when preforming a first installation using netinstall it works.

@Puttika, thnx for your suggestion. I will definitely try that!

/interface wireless
set [ find default-name=wlan1 ] band=5ghz-a/n/ac channel-width=20/40/80mhz-Ceee country=netherlands disabled=no frequency=auto mode=\ap-bridge ssid="THMultimedia" wireless-protocol=802.11

/interface wireless security-profiles
set [ find default=yes ] authentication-types=wpa-psk,wpa2-psk mode=dynamic-keys supplicant-identity=THMultimedia-MikroTik wpa-pre-shared-key=****** wpa2-pre-shared-key=***

/interface bridge
add fast-forward=no name=bridge1

/interface bridge port
add bridge=bridge1 interface=ether1
add bridge=bridge1 interface=wlan1

/ip address
add address=192.168.88.1/24 interface=ether1 network=192.168.88.1
add address=192.168.77.1/24 interface=bridge1 network=192.168.77.1

/ip pool
add name=dhcp_pool ranges=192.168.77.10-192.168.77.100

/ip dhcp-server 
add address-pool=dhcp_pool authoritative=after-2sec-delay disabled=no interface=bridge1 name=default

/ip dhcp-server network
add address=192.168.77.0/24 gateway=192.168.77.1 dns-server=8.8.8.8,8.8.4.4

/ip route
add distance=1 gateway=192.168.88.1

/ip dns
set servers=8.8.8.8,8.8.4.4

/system clock
set time-zone-name=Europe/Amsterdam

/system identity
set name=THMultimedia-MikroTik

Wireless drivers take some time to load. Default script can be executed faster than wireless drivers are loaded.
Best method in this case is to add loop to wait for wireless interfaces to appear at the beginning of your script.

Thanks for your tips guys!

I can confirm that it was indeed related to wireless drivers and fixed using a loop. I’ve taken a look at the MikroTik default configuration and used the loop element found in there.