Default configuration on RB750

MikroTikRouterOS RB450G
回覆文章
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

Default configuration on RB750

文章 yehlu »

http://forum.mikrotik.com/viewtopic.php?f=9&t=33489

代碼: 選擇全部

#| ether1 is renamed ether1-gateway, rest of interfaces are switched
#| IP address 192.168.88.1/24 is on switch
#| DHCP client is on ether1-gateway
#| DHCP server is on switch, with address pool 192.168.88.10-192.168.88.254
#| masquerade on ether1-gateway
:global action

# these commands are executed after installation or configuration reset
:if ($action = "apply") do={
/interface set ether1 name=ether1-gateway
/interface set ether2 name=ether2-local-master
/interface set ether3 name=ether3-local-slave
/interface set ether4 name=ether4-local-slave
/interface set ether5 name=ether5-local-slave

/interface ethernet set ether3-local-slave master-port=ether2-local-master
/interface ethernet set ether4-local-slave master-port=ether2-local-master
/interface ethernet set ether5-local-slave master-port=ether2-local-master

/ip address add address=192.168.88.1/24 interface=ether2-local-master comment="default configuration"

:if ([:len [/system package find name="dhcp" !disabled]] != 0) do={
/ip dhcp-client add interface=ether1-gateway disabled=no 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=ether2-local-master 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 firewall {
filter add chain=input action=accept protocol=icmp comment="default configuration"
filter add chain=input action=accept connection-state=established in-interface=ether1-gateway comment="default configuration"
filter add chain=input action=accept connection-state=related in-interface=ether1-gateway comment="default configuration"
filter add chain=input action=drop in-interface=ether1-gateway comment="default configuration"
nat add chain=srcnat out-interface=ether1-gateway action=masquerade comment="default configuration"
}

/ip dns {
set allow-remote-requests=yes
static add name=router address=192.168.88.1
}

/tool mac-server remove [find]
/tool mac-server add interface=ether2-local-master disabled=no
/tool mac-server add interface=ether3-local-slave disabled=no
/tool mac-server add interface=ether4-local-slave disabled=no
/tool mac-server add interface=ether5-local-slave disabled=no

/tool mac-server mac-winbox disable [find]
/tool mac-server mac-winbox add interface=ether2-local-master disabled=no
/tool mac-server mac-winbox add interface=ether3-local-slave disabled=no
/tool mac-server mac-winbox add interface=ether4-local-slave disabled=no
/tool mac-server mac-winbox add interface=ether5-local-slave disabled=no

/ip neighbor discovery set [find name=ether1-gateway] discover=no
}

# these commands are executed if user requests to remove default configuration
:if ($action = "revert") do={
/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 }
}

:if ([:len [/system package find name="dhcp" !disabled]] != 0) do={
: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=ether2-local-master !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 }
}

/tool mac-server remove [find]
/tool mac-server add interface=all disabled=no

/tool mac-server mac-winbox remove [find interface!=all]
/tool mac-server mac-winbox set [find] disabled=no 

/ip neighbor discovery set [find name=ether1-gateway] discover=yes

/interface ethernet set ether3-local-slave master-port=none
/interface ethernet set ether4-local-slave master-port=none
/interface ethernet set ether5-local-slave master-port=none

/interface set ether1-gateway name=ether1
/interface set ether2-local-master name=ether2
/interface set ether3-local-slave name=ether3
/interface set ether4-local-slave name=ether4
/interface set ether5-local-slave name=ether5
}
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

Re: Default configuration on RB750

文章 yehlu »

列出預設的指令檔

代碼: 選擇全部

system default-configuration print
將系統RESET 並載入預設的指令檔

代碼: 選擇全部

system reset-configuration
將系統RESET 不載入預設的指令檔

代碼: 選擇全部

system reset-configuration no-defaults=yes
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

Re: Default configuration on RB750

文章 yehlu »

預設值的 config backup
附加檔案
RB750Default.backup
(11.82 KiB) 已下載 287 次
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

RB450G

文章 yehlu »

代碼: 選擇全部

          #| DHCP client and masquerade is set on ether1-gateway
          #| ether2 is renamed to ether2-master-local and configured as switch>
          #| IP address 192.168.88.1/24 and DHCP server is set on ether2-maste>
          #| DHCP servers address pool is 192.168.88.10-192.168.88.254

          :global action;
          :local dhcpEnabled 0;
          :local wirelessEnabled 0;

          #check for wireless and dhcp packages
          :if ([:len [/system package find name="dhcp" !disabled]] != 0) do={
          }     :set dhcpEnabled 1;
          }
          :if ([:len [/system package find name="wireless" !disabled]] != 0) d>
          }     :set wirelessEnabled 1;
          }

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

          /interface set ether1 name="ether1-gateway";
          :if ( $dhcpEnabled = 1) do={
          /ip dhcp-client add interface=ether1-gateway disabled=no comment=">
          }

          /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;
          }

          /ip address add address=192.168.88.1/24 interface=ether2-master-loc>
          :if ($dhcpEnabled = 1) do={
          /ip pool add name="default-dhcp" ranges=192.168.88.10-192.168.88.2>
          /ip dhcp-server
          add name=default address-pool="default-dhcp" interface=ether2-mas>
          /ip dhcp-server network
          add address=192.168.88.0/24 gateway=192.168.88.1 dns-server=192.1>
          }
          /ip firewall nat add chain=srcnat out-interface=ether1-gateway acti>
          /ip firewall {
          filter add chain=input action=accept protocol=icmp comment="defaul>
          filter add chain=input action=accept connection-state=established >
          filter add chain=input action=accept connection-state=related comm>
          }
          /tool mac-server remove [find];
          /tool mac-server mac-winbox disable [find];
          :foreach k in=[/interface find] do={
          :local tmpName [/interface get $k name];
          :if (!($tmpName~"ether1")) 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
          /ip dns {
          set allow-remote-requests=yes
          static add name=router address=192.168.88.1
          }

          }
          #------------------------------------------------------------------->
          # Revert configuration.
          # these commands are executed if user requests to remove default con>
          #------------------------------------------------------------------->
          :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]
          /tool mac-server add interface=all 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;
          :if ($dhcpEnabled = 1) do={
          :local o [/ip dhcp-server network find comment="default configurat>
          :if ([:len $o] != 0) do={ /ip dhcp-server network remove $o }
          :local o [/ip dhcp-server find name="default" address-pool="defaul>
          :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.8>
          :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
          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;

          }
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

RB751U-2Hnd

文章 yehlu »

代碼: 選擇全部

#| ether1 is renamed to ether1-gateway
#| DHCP client and masquerade is set on ether1-gateway
#| ether2 is renamed to ether2-master-local and configured as switch master port for ether3-ether5
#| ether2-master-local and wlan1 are bridged
#| wireless is set as access point in 2412MHz using both chains and extension channel enabled.
#| IP address 192.168.88.1/24 and DHCP server is set on bridge interface
#| DHCP servers address pool is 192.168.88.10-192.168.88.254

:global action;
:local dhcpEnabled 0;
:local wirelessEnabled 0;

#check for wireless and dhcp packages
:if ([:len [/system package find name="dhcp" !disabled]] != 0) do={
	:set dhcpEnabled 1;
}
:if ([:len [/system package find name="wireless" !disabled]] != 0) do={
	:set wirelessEnabled 1;
}

#-------------------------------------------------------------------------------
# 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; };
	:if ( $wirelessEnabled = 1) do={
# wait for wireless
		:local count 0;
		:while ([/interface wireless find] = "") 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;
		};
		/interface wireless set wlan1 mode=ap-bridge band=2ghz-b/g/n ht-txchains=0,1 ht-rxchains=0,1 \
			disabled=no country=no_country_set wireless-protocol=any
		/interface wireless set wlan1 channel-width=20/40mhz-ht-above ;
	}

	/interface set ether1 name="ether1-gateway";
	:if ( $dhcpEnabled = 1) do={
		/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";
	:if ($dhcpEnabled = 1) do={
		/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 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 firewall {
		filter add chain=input action=accept protocol=icmp comment="default configuration"
		filter add chain=input action=accept connection-state=established comment="default configuration"
		filter add chain=input action=accept connection-state=related comment="default configuration"
		filter add chain=input action=drop in-interface=ether1-gateway comment="default configuration"
		nat add chain=srcnat out-interface=ether1-gateway action=masquerade comment="default configuration"
	}
	/tool mac-server remove [find];
	/tool mac-server mac-winbox disable [find];
	:foreach k in=[/interface find] do={
		:local tmpName [/interface get $k name];
		:if (!($tmpName~"ether1")) 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
	/ip dns {
		set allow-remote-requests=yes
		static add name=router address=192.168.88.1
	}

}

#-------------------------------------------------------------------------------
# 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]
	/tool mac-server add interface=all 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;
	:if ($dhcpEnabled = 1) do={
		: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"]
	:if ($wirelessEnabled = 1) do={
		/interface set [find name~"wlan1"] name=wlan1
		/interface wireless reset-configuration wlan1
	}

}

附加檔案
RB751U-2Hnd.backup
(13.63 KiB) 已下載 296 次
回覆文章

回到「RouterOS」