# Generat per a:
# RouterOSv5.x
:log info "Unsolclic for 57644-SPDTLaTeuleriaRd1 going to be executed."
#
# Configuration for RouterOSv5.x
# Trasto: 57644-SPDTLaTeuleriaRd1
#
# 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 if you use RouterOSv2.9 , 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=SPDTLaTeuleriaRd1
#
# DNS (client & server cache) zone: 2928
/ip dns set servers=10.138.52.100,10.138.50.194 allow-remote-requests=yes
:delay 1
#
# NTP (client & server cache) zone: 2928
/system ntp client set enabled=yes mode=unicast primary-ntp=10.138.0.2 secondary-ntp=10.138.0.2
:delay 1
#
# Bandwidth-server
/ tool bandwidth-server set enabled=yes authenticate=no allocate-udp-ports-from=2000
#
# SNMP
/snmp community set public addresses=10.0.0.0/8
/snmp set contact="guifi@guifi.net" enabled=yes location="SPDTLaTeuleria" trap-community=public
#
# Guest user
/user
:foreach i in [find group=read] do={/user remove $i;}
add name="guest" group=read address=10.0.0.0/8 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;}
:delay 1
#
# Radio#: 0 SPereTSPDTLTlrRd1CPE0
/interface wireless set wlan1 name="wlan1" \
radio-name="SPereTSPDTLTlrRd1CPE0" mode=station ssid="guifi.net-BellmuntTorelloAP2" \
band="5ghz-a" \
frequency-mode=regulatory-domain country=spain antenna-gain=14 \
dfs-mode=radar-detect \
antenna-mode=ant-a 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: Wan
/ip address
:foreach i in [find interface=wlan1] do={remove $i}
:foreach i in [find address="10.138.192.176/27"] do={remove $i}
/ ip address add address=10.138.192.176/27 network=10.138.192.160 broadcast=10.138.192.191 interface=wlan1 disabled=no
/ routing bgp network
:foreach i in [/routing bgp network find network=10.138.192.160/27] do={/routing bgp network remove $i;}
add network=10.138.192.160/27 synchronize=no disabled=no
/ routing ospf interface
:foreach i in [/routing ospf interface find interface=wlan1] do={/routing ospf interface remove $i;}
add interface=wlan1
/ routing ospf network
:foreach i in [/routing ospf network find network=10.138.192.160/27] do={/routing ospf network remove $i;}
add network=10.138.192.160/27 area=backbone disabled=yes
:delay 1
#
:delay 1
#
# Device has firewall (setting up as CPE)
/ip route add gateway=10.138.192.161
:foreach i in [find address="192.168.1.1/24"] do={remove $i}
/ip address add address=192.168.1.1/24 network=192.168.1.0 broadcast=192.168.1.255 interface=ether1 comment="" disabled=no
:delay 1
/ip pool
:foreach i in [find name=private] do={remove $i}
add name="private" ranges=192.168.1.100-192.168.1.200
:delay 1
/ip dhcp-server
:foreach i in [find name=private] do={remove $i}
add name="private" interface=ether1 lease-time=3d address-pool=private bootp-support=static authoritative=after-2sec-delay disabled=no
:delay 1
/ip dhcp-server network
:foreach i in [find] do={remove $i}
add address=192.168.1.0/24 gateway=192.168.1.1 netmask=24 dns-server=10.138.52.100,10.138.50.194 domain="guifi.net" comment=""
:delay 1
/ip dhcp-client
:foreach i in [find] do={remove $i}
:delay 1
/ip firewall nat
:foreach i in [find] do={remove $i}
:delay 1
add chain=srcnat out-interface=wlan1 action=masquerade comment="" disabled=no
/ip firewall filter
:foreach i in [find] do={remove $i}
add chain=input connection-state=established action=accept comment="Allow Established connections" disabled=no
add chain=input protocol=udp action=accept comment="Allow UDP" disabled=no
add chain=input src-address="192.168.1.0/24" action=accept comment="Allow access to router from known network" disabled=no
add chain=input protocol=tcp dst-port=22 action=accept comment="Allow remote ssh" disabled=no
add chain=input protocol=udp dst-port=161 action=accept comment="Allow snmp" disabled=no
add chain=input protocol=tcp dst-port=8291 action=accept comment="Allow remote winbox" disabled=no
add chain=input protocol=icmp action=accept comment="Allow ping" disabled=no
add chain=forward connection-state=established action=accept comment="Allow already established connections" disabled=no
add chain=forward connection-state=related action=accept comment="Allow related connections" disabled=no
add chain=forward src-address="192.168.1.0/24" action=accept comment="Allow access to router from known network" disabled=no
add chain=input protocol=tcp connection-state=invalid action=drop comment="" disabled=no
add chain=forward protocol=tcp connection-state=invalid action=drop comment="Drop invalid connections" disabled=no
add chain=forward action=drop comment="Drop anything else" disabled=no
add chain=input action=drop comment="Drop anything else" disabled=no
:delay 1
#
:log info "Unsolclic for 57644-SPDTLaTeuleriaRd1 executed."
/