Page 1 of 1

Default configuration after NetInstall

Posted: Tue Jun 04, 2013 6:07 pm
by Axizzz
I made new installation on my rb951 using netinstall without any config file and now my reset configuration is empty. I need to restore default configuration as reset config. How can I export "/system default-configuration" as config file for use it in the netinstall again? I think I should to use any script with set/get constructions but don't know how to do it. I tryed to copy "/system default-configuration print" from terminal and save it as .rsc file but when I use "import file.rsc" it says that all successfull but nothing happens with current configuration and after netinstall with this file also nothing happens. Can somebody help help me?

Re: Default configuration after NetInstall

Posted: Tue Jun 04, 2013 8:28 pm
by asaleh75
try
/system reset-configuration

Re: Default configuration after NetInstall

Posted: Wed Jun 05, 2013 1:56 am
by Axizzz
try
/system reset-configuration
/system reset-configuration
became the same as
/system reset-configuration no-default=yes
after netinstall.

Re: Default configuration after NetInstall

Posted: Mon Mar 30, 2015 7:42 am
by hongphalla
Can you let us know whether it work or not ?

Re: Default configuration after NetInstall

Posted: Mon Mar 30, 2015 9:22 am
by hossain2004a
Looking for Default configuration?
I knew It became handy someday.
:global ssid;
#| Wireless Configuration:
#|     mode:         ap-bridge;
#|     band1:      2ghz-b/g/n;
#|     ht-chains: two;
#|     ht-extension:   20/40mhz-ht-above;
#| 
#| WAN (gateway) Configuration:
#|     gateway:	ether1  (renamed with extension '-gateway');
#|     firewall: 	enabled;
#|     NAT:		enabled;
#|     DHCP Client:	enabled;
#| 
#| LAN Configuration:
#|     LAN Port:	bridge-local;
#|     switch group:	ether2 (master), ether3, ether4, ether5
#|          (renamed with extensions '-master-local' and '-slave-local')
#|     LAN IP:		192.168.88.1;
#|     DHCP Server:	enabled;

:global action;

#-------------------------------------------------------------------------------
# Apply configuration.
# these commands are executed after installation or configuration reset
#-------------------------------------------------------------------------------
:if ($action = "apply") do={
# wait for interfaces
:while ([/interface ethernet find] = "") do={ :delay 1s; };

		:local count 0;
		:while ([/interface wireless find name=wlan1] = "") do={ 
			:set count ($count +1);
			:if ($count = 60) do={
				:log warning "DefConf: Unable to find wireless interface"; 
				/ip address add address=192.168.88.1/24 interface=ether1;
				/quit
			}
			:delay 1s;
		};
     :log info "wlans found: $[/interface wireless find]";
		/interface wireless set wlan1 mode=ap-bridge band=2ghz-b/g/n ht-txchains=0,1 ht-rxchains=0,1 \
			disabled=no wireless-protocol=802.11 distance=indoors
		:local wlanMac  [/interface wireless get wlan1 mac-address];
		:set ssid "MikroTik-$[:pick $wlanMac 9 11]$[:pick $wlanMac 12 14]$[:pick $wlanMac 15 17]"
		/interface wireless set wlan1 ssid=$ssid
   /interface wireless set wlan1 frequency=$frequency
       /interface wireless set wlan1 channel-width=20/40mhz-ht-above ;
	/interface set ether1 name="ether1-gateway";
		/ip dhcp-client add interface=ether1-gateway disabled=no comment="default configuration";
	/interface {
		set ether2 name=ether2-master-local;
		set ether3 name=ether3-slave-local;
		set ether4 name=ether4-slave-local;
		set ether5 name=ether5-slave-local;
	}
	/interface ethernet {
		set ether3-slave-local master-port=ether2-master-local;
		set ether4-slave-local master-port=ether2-master-local;
		set ether5-slave-local master-port=ether2-master-local;
	}

	/interface bridge
		add name=bridge-local disabled=no auto-mac=no protocol-mode=rstp;
	:local bMACIsSet 0;
	:foreach k in=[/interface find] do={
		:local tmpPortName [/interface get $k name];
		:if (!($tmpPortName~"bridge"  || $tmpPortName~"ether1"|| $tmpPortName~"slave")) do={
			:if ($bMACIsSet = 0) do={
				:if ([/interface get $k type] = "ether") do={
					/interface bridge set "bridge-local" admin-mac=[/interface ethernet get $tmpPortName mac-address];
					:set bMACIsSet 1;
				}
			}
			/interface bridge port
				add bridge=bridge-local interface=$tmpPortName;
		}
	}
	/ip address add address=192.168.88.1/24 interface=bridge-local comment="default configuration";
		/ip pool add name="default-dhcp" ranges=192.168.88.10-192.168.88.254;
		/ip dhcp-server
			add name=default address-pool="default-dhcp" interface=bridge-local lease-time=10m disabled=no;
		/ip dhcp-server network
			add address=192.168.88.0/24 gateway=192.168.88.1 dns-server=192.168.88.1 comment="default configuration";
 /ip dns {
     set allow-remote-requests=yes
     static add name=router address=192.168.88.1
 }

	/ip firewall nat add chain=srcnat out-interface=ether1-gateway action=masquerade comment="default configuration"
	/ip firewall {
		filter add chain=input action=accept protocol=icmp comment="default configuration"
		filter add chain=input action=accept connection-state=established,related comment="default configuration"
		filter add chain=input action=drop in-interface=ether1-gateway comment="default configuration"
              filter add chain=forward action=accept connection-state=established,related comment="default configuration"
              filter add chain=forward action=drop connection-state=invalid comment="default configuration"
              filter add chain=forward action=drop connection-state=new connection-nat-state=!dstnat in-interface=ether1-gateway comment="default configuration"
	}
	/tool mac-server disable [find];
	/tool mac-server mac-winbox disable [find];
	:foreach k in=[/interface find] do={
		:local tmpName [/interface get $k name];
		:if (!($tmpName~"ether1-gateway")) do={
			/tool mac-server add interface=$tmpName disabled=no;
			/tool mac-server mac-winbox add interface=$tmpName disabled=no;
		}
	}
	/ip neighbor discovery set [find name="ether1-gateway"] discover=no
}

#-------------------------------------------------------------------------------
# Revert configuration.
# these commands are executed if user requests to remove default configuration
#-------------------------------------------------------------------------------
:if ($action = "revert") do={
# remove wan port protection
	/ip firewall {
		:local o [nat find comment="default configuration"]
		:if ([:len $o] != 0) do={ nat remove $o }
		:local o [filter find comment="default configuration"]
		:if ([:len $o] != 0) do={ filter remove $o }
	}
	/tool mac-server remove [find interface!=all]
	/tool mac-server set [find] disabled=no
	/tool mac-server mac-winbox remove [find interface!=all]
	/tool mac-server mac-winbox set [find] disabled=no
# reset wan ports;
	/ip neighbor discovery set [find name="ether1-gateway"] discover=yes
	/interface set "ether1-gateway" name=ether1;
		:local o [/ip dhcp-server network find comment="default configuration"]
		:if ([:len $o] != 0) do={ /ip dhcp-server network remove $o }
		:local o [/ip dhcp-server find name="default" address-pool="default-dhcp" interface="bridge-local" !disabled]
		:if ([:len $o] != 0) do={ /ip dhcp-server remove $o }
		/ip pool {
			:local o [find name="default-dhcp" ranges=192.168.88.10-192.168.88.254]
			:if ([:len $o] != 0) do={ remove $o }
		}
		:local o [/ip dhcp-client find comment="default configuration"]
		:if ([:len $o] != 0) do={ /ip dhcp-client remove $o }
	/ip dns {
		set allow-remote-requests=no
		:local o [static find name=router address=192.168.88.1]
		:if ([:len $o] != 0) do={ static remove $o }
	}
	/ip address {
		:local o [find comment="default configuration"]
		:if ([:len $o] != 0) do={ remove $o }
	}
# remove switch
	/interface set ether2-master-local name=ether2;
	/interface ethernet set ether3-slave-local master-port=none;
	/interface set ether3-slave-local name=ether3;
	/interface ethernet set ether4-slave-local master-port=none;
	/interface set ether4-slave-local name=ether4;
	/interface ethernet set ether5-slave-local master-port=none;
	/interface set ether5-slave-local name=ether5;
	/interface bridge port remove [find bridge="bridge-local"]
	/interface bridge remove [find name="bridge-local"]
	/interface set [find name~"wlan1"] name=wlan1
	/interface wireless reset-configuration wlan1
}