# Generat per a:
# RouterOSv2.9
:log info "Unsolclic for 3066-SFSAjuntamentST1 going to be executed."
#
# Configuration for RouterOS > 2.9.51 or 3.9
# Trasto: 3066-SFSAjuntamentST1
#
# WARNING: Beta version
#
# Methods to upload/execute this script:
# 1.-As a script. Upload this output as a script either with:
#     a.Winbox (with Linux, wine required)
#     b.Terminal (telnet, ssh...)
#    Then execute the script with:
#      > /system script run script_name
# 2.-Fitxer importat:
#     Desa aquesta "sortida" a un fitxer, després puja'l al router
#     fent servir FTP amb un nom de l'estil "script_name.rsc".
#     (note, l'extensió ".rsc" es un requisit)
#     Executa el fitxer importat amb la comanda:
#      > /import script_name
# 3.-Telnet copia i enganxar:
#     Open a terminal session, and cut&paste this output
#     directly on the terminal input.
#
# Notes:
# -routing-test package is required, be sure you have it enabled at system packages
# -wlans should be enabled manually, be sure to set the correct antenna (a or b)
#   according in how did you connect the cable to the miniPCI. Keep the
#   power at the minimum possible and check the channel.
# -The script doesn't reset the router, you might have to do it manually
# -You must have write access to the router
# -MAC access (winbox, MAC telnet...) method is recommended
#   (the script reconfigures some IP addresses, so communication can be lost)
# -No changes are done in user passwords on the device
# -A Read Only guest account with no password will be created to allow guest access
#   to the router with no danger of damage but able to see the config.
# -Be sure that all packages are activated.
# -Don't run the script from telnet and being connected through an IP connection at
#   the wLan/Lan interface: This interface will be destroyed during the script.
#
/ system identity set name=SFSAjuntamentST1
#
# DNS (client & server cache) zone: 3191
/ip dns set primary-dns=10.138.120.66 secondary-dns=10.138.0.2 allow-remote-requests=yes
:delay 1
#
# NTP (client & server cache) zone: 3191
/system ntp client set enabled=yes mode=unicast primary-ntp=10.138.15.130
/system ntp server set manycast=no enabled=yes
:delay 1
#
# Bandwidth-server
/ tool bandwidth-server set enabled=yes authenticate=no allocate-udp-ports-from=2000
#
# SNMP
/snmp set contact="guifi@guifi.net" enabled=yes location="SFSAjuntament"
#
# Guest user
/user
:foreach i in [find group=read] do={/user remove $i;}
add name="guest" group=read address=0.0.0.0/0 comment="" disabled=no
#
# Graphing
/tool graphing interface add
# Remove current wLan/Lan bridge if exists
:foreach i in [/interface bridge find name=wLan/Lan] \
do={:foreach i in [/interface bridge port find bridge=wLan/Lan] \
do={/interface bridge port remove $i; \
:foreach i in [/ip address find interface=wLan/Lan] \
do={/ip address remove $i;};};
/interface bridge remove $i;}
# Construct main bridge on wlan1 & ether1
/ interface bridge
add name="wLan/Lan"
/ interface bridge port
add interface=ether1 bridge=wLan/Lan
add interface=wlan1 bridge=wLan/Lan
:delay 1
#
# Radio#: 0 SFSAjunAP1
/interface wireless set wlan1 name="wlan1" \
radio-name="SFSAjunAP1" mode=ap-bridge ssid="guifi.net-SFSAjunAP1" \
band="2.4ghz-b" \
frequency-mode=manual-txpower country=spain antenna-gain=0 \
frequency=2412 \
dfs-mode=none \
wds-mode=static wds-default-bridge=none wds-default-cost=100 \
wds-cost-range=50-150 wds-ignore-ssid=yes hide-ssid=no
:delay 1
# Type: wds/p2p
# Remove all existing wds interfaces
:foreach i in [/interface wireless wds find master-interface=wlan1] \
do={:foreach n in [/interface wireless wds get $i name] \
do={:foreach inum in [/ip address find interface=$n] \
do={/ip address remove $inum;};}; \
/interface wireless wds remove $i;}
#
:delay 1
# Type: wLan/Lan
/ip address
:foreach i in [find address="10.228.0.1/27"] do={remove $i}
/ ip address add address=10.228.0.1/27 network=10.228.0.0 broadcast=10.228.0.31 interface=wLan/Lan disabled=no
/ routing ospf interface
:foreach i in [/routing ospf interface find interface=wLan/Lan] do={/routing ospf interface remove $i;}
add interface=wLan/Lan
/ routing ospf network
:foreach i in [/routing ospf network find network=10.228.0.0/27] do={/routing ospf network remove $i;}
add network=10.228.0.0/27 area=backbone disabled=no
:delay 1
#
# DHCP
/ip dhcp-server lease
:foreach i in [find comment=""] do={remove $i;}
:delay 1
add address=10.228.0.2 mac-address=00:15:6D:A6:41:63 client-id=SFSCollRadio1 server=dhcp-wLan/Lan
add address=10.228.0.3 mac-address=00:18:F8:E5:FA:F4 client-id=SFSsantamariaRadio1 server=dhcp-wLan/Lan
add address=10.228.0.4 mac-address=00:18:F8:E5:FA:B8 client-id=SFSFabriRadio1 server=dhcp-wLan/Lan
add address=10.228.0.5 mac-address=00:1A:70:4F:42:A2 client-id=SFSCalEstevaRadio1 server=dhcp-wLan/Lan
add address=10.228.0.6 mac-address=00:18:F8:F1:FD:E7 client-id=SFSCalMinguRadio1 server=dhcp-wLan/Lan
add address=10.228.0.7 mac-address=00:18:F8:F1:FE:26 client-id=SFSCANONGERadio1 server=dhcp-wLan/Lan
add address=10.228.0.8 mac-address=00:18:F8:F1:FE:80 client-id=SFSMaximRadio1 server=dhcp-wLan/Lan
add address=10.228.0.9 mac-address=00:18:F8:E5:F7:31 client-id=Lacucutera server=dhcp-wLan/Lan
add address=10.228.0.10 mac-address=00:16:01:7F:9A:24 client-id=SFSCalSegarretaRadio1 server=dhcp-wLan/Lan
add address=10.228.0.11 mac-address=00:1A:70:4F:44:09 client-id=SFSametllerRadio1 server=dhcp-wLan/Lan
add address=10.228.0.12 mac-address=00:16:01:97:47:3A client-id=SFSForjaCapellaRadio1 server=dhcp-wLan/Lan
add address=10.228.0.13 mac-address=00:1A:70:4F:61:4A client-id=SFSTeixitsTornerRadio1 server=dhcp-wLan/Lan
add address=10.228.0.14 mac-address=00:1A:70:47:B9:9C client-id=SFSmxocolata server=dhcp-wLan/Lan
add address=10.228.0.15 mac-address=00:1A:70:4F:64:71 client-id=SFSTomasAcostaRadio1 server=dhcp-wLan/Lan
add address=10.228.0.16 mac-address=00:1A:70:47:B5:A9 client-id=SFSMennaRadio1 server=dhcp-wLan/Lan
add address=10.228.0.17 mac-address=00:1A:70:47:B6:15 client-id=SFSLaCasetaRadio1 server=dhcp-wLan/Lan
add address=10.228.0.18 mac-address=00:1A:70:47:B5:0D client-id=SFSCalMongetRadio1 server=dhcp-wLan/Lan
add address=10.228.0.19 mac-address=00:16:01:8C:78:8E client-id=SFScalfeliuRadio1 server=dhcp-wLan/Lan
add address=10.228.0.20 mac-address=00:16:01:97:A2:48 client-id=SFSGaleaOllerRadio1 server=dhcp-wLan/Lan
add address=10.228.0.21 mac-address=00:1A:70:47:B4:EF client-id=SFSMateoRadio1 server=dhcp-wLan/Lan
add address=10.228.0.22 mac-address=00:1A:70:4E:FF:10 client-id=SFSElVinyesRadio1 server=dhcp-wLan/Lan
add address=10.228.0.23 mac-address=00:18:39:D3:9A:2F client-id=SFSPedragosaCrespiRadio1 server=dhcp-wLan/Lan
add address=10.228.0.24 mac-address=00:1C:10:14:0D:9B client-id=SFSLesComesOlivesRadio1 server=dhcp-wLan/Lan
add address=10.228.0.25 mac-address=00:1C:10:88:76:79 client-id=SFSCalPastisserRadio1 server=dhcp-wLan/Lan
add address=10.228.0.26 mac-address=00:1D:7E:28:17:45 client-id=SFSJoanRubioRadio1 server=dhcp-wLan/Lan
add address=10.228.0.27 mac-address=00:1D:7E:28:09:39 client-id=SFSMartaRadio1 server=dhcp-wLan/Lan
add address=10.228.0.28 mac-address=00:1A:70:4E:E7:EE client-id=SFSPaquiRadio1 server=dhcp-wLan/Lan
add address=10.228.0.29 mac-address=00:16:01:F2:40:BD client-id=SFSBallusRadio1 server=dhcp-wLan/Lan
:foreach i in [/ip dhcp-server network find address="10.228.0.0/27"] do={/ip dhcp-server network remove $i;}
:foreach i in [/ip pool find name=dhcp-wLan/Lan] do={/ip pool remove $i;}
/ip pool add name=dhcp-wLan/Lan ranges=10.228.0.30-10.228.0.30
/ip dhcp-server network add address=10.228.0.0/27 gateway=10.228.0.1 domain=guifi.net comment=dhcp-wLan/Lan
:foreach i in [/ip dhcp-server find name=dhcp-wLan/Lan] do={/ip dhcp-server remove $i;}
/ip dhcp-server add name=dhcp-wLan/Lan interface=wLan/Lan address-pool=dhcp-wLan/Lan disabled=yes
#
:delay 1
#
# Radio#: 1 SFSAjunAP2
/interface wireless set wlan2 name="wlan2" \
radio-name="SFSAjunAP2" mode=ap-bridge ssid="guifi.net-SFSAjunAP2" \
band="2.4ghz-b" \
frequency-mode=manual-txpower country=spain antenna-gain=0 \
frequency=2432 \
dfs-mode=none \
wds-mode=static wds-default-bridge=none wds-default-cost=100 \
wds-cost-range=50-150 wds-ignore-ssid=yes hide-ssid=no
:delay 1
# Type: wds/p2p
# Remove all existing wds interfaces
:foreach i in [/interface wireless wds find master-interface=wlan2] \
do={:foreach n in [/interface wireless wds get $i name] \
do={:foreach inum in [/ip address find interface=$n] \
do={/ip address remove $inum;};}; \
/interface wireless wds remove $i;}
#
:delay 1
# Type: wLan
/ip address
:foreach i in [find address="10.228.0.33/27"] do={remove $i}
/ ip address add address=10.228.0.33/27 network=10.228.0.32 broadcast=10.228.0.63 interface=wlan2 disabled=no
/ routing ospf interface
:foreach i in [/routing ospf interface find interface=wlan2] do={/routing ospf interface remove $i;}
add interface=wlan2
/ routing ospf network
:foreach i in [/routing ospf network find network=10.228.0.32/27] do={/routing ospf network remove $i;}
add network=10.228.0.32/27 area=backbone disabled=no
:delay 1
#
# DHCP
/ip dhcp-server lease
:foreach i in [find comment=""] do={remove $i;}
:delay 1
add address=10.228.0.34 mac-address=00:18:F8:E5:F6:E0 client-id=SFSBarComasRadio1 server=dhcp-wlan2
add address=10.228.0.35 mac-address=00:18:F8:F2:68:EE client-id=SFSJoanRRadio1 server=dhcp-wlan2
add address=10.228.0.36 mac-address=00:18:F8:F1:D4:EC client-id=SFSBoschCasalsRadio1 server=dhcp-wlan2
add address=10.228.0.37 mac-address=00:1A:70:4F:66:1E client-id=LaTorrePuigsaulensRadio1 server=dhcp-wlan2
add address=10.228.0.38 mac-address=00:18:F8:F1:D5:58 client-id=SFSRomeroRadio1 server=dhcp-wlan2
add address=10.228.0.39 mac-address=00:18:F8:F1:D3:8D client-id=SFSAnissaRadio1 server=dhcp-wlan2
add address=10.228.0.40 mac-address=00:1D:7E:28:1A:43 client-id=SFSCalPeiretRadio1 server=dhcp-wlan2
add address=10.228.0.41 mac-address=00:1A:70:4F:1E:75 client-id=SFSRectoriaRadio1 server=dhcp-wlan2
add address=10.228.0.42 mac-address=00:18:F8:E5:FC:5C client-id=SFSCalSaleroRadio1 server=dhcp-wlan2
add address=10.228.0.43 mac-address=00:1A:70:47:B5:31 client-id=SFScalGallRadio1 server=dhcp-wlan2
add address=10.228.0.44 mac-address=00:1A:70:47:B8:88 client-id=SFSMasCastellotRadio1 server=dhcp-wlan2
add address=10.228.0.45 mac-address=00:1C:10:14:11:91 client-id=SFSPladeMoixonsRadio1 server=dhcp-wlan2
add address=10.228.0.46 mac-address=00:1A:70:47:B5:E8 client-id=SFSPisosRadio2 server=dhcp-wlan2
add address=10.228.0.47 mac-address=00:16:01:ED:F7:62 client-id=SFSOriolsRadio1 server=dhcp-wlan2
add address=10.228.0.48 mac-address=00:1D:7E:ED:26:DA client-id=SFSIvanPisosRadio1 server=dhcp-wlan2
add address=10.228.0.51 mac-address=00:18:F8:F1:FE:1D client-id=SFSCalPeucurtRadio1 server=dhcp-wlan2
:foreach i in [/ip dhcp-server network find address="10.228.0.32/27"] do={/ip dhcp-server network remove $i;}
:foreach i in [/ip pool find name=dhcp-wlan2] do={/ip pool remove $i;}
/ip pool add name=dhcp-wlan2 ranges=10.228.0.57-10.228.0.62
/ip dhcp-server network add address=10.228.0.32/27 gateway=10.228.0.33 domain=guifi.net comment=dhcp-wlan2
:foreach i in [/ip dhcp-server find name=dhcp-wlan2] do={/ip dhcp-server remove $i;}
/ip dhcp-server add name=dhcp-wlan2 interface=wlan2 address-pool=dhcp-wlan2 disabled=no
#
:delay 1
#
# Radio#: 2 SFSAjuntOlost
/interface wireless set wlan3 name="wlan3" \
radio-name="SFSAjuntOlost" mode=ap-bridge ssid="guifi.net-SFSAjuntOlost" \
band="5ghz" \
frequency-mode=manual-txpower country=spain antenna-gain=0 \
frequency=5300 \
dfs-mode=none \
wds-mode=static wds-default-bridge=none wds-default-cost=100 \
wds-cost-range=50-150 wds-ignore-ssid=yes hide-ssid=no
:delay 1
# Type: wds/p2p
# Remove all existing wds interfaces
:foreach i in [/interface wireless wds find master-interface=wlan3] \
do={:foreach n in [/interface wireless wds get $i name] \
do={:foreach inum in [/ip address find interface=$n] \
do={/ip address remove $inum;};}; \
/interface wireless wds remove $i;}
/ interface wireless wds
add name="wds_OLSTDipST1" master-interface=wlan3 wds-address=00:0C:42:0C:1A:F0 disabled=no
/ ip address add address=172.25.128.5/30 network=172.25.128.4 broadcast=172.25.128.7 interface=wds_OLSTDipST1 disabled=no comment="wds_OLSTDipST1"
/ routing ospf interface
:foreach i in [/routing ospf interface find interface=wds_OLSTDipST1] do={/routing ospf interface remove $i;}
add interface=wds_OLSTDipST1
/ routing ospf network
:foreach i in [/routing ospf network find network=172.25.128.4/30] do={/routing ospf network remove $i;}
add network=172.25.128.4/30 area=backbone disabled=yes
/ routing bgp peer
:foreach i in [find name=OLSTDipST1] do={/routing bgp peer remove $i;}
add name="OLSTDipST1" instance=default remote-address=172.25.128.6 remote-as=3061 \
multihop=no route-reflect=no ttl=1 in-filter=ospf-in out-filter=ospf-out disabled=no
#
:delay 1
#
# Routed device
#
# Altres connexions de cable
/ routing ospf interface
:foreach i in [/routing ospf interface find interface=ether2] do={/routing ospf interface remove $i;}
add interface=ether2
/ routing ospf network
:foreach i in [/routing ospf network find network=172.25.128.8/30] do={/routing ospf network remove $i;}
add network=172.25.128.8/30 area=backbone disabled=yes
/ routing bgp peer
:foreach i in [find name=SFSAjuntamentST2] do={/routing bgp peer remove $i;}
add name="SFSAjuntamentST2" instance=default remote-address=172.25.128.9 remote-as=3188 \
multihop=no route-reflect=no ttl=1 in-filter=ospf-in out-filter=ospf-out disabled=no
:foreach i in [/ip address find address="172.25.128.10/30"] do={/ip address remove $i;}
:delay 1
/ ip address add address=172.25.128.10/30 network=172.25.128.8 broadcast=172.25.128.11 interface=ether2 disabled=no comment="SFSAjuntamentST2"
#
# Internal addresses NAT
:foreach i in [/ip firewall nat find src-address="172.25.0.0/16"] do={/ip firewall nat remove $i;}
:foreach i in [/ip firewall nat find src-address="192.168.0.0/16"] do={/ip firewall nat remove $i;}
/ip firewall nat
add chain=srcnat src-address="192.168.0.0/16" dst-address=!192.168.0.0/16 action=src-nat to-addresses=10.228.0.33 to-ports=0-65535 comment="" disabled=no
add chain=srcnat src-address="172.25.0.0/16" dst-address=!172.25.0.0/16 protocol=!ospf action=src-nat to-addresses=10.228.0.33 to-ports=0-65535 comment="" disabled=no
#
# Enrutament BGP
# Filtres BGP i OSPF
:foreach i in [/routing filter find chain=ospf-in] do={/routing filter remove $i;}
:foreach i in [/routing filter find chain=ospf-out] do={/routing filter remove $i;}
/ routing filter
add chain=ospf-out prefix=10.0.0.0/8 prefix-length=8-32 invert-match=no action=accept comment="" disabled=no
add chain=ospf-out invert-match=no action=discard comment="" disabled=no
add chain=ospf-in prefix=10.0.0.0/8 prefix-length=8-32 invert-match=no action=accept comment="" disabled=no
add chain=ospf-in invert-match=no action=reject comment="" disabled=no
#
# Instància BGP
/ routing bgp instance
set default name="default" as=3066 router-id=10.228.0.33 redistribute-static=yes \
redistribute-connected=yes redistribute-rip=yes redistribute-ospf=yes \
redistribute-other-bgp=yes out-filter=ospf-out \
client-to-client-reflection=yes comment="" disabled=no
#
# Enrutament OSPF
/routing ospf set router-id=10.228.0.33 redistribute-connected=as-type-1 redistribute-static=as-type-1 redistribute-bgp=as-type-1
#
:log info "Unsolclic for 3066-SFSAjuntamentST1 executed."
/