Community discussions

just joined
Topic Author
Posts: 1
Joined: Thu Oct 18, 2018 5:43 am

custom default configuration and have RouerOS Default configuration popup after reset

Thu Oct 18, 2018 6:15 am


I want to have RouterOS Default configuration popup appear after doing reset configuration to default when using custom default configuration. (see the link below for the pop up)

I already netinstall my custom configuration to my router and I don't seem to make it work.

here the problems I faced

1. when i comment out ":if ($action = "apply") do={" my script able to apply to the router. even if I reset to the default configuration. after I uncomment out it didn't work so I need have the RouterOS Default configuration pop up

The RouterOS Default configuration popup must be able to remove the configuration when I click the button "remove configuration" so how to do that?

here my custom default config, i have change the SSID to my own custom SSID

:global ssid;
#| RouterMode:
#| * WAN port is protected by firewall and enabled DHCP client
#| * Wireless and Ethernet interfaces (except WAN port ether1)
#| are part of LAN bridge
#| wlan1 Configuration:
#| mode: ap-bridge;
#| band: 2ghz-b/g/n;
#| tx-chains: 0;1;
#| rx-chains: 0;1;
#| ht-extension: 20/40mhz-Ce;
#| wlan2 Configuration:
#| mode: ap-bridge;
#| band: 5ghz-a/n/ac;
#| tx-chains: 0;
#| rx-chains: 0;
#| ht-extension: 20/40/80mhz-Ceee;
#| LAN Configuration:
#| IP address is set on bridge (LAN port)
#| DHCP Server: enabled;
#| WAN (gateway) Configuration:
#| gateway: ether1 ;
#| ip4 firewall: enabled;
#| NAT: enabled;
#| DHCP Client: enabled;
#| DNS: enabled;

:log info Starting_defconf_script_;
# Apply configuration.
# these commands are executed after installation or configuration reset
:if ($action = "apply") do={
# wait for interfaces
:local count 0;
:while ([/interface ethernet find] = "") do={
:if ($count = 30) do={
:log warning "DefConf: Unable to find ethernet interfaces";
:delay 1s; :set count ($count +1);

:local count 0;
:while ([/interface wireless print count-only] < 2) do={
:set count ($count +1);
:if ($count = 40) do={
:log warning "DefConf: Unable to find wireless interface(s)";
/ip address add address= interface=ether1 comment="defconf";
:delay 1s;
/interface wireless {
set wlan1 mode=ap-bridge band=2ghz-b/g/n disabled=no wireless-protocol=802.11 \
set wlan1 channel-width=20/40mhz-Ce;
set wlan1 frequency=auto
:local wlanMac [/interface wireless get wlan1 mac-address];
:set ssid "MikroTikMY-$[:pick $wlanMac 9 11]$[:pick $wlanMac 12 14]$[:pick $wlanMac 15 17]"
set wlan1 ssid=$ssid
/interface wireless {
set wlan2 mode=ap-bridge band=5ghz-a/n/ac disabled=no wireless-protocol=802.11 \
set wlan2 channel-width=20/40/80mhz-Ceee;
set wlan2 frequency=auto
:local wlanMac [/interface wireless get wlan2 mac-address];
:set ssid "MikroTikMY-$[:pick $wlanMac 9 11]$[:pick $wlanMac 12 14]$[:pick $wlanMac 15 17]"
set wlan2 ssid=$ssid
/interface list add name=WAN comment="defconf"
/interface list add name=LAN comment="defconf"
/interface bridge
add name=bridge disabled=no auto-mac=yes protocol-mode=rstp comment=defconf;
:local bMACIsSet 0;
:foreach k in=[/interface find where !(slave=yes || name="ether1" || name~"bridge")] do={
:local tmpPortName [/interface get $k name];
:log info "port: $tmpPortName"
:if ($bMACIsSet = 0) do={
:if ([/interface get $k type] = "ether") do={
/interface bridge set "bridge" auto-mac=no admin-mac=[/interface ethernet get $tmpPortName mac-address];
:set bMACIsSet 1;
/interface bridge port
add bridge=bridge interface=$tmpPortName comment=defconf;
/ip pool add name="default-dhcp" ranges=;
/ip dhcp-server
add name=defconf address-pool="default-dhcp" interface=bridge lease-time=10m disabled=no;
/ip dhcp-server network
add address= gateway= comment="defconf";
/ip address add address= interface=bridge comment="defconf";
/ip dhcp-client add interface=ether1 disabled=no comment="defconf";
/interface list member add list=LAN interface=bridge comment="defconf"
/interface list member add list=WAN interface=ether1 comment="defconf"
/ip firewall nat add chain=srcnat out-interface-list=WAN ipsec-policy=out,none action=masquerade comment="defconf: masquerade"
/ip firewall {
filter add chain=input action=accept connection-state=established,related,untracked comment="defconf: accept established,related,untracked"
filter add chain=input action=drop connection-state=invalid comment="defconf: drop invalid"
filter add chain=input action=accept protocol=icmp comment="defconf: accept ICMP"
filter add chain=input action=drop in-interface-list=!LAN comment="defconf: drop all not coming from LAN"
filter add chain=forward action=accept ipsec-policy=in,ipsec comment="defconf: accept in ipsec policy"
filter add chain=forward action=accept ipsec-policy=out,ipsec comment="defconf: accept out ipsec policy"
filter add chain=forward action=fasttrack-connection connection-state=established,related comment="defconf: fasttrack"
filter add chain=forward action=accept connection-state=established,related,untracked comment="defconf: accept established,related, untracked"
filter add chain=forward action=drop connection-state=invalid comment="defconf: drop invalid"
filter add chain=forward action=drop connection-state=new connection-nat-state=!dstnat in-interface-list=WAN comment="defconf: drop all from WAN not DSTNATed"
/ip neighbor discovery-settings set discover-interface-list=LAN
/tool mac-server set allowed-interface-list=LAN
/tool mac-server mac-winbox set allowed-interface-list=LAN
/ip dns {
set allow-remote-requests=yes
static add name=router.lan address=

# Revert configuration.
# these commands are executed if user requests to remove default configuration
:if ($action = "revert") do={
/user set admin password=""
/system routerboard mode-button set enabled=no
/system routerboard mode-button set on-event=""
/system script remove [find comment~"defconf"]
/ip firewall filter remove [find comment~"defconf"]
/ip firewall nat remove [find comment~"defconf"]
/interface list member remove [find comment~"defconf"]
/interface detect-internet set detect-interface-list=none
/interface detect-internet set lan-interface-list=none
/interface detect-internet set wan-interface-list=none
/interface detect-internet set internet-interface-list=none
/interface list remove [find comment~"defconf"]
/tool mac-server set allowed-interface-list=all
/tool mac-server mac-winbox set allowed-interface-list=all
/ip neighbor discovery-settings set discover-interface-list=!dynamic
:local o [/ip dhcp-server network find comment="defconf"]
:if ([:len $o] != 0) do={ /ip dhcp-server network remove $o }
:local o [/ip dhcp-server find name="defconf" !disabled]
:if ([:len $o] != 0) do={ /ip dhcp-server remove $o }
/ip pool {
:local o [find name="default-dhcp" ranges=]
:if ([:len $o] != 0) do={ remove $o }
:local o [/ip dhcp-client find comment="defconf"]
:if ([:len $o] != 0) do={ /ip dhcp-client remove $o }
/ip dns {
set allow-remote-requests=no
:local o [static find name=router.lan address=]
:if ([:len $o] != 0) do={ static remove $o }
/ip address {
:local o [find comment="defconf"]
:if ([:len $o] != 0) do={ remove $o }
:foreach iface in=[/interface ethernet find] do={
/interface ethernet set $iface name=[get $iface default-name]
/interface bridge port remove [find comment="defconf"]
/interface bridge remove [find comment="defconf"]
/interface wireless reset-configuration wlan1
/interface wireless reset-configuration wlan2
:log info Defconf_script_finished;
:set ssid; ... 6642332855

Who is online

Users browsing this forum: No registered users and 13 guests