Community discussions

MikroTik App
 
ISPCanada
just joined
Topic Author
Posts: 9
Joined: Mon Aug 08, 2022 6:31 pm

Basic Script no longer functioning with V7 RouterOS

Fri Aug 19, 2022 6:13 pm

Hey all!

I had some basic scripts written up for use with hAP ac3 units to run as Access Points on our WiSP.

I recently got in a bunch of routers running v7.2.3, and when importing our script it reports "Script file loaded and executed successfully"

however, no changes appear to have been done to the router. Here's our code, any suggestions?

Thank you :^)
 ## Setup Mikrotik Router as Access Point on network

:local ssid2 "some wifi";  ## SSID of 2.4GHz WiFi
:local password2 "example321";  ## WPA2 Password for 2.4 WiFi

:local ssid5 "some wifi";  ## SSID of 5GHz WiFi
:local password5 "example321";  ## WPA2 Password for 5GHz WiFi

:local ipaddress "192.168.1.2";  ## IP address of this device
:local gatewayip "192.168.1.1";  ## Gateway address on network

:local name "some Wifi";  ## Customer name for system identity



###########################################################################
#  5-10 port router with 1, or 2 wifi interfaces                          #
#  enter values between the quotes for the variables above.               #
#  Save the file,                                                         #
#  if you have booted up a new router and selected remove config,         #
#  or you have reset a router with no default config,                     #
#  drag this file into the router window in WinBox.                       #
#                                                                         #
#  In WinBox, open a terminal window and type import,                     #
#  followed by the filename                                               #
#                                                                         #
###########################################################################











































/interface bridge
add comment=defconf name=bridge

/system identity set name=$name

/interface wireless security-profiles
add authentication-types=wpa2-psk eap-methods="" mode=dynamic-keys name=profile2 supplicant-identity="" wpa2-pre-shared-key="$password2"
add authentication-types=wpa2-psk eap-methods="" mode=dynamic-keys name=profile5 supplicant-identity="" wpa2-pre-shared-key="$password5"

## Check for a WLAN1 and set it up depending on frequency band of radio.
	:if ([:len [/interface wireless find name=wlan1]]>0) do={
	:local country [/interface wireless get [find default-name=wlan1 ] country];
	:local cntry [:pick $country 0 13];
	:if ($cntry="united states") do={
	:put "USA Version";} else={/interface wireless set [ find default-name=wlan1 ] country=canada;
	};
	:local freq [/interface wireless get [find default-name=wlan1 ] band];
	:local f  [:pick $freq 0 1];
	:if ($f=5) do={
	/interface wireless
	set [ find default-name=wlan1 ] mode=ap-bridge band=5ghz-a/n/ac \
    disabled=no name=wlan5 frequency=5180 wps-mode=disabled \
    security-profile="profile5" channel-width=20/40/80mhz-Ceee \
    ssid=($ssid5) wireless-protocol=802.11;
	:put "Main WiFi on wlan1 has been setup on 5GHz.";
	} else={
	:if ($f=2) do={
	/interface wireless
	set [ find default-name=wlan1 ] mode=ap-bridge band=2ghz-b/g/n \
    disabled=no name=wlan2.4 frequency=2412 wps-mode=disabled \
    security-profile="profile2" channel-width=20/40mhz-Ce \
    ssid=($ssid2) wireless-protocol=802.11;
	:put "Main WiFi on wlan1 has been setup on 2GHz.";
	}
	}
	}

## Check for a WLAN2 and set it up depending on frequency band of radio.
	:if ([:len [/interface wireless find name=wlan2]]>0) do={
	:local country [/interface wireless get [find default-name=wlan1 ] country];
	:local cntry [:pick $country 0 13];
	:if ($cntry="united states") do={
	:put "USA Version";} else={/interface wireless set [ find default-name=wlan1 ] country=canada;
	};
	:local freq [/interface wireless get [find default-name=wlan2 ] band];
	:local f  [:pick $freq 0 1];
	:if ($f=5) do={
	/interface wireless
	set [ find default-name=wlan2 ] mode=ap-bridge band=5ghz-a/n/ac \
    disabled=no name=wlan5 frequency=5180 wps-mode=disabled \
    security-profile="profile5" channel-width=20/40/80mhz-Ceee \
    ssid=($ssid5) wireless-protocol=802.11;
	:put "Main WiFi on wlan2 has been setup on 5GHz.";
	} else={
	:if ($f=2) do={
	/interface wireless
	set [ find default-name=wlan2 ] mode=ap-bridge band=2ghz-b/g/n \
    disabled=no name=wlan2.4 frequency=2412 wps-mode=disabled \
    security-profile="profile2" channel-width=20/40mhz-Ce \
    ssid=$wifissid wireless-protocol=802.11;
	:put "Main WiFi on wlan2 has been setup on 2GHz.";
	}
	}
	}



/interface bridge port
add bridge=bridge interface=ether1 multicast-router=disabled
:if ([:len [/interface ethernet find name=ether2]]>0) do={/interface bridge port add bridge=bridge interface=ether2}
:if ([:len [/interface ethernet find name=ether3]]>0) do={/interface bridge port add bridge=bridge interface=ether3}
:if ([:len [/interface ethernet find name=ether4]]>0) do={/interface bridge port add bridge=bridge interface=ether4}
:if ([:len [/interface ethernet find name=ether5]]>0) do={/interface bridge port add bridge=bridge interface=ether5}
:if ([:len [/interface wireless find name=wlan5]]>0) do={/interface bridge port add bridge=bridge interface=wlan5}
:if ([:len [/interface wireless find name=wlan2.4]]>0) do={/interface bridge port add bridge=bridge interface=wlan2.4}
:if ([:len [/interface ethernet find name=ether6]]>0) do={/interface bridge port add bridge=bridge interface=ether6}
:if ([:len [/interface ethernet find name=ether7]]>0) do={/interface bridge port add bridge=bridge interface=ether7}
:if ([:len [/interface ethernet find name=ether8]]>0) do={/interface bridge port add bridge=bridge interface=ether8}
:if ([:len [/interface ethernet find name=ether9]]>0) do={/interface bridge port add bridge=bridge interface=ether9}
:if ([:len [/interface ethernet find name=ether10]]>0) do={/interface bridge port add bridge=bridge interface=ether10}

/ip neighbor discovery-settings
set discover-interface-list=!dynamic

/ip address
add address=($ipaddress."/24") comment="default configuration" interface=bridge;

/ip route
add distance=1 dst-address=0.0.0.0/0 gateway=($gatewayip);

/system ntp client
set enabled=yes server-dns-names=0.ca.pool.ntp.org,1.ca.pool.ntp.org

/ip dns set servers=($gatewayip);

 
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Basic Script no longer functioning with V7 RouterOS

Fri Aug 19, 2022 7:36 pm

I see some horrors inside the script,
and a good script for first time device configuration must be pasted on new terminal without errors.

**********************************************

Without check all this horror script, this is not longer compatible with v7
/system ntp client
set enabled=yes server-dns-names=0.ca.pool.ntp.org,1.ca.pool.ntp.org
 
ISPCanada
just joined
Topic Author
Posts: 9
Joined: Mon Aug 08, 2022 6:31 pm

Re: Basic Script no longer functioning with V7 RouterOS

Sun Aug 21, 2022 7:47 pm

The strange bit is, as mentioned in OP, it says it took the script and executed it just fine. Never applies any settings however. This worked just fine pre V7, and the ntp is at the bottom of our script. Trying to figure out if something near the start of the code starts and ends before actually applying any data.
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 18958
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Basic Script no longer functioning with V7 RouterOS

Sun Aug 21, 2022 7:55 pm

You should be using 7.4.1 anyway.
 
ISPCanada
just joined
Topic Author
Posts: 9
Joined: Mon Aug 08, 2022 6:31 pm

Re: Basic Script no longer functioning with V7 RouterOS  [SOLVED]

Mon Aug 22, 2022 11:33 pm

Resolved the issue, goofy problem! when typing import into console, and tab to autofill name, it doesn't close the quotations " FILE NAME.rsc fully, and if I close it manually by typing in the final ", it will correctly take the script.

Who is online

Users browsing this forum: No registered users and 13 guests