返回列表 發帖

【RouterOS】—— Initial configuration from scratch

我在想,RouterOS在RB的settings是否预置好,就是简单修改一下就可以用,这个修改不能让你RouterOS有更加大的进展,所以自己却有一个想法就是像学Asterisk一样,从新自己去建立,一定一滴去学习,总有一天我对RouterOS认识更加深。

http://wiki.mikrotik.com/wiki/Manual:Initial_Configuration

本帖最後由 角色 於 2014-9-9 01:42 編輯

其他关于default configuration,可以参考下面网页
http://wiki.mikrotik.com/wiki/Manual:Default_Configurations

TOP

The following script will be run for each system reset configuration.
  1. :global ssid;
  2. #| Wireless Configuration:
  3. #|     mode:                ap-bridge;
  4. #|     band:                2ghz-b/g/n;
  5. #|     ht-chains:        two;
  6. #|     ht-extension:   20/40mhz-ht-above;
  7. #|
  8. #| WAN (gateway) Configuration:
  9. #|     gateway:        ether1  (renamed with extension '-gateway');
  10. #|     firewall:         enabled;
  11. #|     NAT:                enabled;
  12. #|     DHCP Client:        enabled;
  13. #|
  14. #| LAN Configuration:
  15. #|     LAN Port:        bridge-local;
  16. #|     switch group:        ether2 (master), ether3, ether4, ether5
  17. #|          (renamed with extensions '-master-local' and '-slave-local')
  18. #|     LAN IP:                192.168.88.1;
  19. #|     DHCP Server:        enabled;

  20. :global action;

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

  28.                 :local count 0;
  29.                 :while ([/interface wireless find] = "") do={
  30.                         :set count ($count +1);
  31.                         :if ($count = 60) do={
  32.                                 :log warning "DefConf: Unable to find wireless interface";
  33.                                 /ip address add address=192.168.88.1/24 interface=ether1;
  34.                                 /quit
  35.                         }
  36.                         :delay 1s;
  37.                 };
  38.         /interface wireless set wlan1 mode=ap-bridge band=2ghz-b/g/n ht-txchains=0,1 ht-rxchains=0,1 \
  39.             disabled=no wireless-protocol=any distance=indoors
  40.                 :local wlanMac  [/interface wireless get wlan1 mac-address];
  41.                 :set ssid "MikroTik-$[:pick $wlanMac 9 11]$[:pick $wlanMac 12 14]$[:pick $wlanMac 15 17]"
  42.                 /interface wireless set wlan1 ssid=$ssid
  43.        /interface wireless set wlan1 channel-width=20/40mhz-ht-above ;
  44.         /interface set ether1 name="ether1-gateway";
  45.                 /ip dhcp-client add interface=ether1-gateway disabled=no comment="default configuration";
  46.         /interface {
  47.                 set ether2 name=ether2-master-local;
  48.                 set ether3 name=ether3-slave-local;
  49.                 set ether4 name=ether4-slave-local;
  50.                 set ether5 name=ether5-slave-local;
  51.         }
  52.         /interface ethernet {
  53.                 set ether3-slave-local master-port=ether2-master-local;
  54.                 set ether4-slave-local master-port=ether2-master-local;
  55.                 set ether5-slave-local master-port=ether2-master-local;
  56.         }

  57.         /interface bridge
  58.                 add name=bridge-local disabled=no auto-mac=no protocol-mode=rstp;
  59.         :local bMACIsSet 0;
  60.         :foreach k in=[/interface find] do={
  61.                 :local tmpPortName [/interface get $k name];
  62.                 :if (!($tmpPortName~"bridge"  || $tmpPortName~"ether1"|| $tmpPortName~"slave")) do={
  63.                         :if ($bMACIsSet = 0) do={
  64.                                 :if ([/interface get $k type] = "ether") do={
  65.                                         /interface bridge set "bridge-local" admin-mac=[/interface ethernet get $tmpPortName mac-address];
  66.                                         :set bMACIsSet 1;
  67.                                 }
  68.                         }
  69.                         /interface bridge port
  70.                                 add bridge=bridge-local interface=$tmpPortName;
  71.                 }
  72.         }
  73.         /ip address add address=192.168.88.1/24 interface=bridge-local comment="default configuration";
  74.                 /ip pool add name="default-dhcp" ranges=192.168.88.10-192.168.88.254;
  75.                 /ip dhcp-server
  76.                         add name=default address-pool="default-dhcp" interface=bridge-local lease-time=10m disabled=no;
  77.                 /ip dhcp-server network
  78.                         add address=192.168.88.0/24 gateway=192.168.88.1 dns-server=192.168.88.1 comment="default configuration";
  79. /ip dns {
  80.      set allow-remote-requests=yes
  81.      static add name=router address=192.168.88.1
  82. }

  83.         /ip firewall nat add chain=srcnat out-interface=ether1-gateway action=masquerade comment="default configuration"
  84.         /ip firewall {
  85.                 filter add chain=input action=accept protocol=icmp comment="default configuration"
  86.                 filter add chain=input action=accept connection-state=established comment="default configuration"
  87.                 filter add chain=input action=accept connection-state=related comment="default configuration"
  88.                 filter add chain=input action=drop in-interface=ether1-gateway comment="default configuration"
  89.               filter add chain=forward action=accept connection-state=established comment="default configuration"
  90.               filter add chain=forward action=accept connection-state=related comment="default configuration"
  91.               filter add chain=forward action=drop connection-state=invalid comment="default configuration"
  92.         }
  93.         /tool mac-server disable [find];
  94.         /tool mac-server mac-winbox disable [find];
  95.         :foreach k in=[/interface find] do={
  96.                 :local tmpName [/interface get $k name];
  97.                 :if (!($tmpName~"ether1-gateway")) do={
  98.                         /tool mac-server add interface=$tmpName disabled=no;
  99.                         /tool mac-server mac-winbox add interface=$tmpName disabled=no;
  100.                 }
  101.         }
  102.         /ip neighbor discovery set [find name="ether1-gateway"] discover=no
  103. }

  104. #-------------------------------------------------------------------------------
  105. # Revert configuration.
  106. # these commands are executed if user requests to remove default configuration
  107. #-------------------------------------------------------------------------------
  108. :if ($action = "revert") do={
  109. # remove wan port protection
  110.         /ip firewall {
  111.                 :local o [nat find comment="default configuration"]
  112.                 :if ([:len $o] != 0) do={ nat remove $o }
  113.                 :local o [filter find comment="default configuration"]
  114.                 :if ([:len $o] != 0) do={ filter remove $o }
  115.         }
  116.         /tool mac-server remove [find interface!=all]
  117.         /tool mac-server set [find] disabled=no
  118.         /tool mac-server mac-winbox remove [find interface!=all]
  119.         /tool mac-server mac-winbox set [find] disabled=no
  120. # reset wan ports;
  121.         /ip neighbor discovery set [find name="ether1-gateway"] discover=yes
  122.         /interface set "ether1-gateway" name=ether1;
  123.                 :local o [/ip dhcp-server network find comment="default configuration"]
  124.                 :if ([:len $o] != 0) do={ /ip dhcp-server network remove $o }
  125.                 :local o [/ip dhcp-server find name="default" address-pool="default-dhcp" interface="bridge-local" !disabled]
  126.                 :if ([:len $o] != 0) do={ /ip dhcp-server remove $o }
  127.                 /ip pool {
  128.                         :local o [find name="default-dhcp" ranges=192.168.88.10-192.168.88.254]
  129.                         :if ([:len $o] != 0) do={ remove $o }
  130.                 }
  131.                 :local o [/ip dhcp-client find comment="default configuration"]
  132.                 :if ([:len $o] != 0) do={ /ip dhcp-client remove $o }
  133.         /ip dns {
  134.                 set allow-remote-requests=no
  135.                 :local o [static find name=router address=192.168.88.1]
  136.                 :if ([:len $o] != 0) do={ static remove $o }
  137.         }
  138.         /ip address {
  139.                 :local o [find comment="default configuration"]
  140.                 :if ([:len $o] != 0) do={ remove $o }
  141.         }
  142. # remove switch
  143.         /interface set ether2-master-local name=ether2;
  144.         /interface ethernet set ether3-slave-local master-port=none;
  145.         /interface set ether3-slave-local name=ether3;
  146.         /interface ethernet set ether4-slave-local master-port=none;
  147.         /interface set ether4-slave-local name=ether4;
  148.         /interface ethernet set ether5-slave-local master-port=none;
  149.         /interface set ether5-slave-local name=ether5;
  150.         /interface bridge port remove [find bridge="bridge-local"]
  151.         /interface bridge remove [find name="bridge-local"]
  152.         /interface set [find name~"wlan1"] name=wlan1
  153.         /interface wireless reset-configuration wlan1
  154. }
複製代碼

TOP

返回列表