####### Copyright Netus Sp. z o.o. ####### www.netus.com.pl # # ####### Parametry skryptu - typowy klient :global Mode gateway :global Identity station-802.11an :global Password "" ####### # # ####### Od strony radia :global IP 172.26.1.2/255.255.255.0 :global Gateway 172.26.1.1 :global DNS 172.26.1.1 ####### # # ####### Od strony kabla (nie używane dla trybu [Mode] bridge i pseudobridge) :global LanIP 192.168.88.1/255.255.255.0 :global DHCPpool 192.168.88.200-192.168.88.254 ####### # # ####### Parametry radia :global SSID MikroTik :global Country poland :global SecAlgo none :global SecKey "" :global RxChains 0,1 :global TxChains 0,1 :global ExtCh above-control ####### # # ####### Ograniczenie przepustowości :global Bandwidth none ####### # # # # Mode - gateway - maskowanie adresów IP (NAT), # router - bez maskowania, # bridge - przeźroczysty most (WDS), wszystkie interfejsy połączone w jeden, # pseudobridge - jak wyżej ale bez WDS, zamiast tego translacja MAC adresów. # Identity - identyfikator systemu # Password - hasło dla loginu admin, "" - brak hasła # IP - adres IP i maska sieci po stronie radia [IP/MASK | dhcp] # Gateway - bramka domyślna [IP | dhcp] # DNS - adres IP serwera DNS [IP | dhcp] # LanIP - adres IP i maska sieci po stronie kabla [IP/MASK] # DHCPpool - pula adresów IP przydzielanych przez serwer DHCP lub none - serwer wyłączony [none | IP-IP] # SSID - identyfikator sieci radiowej # Country - kraj, określa pulę dostępnych częstotliwości i mocy nadawania # SecAlgo - algorytm szyfrowania [none | 104bit-wep | 40bit-wep | aes-ccm] # SecKey - klucz # RxChains - nr-y złącz antenowych używanych do odbioru danych (od lewej do prawej) [0,1,2] # TxChains - nr-y złącz antenowych używanych do transmisji danych (od lewej do prawej) [0,1,2] # ExtChan - parametr określa kierunek rozszerzenie kanału radiowego [above-control | below-control | disabled] # Bandwidth - ograniczenie przepustowości, np. 1M/512k [down/up | none] # # # Adres IP (ewentualnie Gateway lub DNS) po stronie radia może być pobierany automatycznie. # Przykład konfiguracji gdy IP, Gateway i DNS pobierane są z serwera DHCP # # :global IP dhcp # :global Gateway dhcp # :global DNS dhcp # # # # /system identity set name=$Identity /user set [find name=admin] password=$Password :global WID [:pick [/interface wireless find interface-type="Atheros 11N"]] :if (($Mode != "bridge") && ($Mode != "pseudobridge")) do={ :local EID "" /interface wireless set $WID disabled=yes /interface bridge port remove [find interface=[/interface get $WID name]] /ip dhcp-server remove [find interface=[/interface get $WID name]] :foreach i in=[/interface ethernet find] do={ /interface bridge port remove [find interface=[/interface get $i name]] /ip address remove [find interface=[/interface get $i name]] /ip dhcp-server remove [find interface=[/interface get $i name]] } :foreach b in=[/interface bridge find] do={:set b [/interface bridge get $b name]; :if ([:len [/interface bridge port find bridge=$b]] = 0) do={/ip address remove [find interface=$b]; /ip dhcp-server remove [find interface=$b]; /interface bridge remove $b}} :if ([:len [/interface ethernet find]] > 1) do={ /interface bridge add local b [/interface bridge find] set EID [:pick $b ([:len $b]-1)] foreach i in=[/interface ethernet find] do={/interface bridge port add interface=$i bridge=$EID} } else={ set EID [:pick [/interface ethernet find]] } /ip address remove [find interface=[/interface get $WID name]] remove [find interface=[/interface get $EID name]] add address=$LanIP interface=$EID :if ($IP != "dhcp") do={ add address=$IP interface=$WID } else={ /ip dhcp-client remove [find interface=[/interface get $WID name]] /ip dhcp-client add interface=$WID use-peer-dns=no add-default-route=no disabled=yes } :if ($DNS != "dhcp") do={ /ip dns set allow-remote-requests=yes servers=$DNS } else={ /ip dhcp-client set [find interface=[/interface get $WID name]] use-peer-dns=yes } /ip route remove [find dst-address=0.0.0.0/0] :if ($Gateway != "dhcp") do={ add gateway=$Gateway disabled=no } else={ /ip dhcp-client set [find interface=[/interface get $WID name]] add-default-route=yes } /ip dhcp-client set [find interface=[/interface get $WID name]] disabled=no /ip firewall nat remove [find action="masquerade"] :if ($Mode != "router") do={ add action=masquerade chain=srcnat disabled=no src-address=$LanIP } /ip pool remove [find name="script_pool"] :if ($DHCPpool != "none") do={ add name="script_pool" ranges=$DHCPpool } /ip dhcp-server remove [find interface=[/interface get $EID name]] :if ($DHCPpool != "none") do={ add address-pool=script_pool interface=$EID disabled=no /ip dhcp-server network :global NETGATEWAY [:pick $LanIP 0 [:find $LanIP "/"]] :global NETMASK [:pick $LanIP ([:find $LanIP "/"]+1) [:len $LanIP]] :global NETIP [/ip address get [find interface=[/interface get $EID name]] network] remove [find gateway=$NETGATEWAY] add address=($NETIP."/".$NETMASK) gateway=$NETGATEWAY dns-server=$NETGATEWAY netmask=$NETMASK /interface wireless reset-configuration $WID set $WID disabled=no ssid=$SSID band=5ghz-a/n country=$Country rate-set=configured ht-rxchains=$RxChains ht-txchains=$TxChains ht-basic-mcs=mcs-0 ht-extension-channel=$ExtCh ht-supported-mcs="mcs-0,mcs-1,mcs-2,mcs-3,mcs-4,mcs-5,mcs-6,mcs-7,mcs-8,mcs-9,mcs-10,mcs-11,mcs-12,mcs-13,mcs-14,mcs-15" mode=station wmm-support=enabled } } else={ :local BID "" /interface wireless set $WID disabled=yes /interface bridge port remove [find interface=[/interface get $WID name]] /ip dhcp-server remove [find interface=[/interface get $WID name]] :foreach i in=[/interface ethernet find] do={ /interface bridge port remove [find interface=[/interface get $i name]] /ip address remove [find interface=[/interface get $i name]] /ip dhcp-server remove [find interface=[/interface get $i name]] } :foreach b in=[/interface bridge find] do={:set b [/interface bridge get $b name]; :if ([:len [/interface bridge port find bridge=$b]] = 0) do={/ip address remove [find interface=$b]; /ip dhcp-server remove [find interface=$b]; /interface bridge remove $b}} /interface bridge add local b [/interface bridge find] set BID [:pick $b ([:len $b]-1)] foreach i in=[/interface ethernet find] do={/interface bridge port add interface=$i bridge=$BID} /interface bridge port add interface=$WID bridge=$BID /ip address remove [find interface=[/interface get $WID name]] :if ($IP != "dhcp") do={ add address=$IP interface=$BID } else={ /ip dhcp-client remove [find interface=[/interface get $BID name]] /ip dhcp-client add interface=$BID use-peer-dns=no add-default-route=no disabled=yes } :if ($DNS != "dhcp") do={ /ip dns set allow-remote-requests=yes servers=$DNS } else={ /ip dhcp-client set [find interface=[/interface get $BID name]] use-peer-dns=yes } /ip route remove [find dst-address=0.0.0.0/0] :if ($Gateway != "dhcp") do={ add gateway=$Gateway disabled=no } else={ /ip dhcp-client set [find interface=[/interface get $BID name]] add-default-route=yes } /ip dhcp-client set [find interface=[/interface get $BID name]] disabled=no /ip firewall nat remove [find action="masquerade"] /interface wireless reset-configuration $WID set $WID ssid=$SSID band=5ghz-a/n country=$Country rate-set=configured ht-rxchains=$RxChains ht-txchains=$TxChains ht-basic-mcs=mcs-0 ht-extension-channel=$ExtCh ht-supported-mcs="mcs-0,mcs-1,mcs-2,mcs-3,mcs-4,mcs-5,mcs-6,mcs-7,mcs-8,mcs-9,mcs-10,mcs-11,mcs-12,mcs-13,mcs-14,mcs-15" mode=station wmm-support=enabled :if ($Mode = "bridge") do={ set $WID disabled=no mode=station-wds } else={ set $WID disabled=no mode=station-pseudobridge } } /interface wireless security-profiles remove [find name="script_profile"] :if ($SecAlgo != "none") do={ add name=script_profile mode=static-keys-required static-sta-private-algo=$SecAlgo static-sta-private-key=$SecKey /interface wireless set $WID security-profile="script_profile" } /queue simple remove [find interface=[/interface get $WID name]] :if ($Bandwidth != "none") do={ add disabled=no interface=$WID max-limit=$Bandwidth } /system scheduler remove [find name=signal] add disabled=no interval=0s name=signal on-event="local RunningTime 60\r\n\r\n\r\ndelay 5;local wlan [/interface wireless get [find interface-type=\"Atheros 11N\"] name];local id;local f;for a from=1 to=(\$RunningTime*2) step=1 do={set id \"\";set id [:pick [/interface wireless registration-table find interface=\$wlan]];if ([:len \$id] > 0) do={set f ([/interface wireless registration-table get \$id signal-to-noise]*10);beep length=0.4 frequency=\$f};delay 0.5}" policy=read start-time=startup