# Generat per a:
# RouterOSv2.9
:log info "Unsolclic for 2324-RodaDipCollLinks going to be executed."
#
# Configuration for RouterOS > 2.9.51 or 3.x
# Trasto: 2324-RodaDipCollLinks
#
# ATENCIÓ: Versió Beta
#
# 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=RodaDipCollLinks
#
# DNS (client & server cache) zone: 2461
/ip dns set primary-dns=10.138.33.130 secondary-dns=10.138.0.2 allow-remote-requests=yes
:delay 1
#
# NTP (client & server cache) zone: 2461
/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="RodaDipColl"
#
# 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 RodaDipCollEnllacMun
/interface wireless set wlan1 name="wlan1" \
radio-name="RodaDipCollEnllacMun" mode=ap-bridge ssid="guifi.net-RodaDipCollEnllacMun" \
band="5ghz" \
frequency-mode=manual-txpower country=spain antenna-gain=0 \
frequency=5500 \
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: wLan/Lan
/ip address
:foreach i in [find address="10.138.34.73/29"] do={remove $i}
/ ip address add address=10.138.34.73/29 network=10.138.34.72 broadcast=10.138.34.79 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.138.34.72/29] do={/routing ospf network remove $i;}
add network=10.138.34.72/29 area=backbone disabled=no
:delay 1
#
# DHCP
/ip dhcp-server lease
:foreach i in [find comment=""] do={remove $i;}
:delay 1
:foreach i in [/ip dhcp-server network find address="10.138.34.72/29"] 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.138.34.78-10.138.34.78
/ip dhcp-server network add address=10.138.34.72/29 gateway=10.138.34.73 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
# 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;}
/ interface wireless wds
add name="wds_RodaDipMuntanyetaLinks" master-interface=wlan1 wds-address=00:0C:42:05:44:31 disabled=no
/ ip address add address=172.25.25.34/30 network=172.25.25.32 broadcast=172.25.25.35 interface=wds_RodaDipMuntanyetaLinks disabled=no comment="wds_RodaDipMuntanyetaLinks"
/ routing ospf interface
:foreach i in [/routing ospf interface find interface=wds_RodaDipMuntanyetaLinks] do={/routing ospf interface remove $i;}
add interface=wds_RodaDipMuntanyetaLinks
/ routing ospf network
:foreach i in [/routing ospf network find network=172.25.25.32/30] do={/routing ospf network remove $i;}
add network=172.25.25.32/30 area=backbone disabled=yes
/ routing bgp peer
:foreach i in [find name=RodaDipMuntanyetaLinks] do={/routing bgp peer remove $i;}
add name="RodaDipMuntanyetaLinks" instance=default remote-address=172.25.25.33 remote-as=2353 \
multihop=no route-reflect=no ttl=1 in-filter=ospf-in out-filter=ospf-out disabled=no
#
:delay 1
#
# Radio#: 1 DipCollRodaAP
/interface wireless set wlan2 name="wlan2" \
radio-name="DipCollRodaAP" mode=ap-bridge ssid="guifi.net-DipCollRodaAP" \
band="2.4ghz-b" \
frequency-mode=manual-txpower country=spain antenna-gain=0 \
frequency=2417 \
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: wLan
/ip address
:foreach i in [find address="10.138.33.193/26"] do={remove $i}
/ ip address add address=10.138.33.193/26 network=10.138.33.192 broadcast=10.138.33.255 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.138.33.192/26] do={/routing ospf network remove $i;}
add network=10.138.33.192/26 area=backbone disabled=no
:delay 1
#
# DHCP
/ip dhcp-server lease
:foreach i in [find comment=""] do={remove $i;}
:delay 1
add address=10.138.33.194 mac-address=00:16:B6:1F:F4:F3 client-id=RodaJRubioRadio2 server=dhcp-wlan2
add address=10.138.33.195 mac-address=34:07:44:65:23:49 client-id=RodaDfvgabiRadio1 server=dhcp-wlan2
add address=10.138.33.196 mac-address=00:18:F8:F2:68:DF client-id=RodaBarriRadio1 server=dhcp-wlan2
add address=10.138.33.197 mac-address=00:16:B6:B7:83:18 client-id=RodaRlazaroRadio1 server=dhcp-wlan2
add address=10.138.33.198 mac-address=00:18:39:AE:64:7C client-id=RodaJordiRadio1 server=dhcp-wlan2
add address=10.138.33.199 mac-address=00:18:39:AE:4B:1E client-id=RodaRaya server=dhcp-wlan2
add address=10.138.33.200 mac-address=ff:ff:ff:ff:ff:ff client-id=RodaFelix server=dhcp-wlan2
add address=10.138.33.201 mac-address=00:16:01:AD:A9:4A client-id=RodaxiclaureRadio1 server=dhcp-wlan2
add address=10.138.33.202 mac-address=ff:ff:ff:ff:ff:ff client-id=RodaMuntadaRadio1 server=dhcp-wlan2
add address=10.138.33.203 mac-address=00:16:01:92:62:0A client-id=RodaAPMurallaRadio1 server=dhcp-wlan2
add address=10.138.33.204 mac-address=00:18:39:C0:68:35 client-id=RodaxrjRadio1 server=dhcp-wlan2
add address=10.138.33.205 mac-address=00:16:01:8C:61:42 client-id=RodaMcarreraRadio1 server=dhcp-wlan2
add address=10.138.33.206 mac-address=ff:ff:ff:ff:ff:ff client-id=RodadomenechfontRadio1 server=dhcp-wlan2
add address=10.138.33.207 mac-address=00:16:01:92:64:5C client-id=RodaxicllopRadio1 server=dhcp-wlan2
add address=10.138.33.208 mac-address=ff:ff:ff:ff:ff:ff client-id=RodaStTeclaRadio1 server=dhcp-wlan2
add address=10.138.33.209 mac-address=00:1A:70:4E:C1:EA client-id=MasiesRHanphreRadio1 server=dhcp-wlan2
add address=10.138.33.210 mac-address=00:1C:10:44:36:69 client-id=RodaMiquelSRadio1 server=dhcp-wlan2
add address=10.138.33.211 mac-address=00:16:01:8C:74:CA client-id=RodaCriviRadio2 server=dhcp-wlan2
add address=10.138.33.212 mac-address=00:1D:0F:B1:7E:67 client-id=MasiesCornellaRadio1 server=dhcp-wlan2
add address=10.138.33.213 mac-address=00:1C:10:14:24:F9 client-id=MasiesRAutetRadio1 server=dhcp-wlan2
add address=10.138.33.214 mac-address=ff:ff:ff:ff:ff:ff client-id=RodaMNogueraRadio1 server=dhcp-wlan2
add address=10.138.33.215 mac-address=00:1E:E5:36:33:17 client-id=RodaIvanRadio1 server=dhcp-wlan2
add address=10.138.33.216 mac-address=00:1D:0F:AE:C3:1E client-id=RodaPuigmalRadio1 server=dhcp-wlan2
add address=10.138.33.217 mac-address=00:1C:10:3C:E4:1D client-id=NiflowersRadio1 server=dhcp-wlan2
add address=10.138.33.218 mac-address=00:1A:70:4E:EE:EF client-id=RodaSGBRadio2 server=dhcp-wlan2
add address=10.138.33.219 mac-address=00:1C:10:14:13:F8 client-id=RodaCrosasRadio1 server=dhcp-wlan2
add address=10.138.33.220 mac-address=00:1C:10:44:31:50 client-id=RodajfontRadio1 server=dhcp-wlan2
add address=10.138.33.221 mac-address=ff:ff:ff:ff:ff:ff client-id=RodaIAumatellRadio1 server=dhcp-wlan2
add address=10.138.33.222 mac-address=00:16:01:F2:31:92 client-id=RodaDGimenezRadio2 server=dhcp-wlan2
add address=10.138.33.223 mac-address=00:0B:6B:2C:3D:30 client-id=RodaCNuria server=dhcp-wlan2
add address=10.138.33.224 mac-address=00:1D:7E:28:0E:1C client-id=RodaRosaARadio1 server=dhcp-wlan2
add address=10.138.33.225 mac-address=00:16:01:F2:31:92 client-id=RodaActerRadio1 server=dhcp-wlan2
add address=10.138.33.226 mac-address=00:16:01:B0:0D:3B client-id=RodaMateoRadio1 server=dhcp-wlan2
add address=10.138.33.227 mac-address=00:16:01:AF:7E:42 client-id=RodaCollsacabraRadio1 server=dhcp-wlan2
add address=10.138.33.228 mac-address=00:16:01:AF:E9:24 client-id=RodaJoaquimARadio1 server=dhcp-wlan2
add address=10.138.33.229 mac-address=00:16:01:B0:59:EB client-id=RodagarciaRadio1 server=dhcp-wlan2
add address=10.138.33.230 mac-address=ff:ff:ff:ff:ff:ff client-id=RodahujigomoRadio1 server=dhcp-wlan2
add address=10.138.33.231 mac-address=00:1D:7E:30:C6:AC client-id=RodaJacintVRadio1 server=dhcp-wlan2
add address=10.138.33.232 mac-address=00:16:01:4D:AC:FB client-id=MasiesRElpujolarRadio1 server=dhcp-wlan2
add address=10.138.33.233 mac-address=00:16:01:8C:55:10 client-id=RodaJoanCarlesGRadio1 server=dhcp-wlan2
add address=10.138.33.234 mac-address=00:1D:7E:4B:6F:D0 client-id=RodaJoseRadio1 server=dhcp-wlan2
add address=10.138.33.235 mac-address=00:1E:E5:36:33:B0 client-id=RodaAngelPerezRadio1 server=dhcp-wlan2
add address=10.138.33.236 mac-address=00:16:01:AF:EC:01 client-id=RodaAlbaPRadio1 server=dhcp-wlan2
add address=10.138.33.237 mac-address=ff:ff:ff:ff:ff:ff client-id=IIBORRARadio1 server=dhcp-wlan2
add address=10.138.33.238 mac-address=ff:ff:ff:ff:ff:ff client-id=RodaMariaTRadio1 server=dhcp-wlan2
add address=10.138.33.239 mac-address=00:1D:7E:FB:7F:F2 client-id=RodaVicencMRadio1 server=dhcp-wlan2
add address=10.138.33.240 mac-address=00:1E:E5:36:3C:F5 client-id=RodaRamonParRadio1 server=dhcp-wlan2
add address=10.138.33.241 mac-address=00:18:39:AE:4C:5B client-id=RodaRussinyol server=dhcp-wlan2
add address=10.138.33.242 mac-address=00:1D:7E:C6:D2:09 client-id=ManlleuSilviaRadio1 server=dhcp-wlan2
add address=10.138.33.243 mac-address=00:16:B6:B0:F5:87 client-id=RodaColleloiRadio1 server=dhcp-wlan2
add address=10.138.33.244 mac-address=00:16:01:F2:29:AB client-id=RodaEFranchRd1 server=dhcp-wlan2
add address=10.138.33.245 mac-address=00:0B:6B:57:F1:BB client-id=RodaInFlamesRd1 server=dhcp-wlan2
add address=10.138.33.246 mac-address=00:16:B6:39:80:D3 client-id=RodaFabregoRd2 server=dhcp-wlan2
add address=10.138.33.247 mac-address=00:1D:7E:C6:D3:65 client-id=RodaArumiRd1 server=dhcp-wlan2
add address=10.138.33.248 mac-address=00:15:6D:A7:C0:C0 client-id=GurbLaComellaRd1 server=dhcp-wlan2
add address=10.138.33.249 mac-address=00:21:29:B5:C8:23 client-id=RodaPepRd1 server=dhcp-wlan2
add address=10.138.33.250 mac-address=00:15:6D:A9:BD:E4 client-id=RodaXavierERd1 server=dhcp-wlan2
add address=10.138.33.252 mac-address=00:15:6D:A9:BB:18 client-id=RodaJosepPRd1 server=dhcp-wlan2
add address=10.138.33.253 mac-address=00:15:6D:A9:BD:95 client-id=RMoleraRd1 server=dhcp-wlan2
:foreach i in [/ip dhcp-server network find address="10.138.33.192/26"] 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.138.33.254-10.138.33.254
/ip dhcp-server network add address=10.138.33.192/26 gateway=10.138.33.193 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=yes
#
:delay 1
#
# Radio#: 2 DipCollEnllacProxy
/interface wireless set wlan3 name="wlan3" \
radio-name="DipCollEnllacProxy" mode=ap-bridge ssid="guifi.net-DipCollEnllacProxy" \
band="5ghz" \
frequency-mode=manual-txpower country=spain antenna-gain=0 \
frequency=5220 \
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: wLan
/ip address
:foreach i in [find address="10.138.34.65/29"] do={remove $i}
/ ip address add address=10.138.34.65/29 network=10.138.34.64 broadcast=10.138.34.71 interface=wlan3 disabled=no
/ routing ospf interface
:foreach i in [/routing ospf interface find interface=wlan3] do={/routing ospf interface remove $i;}
add interface=wlan3
/ routing ospf network
:foreach i in [/routing ospf network find network=10.138.34.64/29] do={/routing ospf network remove $i;}
add network=10.138.34.64/29 area=backbone disabled=no
:delay 1
#
# DHCP
/ip dhcp-server lease
:foreach i in [find comment=""] do={remove $i;}
:delay 1
:foreach i in [/ip dhcp-server network find address="10.138.34.64/29"] do={/ip dhcp-server network remove $i;}
:foreach i in [/ip pool find name=dhcp-wlan3] do={/ip pool remove $i;}
/ip pool add name=dhcp-wlan3 ranges=10.138.34.70-10.138.34.70
/ip dhcp-server network add address=10.138.34.64/29 gateway=10.138.34.65 domain=guifi.net comment=dhcp-wlan3
:foreach i in [/ip dhcp-server find name=dhcp-wlan3] do={/ip dhcp-server remove $i;}
/ip dhcp-server add name=dhcp-wlan3 interface=wlan3 address-pool=dhcp-wlan3 disabled=yes
#
: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_RodaAjuntamenST" master-interface=wlan3 wds-address=00:0B:6B:86:67:88 disabled=no
/ ip address add address=172.25.25.9/30 network=172.25.25.8 broadcast=172.25.25.11 interface=wds_RodaAjuntamenST disabled=no comment="wds_RodaAjuntamenST"
/ routing ospf interface
:foreach i in [/routing ospf interface find interface=wds_RodaAjuntamenST] do={/routing ospf interface remove $i;}
add interface=wds_RodaAjuntamenST
/ routing ospf network
:foreach i in [/routing ospf network find network=172.25.25.8/30] do={/routing ospf network remove $i;}
add network=172.25.25.8/30 area=backbone disabled=no
/ routing bgp peer
:foreach i in [find name=RodaAjuntamenST] do={/routing bgp peer remove $i;}
add name="RodaAjuntamenST" instance=default remote-address=172.25.25.10 remote-as=9340 \
multihop=no route-reflect=no ttl=1 in-filter=ospf-in out-filter=ospf-out disabled=yes
#
:delay 1
#
# Routed device
#
# Altres connexions de cable
:foreach i in [/ip address find address="172.25.25.6/30"] do={/ip address remove $i;}
:delay 1
/ ip address add address=172.25.25.6/30 network=172.25.25.4 broadcast=172.25.25.7 interface=ether2 disabled=no comment=""
/ routing ospf interface
:foreach i in [/routing ospf interface find interface=ether3] do={/routing ospf interface remove $i;}
add interface=ether3
/ routing ospf network
:foreach i in [/routing ospf network find network=172.25.25.28/30] do={/routing ospf network remove $i;}
add network=172.25.25.28/30 area=backbone disabled=no
/ routing bgp peer
:foreach i in [find name=MasiesRColldeRodaOest] do={/routing bgp peer remove $i;}
add name="MasiesRColldeRodaOest" instance=default remote-address=172.25.25.30 remote-as=457 \
multihop=no route-reflect=no ttl=1 in-filter=ospf-in out-filter=ospf-out disabled=yes
:foreach i in [/ip address find address="172.25.25.29/30"] do={/ip address remove $i;}
:delay 1
/ ip address add address=172.25.25.29/30 network=172.25.25.28 broadcast=172.25.25.31 interface=ether3 disabled=no comment="MasiesRColldeRodaOest"
#
# 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.138.34.65 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.138.34.65 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=2324 router-id=10.138.34.65 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.138.34.65 redistribute-connected=as-type-1 redistribute-static=as-type-1 redistribute-bgp=as-type-1
#
:log info "Unsolclic for 2324-RodaDipCollLinks executed."
/