# 2024-07-30 16:54:36 by RouterOS 7.15.2
# software id = WHDA-K050
#
# model = C52iG-5HaxD2HaxD
# serial number = xxxxxxxxxxxxx
/interface bridge
add admin-mac=48:A9:8A:F4:19:D1 auto-mac=no comment=defconf name=bridge
/interface ethernet
set [ find default-name=ether3 ] name=ether3_LAN
/interface wifi
# managed by CAPsMAN
# mode: AP, SSID: wachcio_2.4, channel: 2412/ax/Ce
set [ find default-name=wifi2 ] configuration.manager=capsman .mode=ap \
disabled=no mtu=1500 name=wifi2_4ghz security.authentication-types=\
wpa2-psk,wpa3-psk .ft=yes .ft-over-ds=yes
# managed by CAPsMAN
# mode: AP, SSID: wachcio_5GHz, channel: 5745/ax/Ceee
set [ find default-name=wifi1 ] channel.skip-dfs-channels=10min-cac \
configuration.manager=capsman .mode=ap disabled=no name=wifi5ghz \
security.authentication-types="" .ft=yes .ft-over-ds=yes
/interface vlan
add interface=bridge name=vlan10_IoT vlan-id=10
add interface=bridge name=vlan20_gosc vlan-id=20
add disabled=yes interface=bridge name=vlan100_mgmt vlan-id=100
/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN
/interface wifi datapath
add bridge=bridge disabled=no name=datapath1
/ip pool
add name=default-dhcp ranges=192.168.88.10-192.168.88.254
/system logging action
add name=syslogNG remote=192.168.2.71 target=remote
/disk settings
set auto-media-interface=bridge auto-media-sharing=yes auto-smb-sharing=yes
/interface bridge port
add bridge=bridge comment=defconf interface=ether2
add bridge=bridge comment=defconf interface=ether3_LAN
add bridge=bridge comment=defconf interface=ether4
add bridge=bridge comment=defconf interface=wifi5ghz
add bridge=bridge comment=defconf interface=wifi2_4ghz
add bridge=bridge interface=ether5
/ip firewall connection tracking
set udp-timeout=10s
/ip neighbor discovery-settings
set discover-interface-list=LAN
/interface bridge vlan
add bridge=bridge disabled=yes tagged=ether3_LAN vlan-ids=100
add bridge=bridge tagged=ether3_LAN vlan-ids=10
add bridge=bridge tagged=ether3_LAN vlan-ids=20
/interface list member
add comment=defconf interface=bridge list=LAN
add comment=defconf interface=ether1 list=WAN
/interface wifi cap
set caps-man-addresses=192.168.2.1 discovery-interfaces=bridge enabled=yes \
slaves-datapath=datapath1
/ip address
add address=192.168.10.4/24 interface=vlan10_IoT network=192.168.10.0
add address=192.168.20.4/24 interface=vlan20_gosc network=192.168.20.0
add address=192.168.100.4/24 interface=vlan100_mgmt network=192.168.100.0
/ip dhcp-client
add comment=defconf interface=ether1
add interface=bridge
/ip dhcp-server
add address-pool=default-dhcp disabled=yes interface=bridge name=defconf
/ip dhcp-server network
add address=192.168.88.0/24 comment=defconf dns-server=192.168.88.1 gateway=\
192.168.88.1
/ip dns
set allow-remote-requests=yes
/ip dns static
add address=192.168.88.1 comment=defconf name=router.lan
/ip firewall address-list
add address=88.90.114.186 comment="Created by script" list="Norwegia kwatera"
/ip firewall filter
add action=accept chain=input comment=\
"defconf: accept established,related,untracked" connection-state=\
established,related,untracked
add action=drop chain=input comment="defconf: drop invalid" connection-state=\
invalid
add action=accept chain=input comment="defconf: accept ICMP" protocol=icmp
add action=accept chain=input comment=\
"defconf: accept to local loopback (for CAPsMAN)" dst-address=127.0.0.1
add action=drop chain=input comment="defconf: drop all not coming from LAN" \
in-interface-list=!LAN
add action=accept chain=forward comment="defconf: accept in ipsec policy" \
ipsec-policy=in,ipsec
add action=accept chain=forward comment="defconf: accept out ipsec policy" \
ipsec-policy=out,ipsec
add action=fasttrack-connection chain=forward comment="defconf: fasttrack" \
connection-state=established,related hw-offload=yes
add action=accept chain=forward comment=\
"defconf: accept established,related, untracked" connection-state=\
established,related,untracked
add action=drop chain=forward comment="defconf: drop invalid" \
connection-state=invalid
add action=drop chain=forward comment=\
"defconf: drop all from WAN not DSTNATed" connection-nat-state=!dstnat \
connection-state=new in-interface-list=WAN
add action=accept chain=input comment=\
"defconf: accept established,related,untracked" connection-state=\
established,related,untracked
add action=drop chain=input comment="defconf: drop invalid" connection-state=\
invalid
add action=accept chain=input comment="defconf: accept ICMP" protocol=icmp
add action=accept chain=input comment=\
"defconf: accept to local loopback (for CAPsMAN)" dst-address=127.0.0.1
add action=drop chain=input comment="defconf: drop all not coming from LAN" \
in-interface-list=!LAN
add action=accept chain=forward comment="defconf: accept in ipsec policy" \
ipsec-policy=in,ipsec
add action=accept chain=forward comment="defconf: accept out ipsec policy" \
ipsec-policy=out,ipsec
add action=fasttrack-connection chain=forward comment="defconf: fasttrack" \
connection-state=established,related hw-offload=yes
add action=accept chain=forward comment=\
"defconf: accept established,related, untracked" connection-state=\
established,related,untracked
add action=drop chain=forward comment="defconf: drop invalid" \
connection-state=invalid
add action=drop chain=forward comment=\
"defconf: drop all from WAN not DSTNATed" connection-nat-state=!dstnat \
connection-state=new in-interface-list=WAN
/ip firewall nat
add action=masquerade chain=srcnat comment="defconf: masquerade" \
ipsec-policy=out,none out-interface-list=WAN
add action=masquerade chain=srcnat comment="defconf: masquerade" \
ipsec-policy=out,none out-interface-list=WAN
/ipv6 firewall address-list
add address=::/128 comment="defconf: unspecified address" list=bad_ipv6
add address=::1/128 comment="defconf: lo" list=bad_ipv6
add address=fec0::/10 comment="defconf: site-local" list=bad_ipv6
add address=::ffff:0.0.0.0/96 comment="defconf: ipv4-mapped" list=bad_ipv6
add address=::/96 comment="defconf: ipv4 compat" list=bad_ipv6
add address=100::/64 comment="defconf: discard only " list=bad_ipv6
add address=2001:db8::/32 comment="defconf: documentation" list=bad_ipv6
add address=2001:10::/28 comment="defconf: ORCHID" list=bad_ipv6
add address=3ffe::/16 comment="defconf: 6bone" list=bad_ipv6
/ipv6 firewall filter
add action=accept chain=input comment=\
"defconf: accept established,related,untracked" connection-state=\
established,related,untracked
add action=drop chain=input comment="defconf: drop invalid" connection-state=\
invalid
add action=accept chain=input comment="defconf: accept ICMPv6" protocol=\
icmpv6
add action=accept chain=input comment="defconf: accept UDP traceroute" \
dst-port=33434-33534 protocol=udp
add action=accept chain=input comment=\
"defconf: accept DHCPv6-Client prefix delegation." dst-port=546 protocol=\
udp src-address=fe80::/10
add action=accept chain=input comment="defconf: accept IKE" dst-port=500,4500 \
protocol=udp
add action=accept chain=input comment="defconf: accept ipsec AH" protocol=\
ipsec-ah
add action=accept chain=input comment="defconf: accept ipsec ESP" protocol=\
ipsec-esp
add action=accept chain=input comment=\
"defconf: accept all that matches ipsec policy" ipsec-policy=in,ipsec
add action=drop chain=input comment=\
"defconf: drop everything else not coming from LAN" in-interface-list=\
!LAN
add action=accept chain=forward comment=\
"defconf: accept established,related,untracked" connection-state=\
established,related,untracked
add action=drop chain=forward comment="defconf: drop invalid" \
connection-state=invalid
add action=drop chain=forward comment=\
"defconf: drop packets with bad src ipv6" src-address-list=bad_ipv6
add action=drop chain=forward comment=\
"defconf: drop packets with bad dst ipv6" dst-address-list=bad_ipv6
add action=drop chain=forward comment="defconf: rfc4890 drop hop-limit=1" \
hop-limit=equal:1 protocol=icmpv6
add action=accept chain=forward comment="defconf: accept ICMPv6" protocol=\
icmpv6
add action=accept chain=forward comment="defconf: accept HIP" protocol=139
add action=accept chain=forward comment="defconf: accept IKE" dst-port=\
500,4500 protocol=udp
add action=accept chain=forward comment="defconf: accept ipsec AH" protocol=\
ipsec-ah
add action=accept chain=forward comment="defconf: accept ipsec ESP" protocol=\
ipsec-esp
add action=accept chain=forward comment=\
"defconf: accept all that matches ipsec policy" ipsec-policy=in,ipsec
add action=drop chain=forward comment=\
"defconf: drop everything else not coming from LAN" in-interface-list=\
!LAN
add action=accept chain=input comment=\
"defconf: accept established,related,untracked" connection-state=\
established,related,untracked
add action=drop chain=input comment="defconf: drop invalid" connection-state=\
invalid
add action=accept chain=input comment="defconf: accept ICMPv6" protocol=\
icmpv6
add action=accept chain=input comment="defconf: accept UDP traceroute" port=\
33434-33534 protocol=udp
add action=accept chain=input comment=\
"defconf: accept DHCPv6-Client prefix delegation." dst-port=546 protocol=\
udp src-address=fe80::/10
add action=accept chain=input comment="defconf: accept IKE" dst-port=500,4500 \
protocol=udp
add action=accept chain=input comment="defconf: accept ipsec AH" protocol=\
ipsec-ah
add action=accept chain=input comment="defconf: accept ipsec ESP" protocol=\
ipsec-esp
add action=accept chain=input comment=\
"defconf: accept all that matches ipsec policy" ipsec-policy=in,ipsec
add action=drop chain=input comment=\
"defconf: drop everything else not coming from LAN" in-interface-list=\
!LAN
add action=accept chain=forward comment=\
"defconf: accept established,related,untracked" connection-state=\
established,related,untracked
add action=drop chain=forward comment="defconf: drop invalid" \
connection-state=invalid
add action=drop chain=forward comment=\
"defconf: drop packets with bad src ipv6" src-address-list=bad_ipv6
add action=drop chain=forward comment=\
"defconf: drop packets with bad dst ipv6" dst-address-list=bad_ipv6
add action=drop chain=forward comment="defconf: rfc4890 drop hop-limit=1" \
hop-limit=equal:1 protocol=icmpv6
add action=accept chain=forward comment="defconf: accept ICMPv6" protocol=\
icmpv6
add action=accept chain=forward comment="defconf: accept HIP" protocol=139
add action=accept chain=forward comment="defconf: accept IKE" dst-port=\
500,4500 protocol=udp
add action=accept chain=forward comment="defconf: accept ipsec AH" protocol=\
ipsec-ah
add action=accept chain=forward comment="defconf: accept ipsec ESP" protocol=\
ipsec-esp
add action=accept chain=forward comment=\
"defconf: accept all that matches ipsec policy" ipsec-policy=in,ipsec
add action=drop chain=forward comment=\
"defconf: drop everything else not coming from LAN" in-interface-list=\
!LAN
/snmp
set contact=Wachcio enabled=yes location=Rypin trap-generators=start-trap \
trap-interfaces=all trap-version=3
/system clock
set time-zone-name=Europe/Warsaw
/system identity
set name=MikroTikAX2_ogrod
/system logging
add action=syslogNG topics=info
add action=syslogNG topics=error
add action=syslogNG topics=warning
add action=syslogNG topics=critical
add action=syslogNG topics=e-mail
add action=syslogNG topics=system
add action=syslogNG topics=account
add action=syslogNG topics=async
add action=syslogNG topics=bridge
add action=syslogNG topics=backup
add action=syslogNG topics=dhcp
add action=syslogNG topics=dns
add action=syslogNG topics=fetch
add action=syslogNG topics=firewall
add action=syslogNG topics=health
add action=syslogNG topics=interface
add action=syslogNG topics=manager
add action=syslogNG topics=mqtt
add action=syslogNG topics=ntp
add action=syslogNG topics=pppoe
add action=syslogNG topics=route
add action=syslogNG topics=script
add action=syslogNG disabled=yes topics=snmp
add action=syslogNG topics=ssh
add action=syslogNG topics=timer
add action=syslogNG topics=wireless
add action=syslogNG topics=debug
add action=syslogNG topics=info
add action=syslogNG topics=error
add action=syslogNG topics=warning
add action=syslogNG topics=critical
add action=syslogNG topics=e-mail
add action=syslogNG topics=system
add action=syslogNG topics=account
add action=syslogNG topics=async
add action=syslogNG topics=bridge
add action=syslogNG topics=backup
add action=syslogNG topics=dhcp
add action=syslogNG topics=dns
add action=syslogNG topics=fetch
add action=syslogNG topics=firewall
add action=syslogNG topics=health
add action=syslogNG topics=interface
add action=syslogNG topics=manager
add action=syslogNG topics=mqtt
add action=syslogNG topics=ntp
add action=syslogNG topics=pppoe
add action=syslogNG topics=route
add action=syslogNG topics=script
add action=syslogNG disabled=yes topics=snmp
add action=syslogNG topics=ssh
add action=syslogNG topics=timer
add action=syslogNG topics=wireless
add action=syslogNG topics=debug
/system note
set show-at-login=no
/system ntp client
set enabled=yes
/system ntp server
set enabled=yes manycast=yes multicast=yes use-local-clock=yes
/system ntp client servers
add address=194.146.251.100
add address=150.254.190.51
add address=193.110.137.171
add address=109.206.205.233
add address=158.75.5.245
/system scheduler
add interval=1d name=backup_to_email on-event=email-backup-export policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
start-date=2024-05-06 start-time=01:00:00
add interval=1d name=backup_to_ftp on-event=ftp-backup-export policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
start-date=2024-05-06 start-time=01:15:00
add disabled=yes interval=1d name=check_No_IP on-event=check_No_IP policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
start-date=2024-06-02 start-time=02:15:00
/system script
add dont-require-permissions=no name=email-backup-export owner=wachcio \
policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
source="{\r\
\n:log info \"Script backup configuration and send email\";\r\
\n\r\
\n# Set Filename variables. Do not change this unless you want to edit the\
\_format of the filename.\r\
\n\r\
\n:local date [/system clock get date];\r\
\n:local time [/system clock get time];\r\
\n# Replace \":\" with \"_\" in time to avoid issues with file naming conv\
entions.\r\
\n:local safeTime ([:pick \$time 0 2] . \"_\" . [:pick \$time 3 5] . \"_\"\
\_. [:pick \$time 6 8]);\r\
\n:local filename \"\$[/system identity get name]_\$date_\$safeTime\";\r\
\n:local filenameBackup (\$filename.\".backup\");\r\
\n:local filenameExport (\$filename.\".rsc\");\r\
\n:local files (\$filenameBackup.\",\".\$filenameExport);\r\
\n:local subject \"[BACKUP] MikroTik \$[/system identity get name] backup \
configuration \$date\"; \r\
\n\r\
\n# Create backup file and export the config.\r\
\n\r\
\n:log info \"Create backup file and export the config.\";\r\
\n\r\
\nexport compact file=\"\$filename\";\r\
\n/system backup save name=\"\$filename\";\r\
\n\r\
\n:log info \"File: \$filenameBackup\";\r\
\n:log info \"File: \$filenameExport\";\r\
\n:log info \"Backup Created Successfully\";\r\
\n\r\
\n:delay 5s;\r\
\n\r\
\n/tool e-mail send file=\$files to=\"home-network@wachcio.pl\" subject=\"\
\$subject\";\r\
\n\r\
\n:delay 5s;\r\
\n\r\
\n/file remove \$filenameBackup;\r\
\n/file remove \$filenameExport;\r\
\n:log info \"backup script finished\";\r\
\n}\r\
\n"
add dont-require-permissions=no name=ftp-backup-export owner=wachcio policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="{\
\r\
\n# Config\r\
\n :local server \"192.168.2.5\";\r\
\n :local username \"mikrotik\";\r\
\n :local password \"xxxxxxxx\";\r\
\n:log info \"Script backup configuration and send ftpl\";\r\
\n\r\
\n# Set Filename variables. Do not change this unless you want to edit the\
\_format of the filename.\r\
\n\r\
\n:local date [/system clock get date];\r\
\n:local time [/system clock get time];\r\
\n# Replace \":\" with \"_\" in time to avoid issues with file naming conv\
entions.\r\
\n:local safeTime ([:pick \$time 0 2] . \"_\" . [:pick \$time 3 5] . \"_\"\
\_. [:pick \$time 6 8]);\r\
\n:local filename \"\$[/system identity get name]_\$date_\$safeTime\";\r\
\n:local filenameBackup (\$filename.\".backup\");\r\
\n:local filenameExport (\$filename.\".rsc\");\r\
\n:local files (\$filenameBackup.\",\".\$filenameExport);\r\
\n\r\
\n# Create backup file and export the config.\r\
\n\r\
\n:log info \"Create backup file and export the config.\";\r\
\n\r\
\nexport compact file=\"\$filename\";\r\
\n/system backup save name=\"\$filename\";\r\
\n\r\
\n:log info \"File: \$filenameBackup\";\r\
\n:log info \"File: \$filenameExport\";\r\
\n:log info \"Backup Created Successfully\";\r\
\n\r\
\n:delay 2s;\r\
\n\r\
\n /tool fetch mode=ftp upload=yes user=\"\$username\" password=\"\$passwo\
rd\" src-path=\"\$filenameBackup\" dst-path=\"/Backup config/\$filenameBac\
kup\" address=\"\$server\";\r\
\n:delay 2s;\r\
\n /tool fetch mode=ftp upload=yes user=\"\$username\" password=\"\$passwo\
rd\" src-path=\"\$filenameExport\" dst-path=\"/Backup config/\$filenameExp\
ort\" address=\"\$server\";\r\
\n\r\
\n:delay 5s;\r\
\n\r\
\n/file remove \$filenameBackup;\r\
\n/file remove \$filenameExport;\r\
\n:log info \"backup script finished\";\r\
\n}\r\
\n"
add dont-require-permissions=no name=check_No_IP owner=wachcio policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\
\_Definiowanie zmiennych\r\
\n:local url \"http://xxxxxxxx.wachcio.pl/xxxxxxxxxx.txt\"\r\
\n:local addressListName \"Norwegia kwatera\"\r\
\n\r\
\n# Pobranie zawartosci z URL\r\
\n:local content [/tool fetch url=\$url mode=http dst-path=(\"log.txt\") ;\
\_:delay 2s ; /file get [/file find name=\"log.txt\"] contents]\r\
\n\r\
\n# Wyodrebnienie IP z pobranej zawartosci\r\
\n:local newIP [:pick \$content 0 [:find \$content \";\"]]\r\
\n\r\
\n# Sprawdzenie, czy lista adres\F3w istnieje\r\
\n:if ([:len [/ip firewall address-list find list=\$addressListName]] > 0)\
\_do={\r\
\n # Pobranie identyfikatora istniejacej reguly\r\
\n :local currentID [/ip firewall address-list find list=\$addressListN\
ame]\r\
\n \r\
\n # Pobranie obecnego adresu z listy\r\
\n :local currentIP [/ip firewall address-list get \$currentID address]\
\r\
\n\r\
\n # Sprawdzenie, czy adresy sie zgadzaja\r\
\n :if (\$currentIP != \$newIP) do={\r\
\n # Edycja istniejacej reguly\r\
\n /ip firewall address-list set \$currentID address=\$newIP commen\
t=\"Updated by script\"\r\
\n :log info \"Address list updated: \$newIP\"\r\
\n } else={\r\
\n :log info \"Address list is up-to-date: \$currentIP\"\r\
\n }\r\
\n} else={\r\
\n # Jesli lista adres\F3w nie istnieje, dodanie nowego adresu\r\
\n /ip firewall address-list add list=\$addressListName address=\$newIP\
\_comment=\"Created by script\"\r\
\n :log info \"Address list created: \$newIP\"\r\
\n}\r\
\n\r\
\n# Usuniecie tymczasowego pliku\r\
\n/file remove log.txt\r\
\n"
/tool e-mail
set from=<admin@wachcio.pl> port=465 server=wachcio.atthost24.pl tls=yes \
user=admin@wachcio.pl
/tool mac-server
set allowed-interface-list=LAN
/tool mac-server mac-winbox
set allowed-interface-list=LAN