# feb/02/2023 07:50:01 by RouterOS 7.7
# software id = Q2GE-GEVI
#
# model = RB4011iGS+
# serial number = xxxxxxxxxx
/interface bridge
add admin-mac=08:xx:xx:5x:xx:xx auto-mac=no comment=defconf name=bridge
/interface ethernet
set [ find default-name=ether2 ] advertise=1000M-full
set [ find default-name=ether3 ] speed=100Mbps
set [ find default-name=ether10 ] poe-out=off
/interface wireguard
add listen-port=13231 mtu=1420 name=wireguard-RW
add listen-port=13131 mtu=1420 name=wireguard-STS-EOIP
/interface eoip
add local-address=172.16.0.1 mac-address=FE:F5:xx:xx:xx:xx name=\
eoip-tunnel-over-wg-sts remote-address=172.16.0.2 tunnel-id=0
/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/ip pool
add name=dhcp ranges=192.168.2.10-192.168.2.99
/ip dhcp-server
add address-pool=dhcp interface=bridge name=dhcp1
/port
set 0 name=serial0
set 1 name=serial1
/system logging action
add name=login target=memory
/interface bridge port
add bridge=bridge comment=defconf interface=ether2
add bridge=bridge comment=defconf interface=ether3
add bridge=bridge comment=defconf interface=ether4
add bridge=bridge comment=defconf interface=ether5
add bridge=bridge comment=defconf interface=ether6
add bridge=bridge comment=defconf interface=ether7
add bridge=bridge comment=defconf interface=ether8
add bridge=bridge comment=defconf interface=ether9
add bridge=bridge comment=defconf interface=ether10
add bridge=bridge comment=defconf disabled=yes interface=sfp-sfpplus1
add bridge=bridge interface=ether1
add bridge=bridge interface=eoip-tunnel-over-wg-sts
/ip neighbor discovery-settings
set discover-interface-list=LAN
/interface detect-internet
set detect-interface-list=WAN lan-interface-list=LAN
/interface list member
add comment=defconf interface=bridge list=LAN
add interface=sfp-sfpplus1 list=WAN
add interface=wireguard-RW list=LAN
/interface wireguard peers
add allowed-address=192.168.100.3/32 comment="+++ PORTATIL ERNESTO" \
endpoint-port=13231 interface=wireguard-RW public-key=\
"896l0zzzzzzzzzzzzzzzzzzzucAkLvHByI="
add allowed-address=192.168.100.2/32 comment="+++ IPHONE ERNESTO" \
endpoint-port=13231 interface=wireguard-RW public-key=\
"Yv8ZzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzpiHmQ="
add allowed-address=192.168.100.4/32 comment="+++ IPAD ERNESTO pendiente" \
endpoint-port=13231 interface=wireguard-RW public-key=\
"Jw7zzzzzzzzzzzzzzzzzzzzzzzzzzzzzZJUQBo="
add allowed-address=192.168.100.5/32 comment="+++ IPHONE LEONOR" \
endpoint-port=13231 interface=wireguard-RW public-key=\
"NCvzzzzzzzzzzzzzzzzzzzzzzzzzzzzTdMMAXc="
add allowed-address=172.16.0.2/32 comment="+++ CONEXION BENICASSIM" \
endpoint-address=279zzzzzzzz.sn.mynetname.net endpoint-port=13131 \
interface=wireguard-STS-EOIP public-key=\
"Kq+a7lzzzzzzzzzzzzzzzzzzz3rx/5+B4="
/ip address
add address=192.168.2.1/24 comment=defconf interface=bridge network=\
192.168.2.0
add address=192.168.100.1/24 comment="WIREGUARD ROADWARRIOR " interface=\
wireguard-RW network=192.168.100.0
add address=172.16.0.1/30 comment="+++ WIREGUARD SITE TO SITE" interface=\
wireguard-STS-EOIP network=172.16.0.0
/ip cloud
set ddns-enabled=yes ddns-update-interval=5m
/ip dhcp-client
add comment=defconf interface=sfp-sfpplus1
/ip dhcp-server lease
add address=192.168.2.104 comment=\
" ++++++++++++ RASPERRY PI SERVER 2\AA PLANTA" mac-address=\
B8:27:zz:zz:zz:zz server=dhcp1
add address=192.168.2.100 comment=\
" ++++++++++++ DECODIFICADOR SATELITE GIGABLUE" mac-address=\
AC:DB:zz:zz:zz:zz server=dhcp1
add address=192.168.2.101 comment=" ++++++++++++ RASPBERRY PI USADA EN TV " \
mac-address=DC:A6:zz:zz:zz:zz server=dhcp1
add address=192.168.2.102 comment=" ++++++++++++ GOOGLE MESH " mac-address=\
CC:F4:zz:zz:zz:zz server=dhcp1
add address=192.168.2.103 comment=" ++++++++++++ SAMSUNG 75\" COMEDOR" \
mac-address=00:C3:zz:zz:zz:zz server=dhcp1
add address=192.168.2.106 comment=" ++++++++++++ PORTATIL LINUX " \
mac-address=00:1E:zz:zz:zz:zz server=dhcp1
add address=192.168.2.105 comment=" ++++++++++++ IMAC" mac-address=\
C8:2A:zz:zz:zz:zz server=dhcp1
add address=192.168.2.107 comment=" ++++++++++++ SAMSUNG 48\" SEGUNDA PLANTA" \
mac-address=50:85:zz:zz:zz:zz server=dhcp1
add address=192.168.2.108 comment=" ++++++++++++ SURFACE TRABAJO" \
mac-address=A0:CE:zz:zz:zz:zz server=dhcp1
add address=192.168.2.109 comment="+++++++++++++ PLAYSTATION 4" mac-address=\
78:C8:zz:zz:zz:zz server=dhcp1
add address=192.168.2.110 comment="+++++++++++++ DANKO-DEBIAN" mac-address=\
64:31:zz:zz:zz:zz server=dhcp1
/ip dhcp-server network
add address=192.168.2.0/24 comment=defconf dns-server=\
192.168.2.1,192.168.0.1,8.8.8.8 gateway=192.168.2.1 netmask=24
/ip dns
set allow-remote-requests=yes
/ip dns static
add address=192.168.2.1 comment=defconf name=router.lan
add address=192.168.2.104 disabled=yes name=emiralles.zzz.zzz
add address=217.130.174.161 name=ims.vodafone.es
/ip firewall address-list
add address=dzzzzzzzzzz.sn.mynetname.net list=WANIP
add address=195.239.75.235 list=ssh_blacklist
add address=188.133.187.50 list=ssh_blacklist
add address=5.44.60.139 list=ssh_blacklist
add address=192.241.212.202 list=ssh_blacklist
add address=64.62.197.155 list=ssh_blacklist
add address=103.156.90.29 list=ssh_blacklist
add address=183.107.45.127 list=ssh_blacklist
add address=141.98.11.57 list=ssh_blacklist
add address=190.215.169.136 list=ssh_blacklist
add address=64.62.197.134 list=IPSEC
add address=64.62.197.215 list=IPSEC
add address=184.105.247.247 list=IPSEC
add address=64.62.197.36 list=IPSEC
add address=64.62.197.59 list=IPSEC
add address=197.245.79.51 list=IPSEC
add address=184.105.247.243 list=IPSEC
add address=65.49.20.107 list=IPSEC
add address=65.49.20.91 list=IPSEC
add address=173.239.224.40 list=IPSEC
add address=184.105.247.254 list=IPSEC
add address=216.218.206.86 list=IPSEC
add address=172.98.33.250 list=IPSEC
add address=184.105.139.90 list=IPSEC
add address=65.49.20.121 list=IPSEC
add address=64.62.197.147 list=IPSEC
/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="Bloqueo Total SSH" dst-port=22 protocol=\
tcp
add action=drop chain=input comment=\
"block address that reach maximum login attempts" src-address-list=\
login_failure
add action=accept chain=input comment="Allow WIREGUARD RW" dst-port=13231 \
protocol=udp
add action=accept chain=input comment="Allow WIREGUARD RW traffic" \
src-address-list=192.168.100.0/24
add action=accept chain=input comment="OpenVPN Port TCP/UDP" disabled=yes \
dst-port=1194 protocol=tcp
add action=accept chain=input comment="OpenVPN Port TCP/UDP" disabled=yes \
dst-port=1194 protocol=udp
add action=add-src-to-address-list address-list=BlackList \
address-list-timeout=14w2d chain=input comment=\
"F2B SSH: Login Failure -> BlackList" connection-state=established \
disabled=yes dst-port=22 packet-size=304 protocol=tcp
add action=add-src-to-address-list address-list=ssh_blacklist \
address-list-timeout=14w2d chain=input comment=\
"drop ssh brute forcers ---> Segundo intento Pasa a lista negra" \
connection-state=new disabled=yes dst-port=22 protocol=tcp \
src-address-list=ssh_stage1
add action=add-src-to-address-list address-list=ssh_stage1 \
address-list-timeout=20m chain=input comment=\
"drop ssh brute forcers ---> Primer intento Pasa a STAGE 1" \
connection-state=new disabled=yes dst-port=22 protocol=tcp
add action=accept chain=input comment=\
"WIREGUARD CON BENICASSIM vpn: allow wireguard-STS-EOIP" dst-port=13131 \
protocol=udp
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=jump chain=output comment=\
"F2B Winbox: Jump to Fail2Ban-Destination-IP chain" content=\
"invalid user name or password" jump-target=Fail2Ban-Destination-IP \
protocol=tcp src-port=8291
add action=add-dst-to-address-list address-list=BlackList \
address-list-timeout=14w2d chain=Fail2Ban-Destination-IP comment=\
"F2B Winbox LoginFailure01 --> BlackList" dst-address-list=LoginFailure01
add action=add-dst-to-address-list address-list=LoginFailure01 \
address-list-timeout=5m chain=Fail2Ban-Destination-IP comment=\
"FB Winbox 1 Attempt --> LoginFailure01"
add action=add-dst-to-address-list address-list=BlackList \
address-list-timeout=14w2d chain=output comment=\
"F2B Web: Login Failure -> BlackList" connection-state=established \
content="Error 403" protocol=tcp src-port=80
add action=add-dst-to-address-list address-list=BlackList \
address-list-timeout=14w2d chain=output comment=\
"F2B IPSEC: Login Failure -> BlackList" connection-state=established \
content="phase1 negotiation failed"
/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="HAIRPIN NAT" dst-address=\
192.168.2.0/24 src-address=192.168.2.0/24
add action=dst-nat chain=dstnat comment="Https EXTERNO" dst-port=443 \
in-interface-list=WAN protocol=tcp to-addresses=192.168.2.104 to-ports=\
443
add action=dst-nat chain=dstnat comment="HAIRPIN PORT 443" dst-address-list=\
WANIP dst-port=443 protocol=tcp to-addresses=192.168.2.104 to-ports=443
add action=dst-nat chain=dstnat comment="HAIRPIN PORT 80" disabled=yes \
dst-address-list=WANIP dst-port=80 protocol=tcp to-addresses=\
192.168.2.104 to-ports=80
add action=dst-nat chain=dstnat comment="TRANSMISSION CONNECT" dst-port=51413 \
in-interface-list=WAN protocol=tcp to-addresses=192.168.2.104 to-ports=\
51413
add action=dst-nat chain=dstnat comment="TRANSMISSION CONNECT" dst-port=51413 \
in-interface-list=WAN protocol=udp to-addresses=192.168.2.104 to-ports=\
51413
add action=dst-nat chain=dstnat comment="HTTPS CONNECT DIRECT" disabled=yes \
dst-port=443 in-interface-list=WAN protocol=tcp to-addresses=\
192.168.2.104 to-ports=443
add action=dst-nat chain=dstnat comment="HTTP CONNECT DIRECT" disabled=yes \
dst-port=80 in-interface-list=WAN protocol=tcp to-addresses=192.168.2.104 \
to-ports=80
add action=dst-nat chain=dstnat comment="OPENVPN CONNECT" disabled=yes \
dst-port=1194 in-interface-list=WAN protocol=udp to-addresses=\
192.168.2.104 to-ports=1194
/ip firewall raw
add action=drop chain=prerouting comment="Drop all" src-address-list=\
BlackList
add action=drop chain=prerouting src-address-list=Indeseable_IP
add action=drop chain=prerouting src-address-list=web_blacklist
add action=drop chain=prerouting src-address-list=ssh_blacklist
add action=drop chain=prerouting src-address-list=IPSEC
/ip service
set telnet disabled=yes
set ftp disabled=yes
set api disabled=yes
set api-ssl disabled=yes
/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" 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
/system clock
set time-zone-name=Europe/Madrid
/system identity
set name=DANKO-RouterOS
/system logging
add action=login topics=system,error,critical
/system ntp client
set enabled=yes
/system ntp client servers
add address=pool.ntp.org
/tool mac-server
set allowed-interface-list=LAN