Firewall doesn't drop new connections in forward (or did I do something wrong?)

Hello,

Firstly, I want to clarify that I’m not a System Engineer or a security expert, so please forgive any shortcomings in my understanding.

Recently, I revisited the firewall settings on my HEXs router, following the example provided in the following link:

https://help.mikrotik.com/docs/display/ROS/Building+Advanced+Firewall

I’ve configured the firewall based on the example, with two exceptions. In the RAW section, I omitted the part related to ICMP filtering and added a rule to drop connections from a manually maintained list of IP addresses (RAW rule nr. 3 bellow).

In my network, I have a Linux server (192.168.0.3) running services on HTTPS, HTTP, and SSH (on port 2203) ports. Using NAT, I’ve opened this ports on the router that point to the server.

Now, upon analyzing the logs of the server 192.168.0.3, I’ve noticed continuous SSH brute force or scanning attempts (I’m not sure) on random ports (not the standard SSH port or my SSH port 2203) originating from an IP address in China:

Apr 28 11:36:54 cloud sshd[28265]: Connection closed by 113.XXX.XXX.XXX port 58753 [preauth]
Apr 28 11:36:54 cloud sshd[28271]: Connection closed by 113.XXX.XXX.XXX port 58927 [preauth]
Apr 28 11:36:54 cloud sshd[28266]: Connection closed by 113.XXX.XXX.XXX port 58782 [preauth]
Apr 28 11:36:54 cloud sshd[28269]: Connection closed by 113.XXX.XXX.XXX port 58840 [preauth]
..... (continue to try on many different ports)

As a response, I’ve banned the IP address on HEXs firewall and logged the activity, which shows attempts on different ports:

banIP_ prerouting: in:ether1 out:(unknown 0), connection-state:invalid src-mac XX:XX:XX:XX:XX:XX, proto TCP (SYN), 113.XXX.XXX.XXX:49987->61.XXX.XXX.XXX:10031, len 40
.....
.....

Now, my question is: How is it possible that these requests reach the server 192.168.0.3 when the firewall is supposed to drop new connections for forwarding on all ports, except for those set to be open on NAT rules? Is this normal?

Below are the firewall rules on my HEXs router:

RAW settings:

 0  D ;;; special dummy rule to show fasttrack counters
      chain=prerouting action=passthrough 
      
 1 X  ;;; defconf: enable for transparent firewall
      chain=prerouting action=accept 

 2    ;;; defconf: accept DHCP discover
      chain=prerouting action=accept in-interface-list=LAN src-port=68 dst-port=67 protocol=udp src-address=0.0.0.0 dst-address=255.255.255.255 

 3    ;;; Drop banned IPs
      chain=prerouting action=drop log=no log-prefix="banIP_" src-address-list=ban_ip 

 4    ;;; defconf: drop bogon IP's
      chain=prerouting action=drop src-address-list=bad_ipv4 

 5    ;;; defconf: drop bogon IP's
      chain=prerouting action=drop dst-address-list=bad_ipv4 

 6    ;;; defconf: drop bogon IP's
      chain=prerouting action=drop src-address-list=bad_src_ipv4 

 7    ;;; defconf: drop bogon IP's
      chain=prerouting action=drop log=no log-prefix="224_bad_dst" dst-address-list=bad_dst_ipv4 

 8    ;;; defconf: drop non global from WAN
      chain=prerouting action=drop in-interface-list=WAN src-address-list=not_global_ipv4 

 9    ;;; defconf: drop forward to local lan from WAN
      chain=prerouting action=drop in-interface-list=WAN dst-address=192.168.0.0/24 

10    ;;; defconf: drop local if not from default IP range
      chain=prerouting action=drop in-interface-list=LAN log=no log-prefix="not_lan_adrs" src-address=!192.168.0.0/24 

11    ;;; defconf: drop bad UDP
      chain=prerouting action=drop port=0 protocol=udp 

12    ;;; defconf: jump to TCP chain
      chain=prerouting action=jump jump-target=bad_tcp protocol=tcp 

13    ;;; defconf: accept everything else from LAN
      chain=prerouting action=accept in-interface-list=LAN 

14    ;;; defconf: accept everything else from WAN
      chain=prerouting action=accept in-interface-list=WAN 

15    ;;; defconf: drop the rest
      chain=prerouting action=drop 

16    ;;; defconf: TCP flag filter
      chain=bad_tcp action=drop tcp-flags=!fin,!syn,!rst,!ack protocol=tcp 

17    ;;; defconf tcp fin, syn flag
      chain=bad_tcp action=drop tcp-flags=fin,syn log=no log-prefix="" protocol=tcp 

18    ;;; defconf tcp fin, rst flag
      chain=bad_tcp action=drop tcp-flags=fin,rst log=no log-prefix="" protocol=tcp 

19    ;;; defconf tcp fin, !ack flag
      chain=bad_tcp action=drop tcp-flags=fin,!ack log=no log-prefix="" protocol=tcp 

20    ;;; defconf tcp fin, urg flag
      chain=bad_tcp action=drop tcp-flags=fin,urg log=no log-prefix="" protocol=tcp 

21    ;;; defconf tcp syn, rst flag
      chain=bad_tcp action=drop tcp-flags=syn,rst log=no log-prefix="" protocol=tcp 

22    ;;; defconf tcp rst, urg flag
      chain=bad_tcp action=drop tcp-flags=rst,urg log=no log-prefix="" protocol=tcp 

23    ;;; defconf: TCP port 0 drop
      chain=bad_tcp action=drop port=0 protocol=tcp

Filter settings:

 0  D ;;; special dummy rule to show fasttrack counters
      chain=forward action=passthrough 

 1    ;;; defconf: accept ICMP after RAW
      chain=input action=accept protocol=icmp log=no log-prefix="" 

 2    ;;; defconf: accept established,related, untracked
      chain=input action=accept connection-state=established,related,untracked log=no log-prefix="" 

 3    ;;; defconf: drop all not coming from LAN
      chain=input action=drop in-interface-list=!LAN log=no log-prefix="drop_nolan" 

 4 X  ;;; defconf: accept all that matches IPSec policy
      chain=forward action=accept ipsec-policy=in,ipsec 

 5    ;;; defconf: fasttrack accept estabilished related
      chain=forward action=fasttrack-connection hw-offload=yes connection-state=established,related log=no log-prefix="" 

 6    ;;; defconf: accept established,related, untracked
      chain=forward action=accept connection-state=established,related,untracked log=no log-prefix="" 

 7    ;;; defconf: drop invalid
      chain=forward action=drop connection-state=invalid log=no log-prefix="invalid" 

 8    ;;; defconf:  drop all from WAN not DSTNATed
      chain=forward action=drop connection-state=new connection-nat-state=!dstnat in-interface-list=WAN 

 9    ;;; defconf: drop bad forward IPs
      chain=forward action=drop src-address-list=no_forward_ipv4 

10    ;;; defconf: drop bad forward IPs
      chain=forward action=drop dst-address-list=no_forward_ipv4

NAT settings:

 0 X  ;;; defconf: accept all that matches IPSec policy
      chain=srcnat action=accept ipsec-policy=out,ipsec 

 1    ;;; defconf: masquerade
      chain=srcnat action=masquerade out-interface-list=WAN log=no log-prefix="" 

 2    ;;; ssh on 192.168.0.3
      chain=dstnat action=dst-nat to-addresses=192.168.0.3 to-ports=2203 protocol=tcp dst-address-type=local dst-port=2203 log=no log-prefix="" 

 3    ;;; using public address from LAN - ssh 192.168.0.3
      chain=srcnat action=masquerade to-ports=2203 protocol=tcp src-address=192.168.0.0/24 dst-address=192.168.0.3 out-interface=bridge dst-port=2203 log=no log-prefix=""  

 4    ;;; https on 192.168.0.3
      chain=dstnat action=dst-nat to-addresses=192.168.0.3 to-ports=443 protocol=tcp dst-address-type=local dst-port=443 log=no log-prefix="" 

 5    ;;; using public address from LAN - https 192.168.0.3
      chain=srcnat action=masquerade protocol=tcp src-address=192.168.0.0/24 dst-address=192.168.0.3 out-interface=bridge dst-port=443 log=no log-prefix="" 

 6    ;;; http on 192.168.0.3
      chain=dstnat action=dst-nat to-addresses=192.168.0.3 to-ports=80 protocol=tcp dst-address-type=local dst-port=80 log=no log-prefix="" 

 7    ;;; using public address from LAN - http 192.168.0.3
      chain=srcnat action=masquerade protocol=tcp src-address=192.168.0.0/24 dst-address=192.168.0.3 out-interface=bridge dst-port=80 log=no log-prefix=""

I’ve gone through the RouterOS documentation regarding the firewall, although being not an expert, I might have missed something. Therefore, I’m seeking advice here.

Thank you

Can no one help me with this issue? Or is it a non-issue?

Thanks

Can you use the export instead of print (to make it read friendly)?

/ip/firewall export

I would want to see the c omplete config, its all connected.
/export file=anynameyouwish (minus router serial number, public WANIP information, keys etc. )

Hello,
following both the router export and firewall export.
Anyway the firewall setting are the same in advanced firewall reported in the manual of mikrotik look at link in the first message. I check two time all rules if I had missing somethings.

Firewall export:

# 2024-06-16 22:07:14 by RouterOS 7.15.1
# software id = MN0B-GU3N
#
# model = RB760iGS
# serial number = xxxxxxxxxxxxxxxxxxx
/ip firewall address-list
add address=0.0.0.0/8 comment="defconf: RFC6890" list=no_forward_ipv4
add address=169.254.0.0/16 comment="defconf: RFC6890" list=no_forward_ipv4
add address=224.0.0.0/4 comment="defconf: multicast" list=no_forward_ipv4
add address=255.255.255.255 comment="defconf: RFC6890" list=no_forward_ipv4
add address=127.0.0.0/8 comment="defconf: RFC6890" list=bad_ipv4
add address=192.0.0.0/24 comment="defconf: RFC6890" list=bad_ipv4
add address=192.0.2.0/24 comment="defconf: RFC6890 documentation" list=bad_ipv4
add address=198.51.100.0/24 comment="defconf: RFC6890 documentation" list=bad_ipv4
add address=203.0.113.0/24 comment="defconf: RFC6890 documentation" list=bad_ipv4
add address=240.0.0.0/4 comment="defconf: RFC6890 reserved" list=bad_ipv4
add address=0.0.0.0/8 comment="defconf: RFC6890" list=not_global_ipv4
add address=10.0.0.0/8 comment="defconf: RFC6890" list=not_global_ipv4
add address=100.64.0.0/10 comment="defconf: RFC6890" list=not_global_ipv4
add address=169.254.0.0/16 comment="defconf: RFC6890" list=not_global_ipv4
add address=172.16.0.0/12 comment="defconf: RFC6890" list=not_global_ipv4
add address=192.0.0.0/29 comment="defconf: RFC6890" list=not_global_ipv4
add address=192.168.0.0/16 comment="defconf: RFC6890" list=not_global_ipv4
add address=198.18.0.0/15 comment="defconf: RFC6890 benchmark" list=not_global_ipv4
add address=255.255.255.255 comment="defconf: RFC6890" list=not_global_ipv4
add address=224.0.0.0/4 comment="defconf: multicast" list=bad_src_ipv4
add address=255.255.255.255 comment="defconf: RFC6890" list=bad_src_ipv4
add address=0.0.0.0/8 comment="defconf: RFC6890" list=bad_dst_ipv4
add address=224.0.0.0/4 comment="defconf: RFC6890" list=bad_dst_ipv4
add address=xxxxxxxxxxxxx/24 comment="banned 28 apr 2024" disabled=yes list=ban_ip
add address=xxxxxxxxxxx comment="banned 29 apr. 2024" disabled=yes list=ban_ip
add list=ddos-attackers
add list=ddos-targets
add address=xxxxxxxxxxxx comment="banned on 2 may 2024" list=ban_ip
add address=xxxxxxxxxxx.sn.mynetname.net comment="WAN IP" list=WANs
add address=192.168.0.0/24 comment="LAN IPs" list=LANs
add address=xxxxxxxxxxxx comment="banned on 22 may 2024" list=ban_ip
add address=xxxxxxxxxxxxx comment="ban on 31 may 2024" list=ban_ip
/ip firewall connection tracking
set udp-timeout=10s
/ip firewall filter
add action=accept chain=input comment="defconf: accept ICMP after RAW" protocol=icmp
add action=accept chain=input comment="defconf: accept established,related, untracked" connection-state=established,related,untracked
add action=drop chain=input comment="defconf: drop all not coming from LAN" in-interface-list=!LAN log-prefix=drop_nolan
add action=accept chain=forward comment="defconf: accept all that matches IPSec policy" disabled=yes ipsec-policy=in,ipsec
add action=fasttrack-connection chain=forward comment="defconf: fasttrack accept estabilished related" 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 log-prefix=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=drop chain=forward comment="defconf: drop bad forward IPs" src-address-list=no_forward_ipv4
add action=drop chain=forward comment="defconf: drop bad forward IPs" dst-address-list=no_forward_ipv4
/ip firewall mangle
add action=mark-connection chain=prerouting comment="Mark connections for hairpin NAT" disabled=yes dst-address-list=WANs new-connection-mark="Hairpin NAT" passthrough=yes src-address-list=LANs
/ip firewall nat
add action=accept chain=srcnat comment="defconf: accept all that matches IPSec policy" disabled=yes ipsec-policy=out,ipsec
add action=masquerade chain=srcnat comment="defconf: masquerade" out-interface-list=WAN
add action=dst-nat chain=dstnat comment="ssh on 192.168.0.3" dst-address-list=WANs dst-port=2203 protocol=tcp to-addresses=192.168.0.3 to-ports=2203
add action=masquerade chain=srcnat comment="using public address from LAN - ssh 192.168.0.3" dst-address=192.168.0.3 dst-port=2203 out-interface=bridge protocol=tcp src-address=192.168.0.0/24
add action=dst-nat chain=dstnat comment="https on 192.168.0.3" dst-address-list=WANs dst-port=443 protocol=tcp to-addresses=192.168.0.3 to-ports=443
add action=masquerade chain=srcnat comment="using public address from LAN - https 192.168.0.3" dst-address=192.168.0.3 dst-port=443 out-interface=bridge protocol=tcp src-address=192.168.0.0/24
add action=dst-nat chain=dstnat comment="http on 192.168.0.3" dst-address-list=WANs dst-port=80 protocol=tcp to-addresses=192.168.0.3 to-ports=80
add action=masquerade chain=srcnat comment="using public address from LAN - http 192.168.0.3" dst-address=192.168.0.3 dst-port=80 out-interface=bridge protocol=tcp src-address=192.168.0.0/24
/ip firewall raw
add action=accept chain=prerouting comment="defconf: enable for transparent firewall" disabled=yes
add action=accept chain=prerouting comment="defconf: accept DHCP discover" dst-address=255.255.255.255 dst-port=67 in-interface-list=LAN protocol=udp src-address=0.0.0.0 src-port=68
add action=drop chain=prerouting comment="Drop banned IPs" log=yes log-prefix=banIP_ src-address-list=ban_ip
add action=drop chain=prerouting comment="defconf: drop bogon IP's" src-address-list=bad_ipv4
add action=drop chain=prerouting comment="defconf: drop bogon IP's" dst-address-list=bad_ipv4
add action=drop chain=prerouting comment="defconf: drop bogon IP's" src-address-list=bad_src_ipv4
add action=drop chain=prerouting comment="defconf: drop bogon IP's" dst-address-list=bad_dst_ipv4 log-prefix=224_bad_dst
add action=drop chain=prerouting comment="defconf: drop non global from WAN" in-interface-list=WAN src-address-list=not_global_ipv4
add action=drop chain=prerouting comment="defconf: drop forward to local lan from WAN" dst-address=192.168.0.0/24 in-interface-list=WAN
add action=drop chain=prerouting comment="defconf: drop local if not from default IP range" in-interface-list=LAN log-prefix=not_lan_adrs src-address=!192.168.0.0/24
add action=drop chain=prerouting comment="defconf: drop bad UDP" port=0 protocol=udp
add action=jump chain=prerouting comment="defconf: jump to TCP chain" jump-target=bad_tcp protocol=tcp
add action=accept chain=prerouting comment="defconf: accept everything else from LAN" in-interface-list=LAN
add action=accept chain=prerouting comment="defconf: accept everything else from WAN" in-interface-list=WAN
add action=drop chain=prerouting comment="defconf: drop the rest"
add action=drop chain=bad_tcp comment="defconf: TCP flag filter" protocol=tcp tcp-flags=!fin,!syn,!rst,!ack
add action=drop chain=bad_tcp comment="defconf tcp fin, syn flag" protocol=tcp tcp-flags=fin,syn
add action=drop chain=bad_tcp comment="defconf tcp fin, rst flag" protocol=tcp tcp-flags=fin,rst
add action=drop chain=bad_tcp comment="defconf tcp fin, !ack flag" protocol=tcp tcp-flags=fin,!ack
add action=drop chain=bad_tcp comment="defconf tcp fin, urg flag" protocol=tcp tcp-flags=fin,urg
add action=drop chain=bad_tcp comment="defconf tcp syn, rst flag" protocol=tcp tcp-flags=syn,rst
add action=drop chain=bad_tcp comment="defconf tcp rst, urg flag" protocol=tcp tcp-flags=rst,urg
add action=drop chain=bad_tcp comment="defconf: TCP port 0 drop" port=0 protocol=tcp
/ip firewall service-port
set ftp disabled=yes
set tftp disabled=yes
set h323 disabled=yes
set sip disabled=yes
set pptp disabled=yes
set udplite disabled=yes
set dccp disabled=yes
set sctp disabled=yes

router export (I hope I have deleted all the sensitive data. It is very risky to export the entire router like this. I have replaced the sensitive data with X’s and deleted some things that were disabled)

# 2024-06-16 22:11:25 by RouterOS 7.15.1
# software id = MN0B-GU3N
#
# model = RB760iGS
# serial number = XXXXXXXXXXXX
/disk
set sd1 media-interface=none media-sharing=no
add media-interface=none media-sharing=no parent=sd1 partition-number=1 \
    partition-offset=512 partition-size="3 965 189 632" type=partition
/interface bridge
add admin-mac=XX:XX:XX:XX:XX:XX auto-mac=no comment=defconf name=bridge \
    port-cost-mode=short
/interface ethernet
set [ find default-name=sfp1 ] disabled=yes
/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN
/interface lte apn
set [ find default=yes ] ip-type=ipv4 use-network-apn=no
/ip pool
add name=dhcp ranges=192.168.0.100-192.168.0.253
/ip dhcp-server
add address-pool=dhcp interface=bridge lease-time=1h name=defconf
/ip smb users
set [ find default=yes ] disabled=yes
/ipv6 pool
add name=ipv6-pool prefix=::/64 prefix-length=64
/port
set 0 name=serial0
/ppp profile
set *0 dhcpv6-pd-pool=eohikari-pd use-ipv6=default
set *FFFFFFFE dhcpv6-pd-pool=eohikari-pd on-up=":delay 10\
    \n/system script run Gandi_liveDNS_DDNS\
    \n/system script run livedns_xxxxxxxxxx.com" use-ipv6=default use-upnp=\
    yes
/routing bgp template
set default disabled=no output.network=bgp-networks
/routing ospf instance
add disabled=no name=default-v2
add disabled=no name=default-v3 version=3
/routing ospf area
add disabled=yes instance=default-v2 name=backbone-v2
add disabled=yes instance=default-v3 name=backbone-v3
/system logging action
set 0 memory-lines=2000
/interface bridge port
add bridge=bridge comment=defconf ingress-filtering=no interface=ether2 \
    internal-path-cost=10 path-cost=10
add bridge=bridge comment=defconf ingress-filtering=no interface=ether3 \
    internal-path-cost=10 path-cost=10
add bridge=bridge comment=defconf ingress-filtering=no interface=ether4 \
    internal-path-cost=10 path-cost=10
add bridge=bridge comment=defconf ingress-filtering=no interface=ether5 \
    internal-path-cost=10 path-cost=10
add bridge=bridge comment=defconf ingress-filtering=no interface=sfp1 \
    internal-path-cost=10 path-cost=10
/ip firewall connection tracking
set udp-timeout=10s
/ip neighbor discovery-settings
set discover-interface-list=none lldp-med-net-policy-vlan=1
/ip settings
set rp-filter=strict tcp-syncookies=yes
/ipv6 settings
set accept-router-advertisements=yes disable-ipv6=yes max-neighbor-entries=\
    8192
/interface detect-internet
set detect-interface-list=WAN internet-interface-list=WAN lan-interface-list=\
    LAN wan-interface-list=WAN
/interface list member
add comment=defconf interface=bridge list=LAN
add comment=defconf interface=ether1 list=WAN
/interface ovpn-server server
set auth=sha1,md5
/ip address
add address=192.168.0.1/24 comment=defconf interface=bridge network=\
    192.168.0.0
/ip cloud
set ddns-enabled=yes
/ip dhcp-client
add comment=defconf interface=ether1 script=":delay 10\
    \n/system script run CF_DDNS_v1_xxxxxxxxxx.com\
    \n/system script run CF_DDNS_v1_xxxxxxxxxx.net\
    \n/system script run CF_DDNS_v1_xxxxxxxxxxx.org\
    \n" use-peer-dns=no
/ip dhcp-server lease
add address=192.168.0.2 client-id=1:XX:XX:XX:XX:XX:XX mac-address=\
    XX:XX:XX:XX:XX:XX server=defconf
add address=192.168.0.5 client-id=1:XX:XX:XX:XX:XX:XX mac-address=\
    XX:XX:XX:XX:XX:XX server=defconf
add address=192.168.0.6 client-id=1:XX:XX:XX:XX:XX:XX mac-address=\
    XX:XX:XX:XX:XX:XX server=defconf
add address=192.168.0.254 client-id=1:XX:XX:XX:XX:XX:XX mac-address=\
    XX:XX:XX:XX:XX:XX server=defconf
add address=192.168.0.4 client-id=1:XX:XX:XX:XX:XX:XX mac-address=\
    XX:XX:XX:XX:XX:XX server=defconf
add address=192.168.0.3 client-id=1:XX:XX:XX:XX:XX:XX mac-address=\
    XX:XX:XX:XX:XX:XX server=defconf
add address=192.168.0.7 client-id=1:XX:XX:XX:XX:XX:XX comment=\
    "Nintendo Switch" mac-address=XX:XX:XX:XX:XX:XX server=defconf
add address=192.168.0.8 client-id=1:XX:XX:XX:XX:XX:XX comment="Android TV" \
    mac-address=XX:XX:XX:XX:XX:XX server=defconf
add address=192.168.0.9 client-id=1:XX:XX:XX:XX:XX:XX comment="Kaito tablet" \
    mac-address=XX:XX:XX:XX:XX:XX server=defconf
add address=192.168.0.10 client-id=1:XX:XX:XX:XX:XX:XX comment="Mia desktop" \
    mac-address=XX:XX:XX:XX:XX:XX server=defconf
/ip dhcp-server network
add address=192.168.0.0/24 comment=defconf dns-server=\
    192.168.0.1,1.1.1.2,1.0.0.2,8.8.8.8 domain=home-net gateway=192.168.0.1 \
    netmask=24 ntp-server=80.67.184.129
/ip dns
set allow-remote-requests=yes cache-max-ttl=2d cache-size=3072KiB \
    query-server-timeout=50m query-total-timeout=4h10m servers=\
    1.1.1.2,1.0.0.2,8.8.8.8 verify-doh-cert=yes
/ip dns static
add address=192.168.0.1 comment=defconf name=router.lan
add address=1.1.1.2 disabled=yes name=security.cloudflare-dns.com
add address=1.0.0.2 disabled=yes name=security.cloudflare2-dns.com
/ip firewall address-list
add address=0.0.0.0/8 comment="defconf: RFC6890" list=no_forward_ipv4
add address=169.254.0.0/16 comment="defconf: RFC6890" list=no_forward_ipv4
add address=224.0.0.0/4 comment="defconf: multicast" list=no_forward_ipv4
add address=255.255.255.255 comment="defconf: RFC6890" list=no_forward_ipv4
add address=127.0.0.0/8 comment="defconf: RFC6890" list=bad_ipv4
add address=192.0.0.0/24 comment="defconf: RFC6890" list=bad_ipv4
add address=192.0.2.0/24 comment="defconf: RFC6890 documentation" list=\
    bad_ipv4
add address=198.51.100.0/24 comment="defconf: RFC6890 documentation" list=\
    bad_ipv4
add address=203.0.113.0/24 comment="defconf: RFC6890 documentation" list=\
    bad_ipv4
add address=240.0.0.0/4 comment="defconf: RFC6890 reserved" list=bad_ipv4
add address=0.0.0.0/8 comment="defconf: RFC6890" list=not_global_ipv4
add address=10.0.0.0/8 comment="defconf: RFC6890" list=not_global_ipv4
add address=100.64.0.0/10 comment="defconf: RFC6890" list=not_global_ipv4
add address=169.254.0.0/16 comment="defconf: RFC6890" list=not_global_ipv4
add address=172.16.0.0/12 comment="defconf: RFC6890" list=not_global_ipv4
add address=192.0.0.0/29 comment="defconf: RFC6890" list=not_global_ipv4
add address=192.168.0.0/16 comment="defconf: RFC6890" list=not_global_ipv4
add address=198.18.0.0/15 comment="defconf: RFC6890 benchmark" list=\
    not_global_ipv4
add address=255.255.255.255 comment="defconf: RFC6890" list=not_global_ipv4
add address=224.0.0.0/4 comment="defconf: multicast" list=bad_src_ipv4
add address=255.255.255.255 comment="defconf: RFC6890" list=bad_src_ipv4
add address=0.0.0.0/8 comment="defconf: RFC6890" list=bad_dst_ipv4
add address=224.0.0.0/4 comment="defconf: RFC6890" list=bad_dst_ipv4
add address=xxx.xxx.xxx.xxx/24 comment="banned 28 apr 2024" disabled=yes list=\
    ban_ip
add address=xxx.xxx.xxx.xxx comment="banned 29 apr. 2024" disabled=yes list=\
    ban_ip
add list=ddos-attackers
add list=ddos-targets
add address=xxx.xxx.xxx.xxx comment="banned on 2 may 2024" list=ban_ip
add address=xxxxxxxxxxxx.sn.mynetname.net comment="WAN IP" list=WANs
add address=192.168.0.0/24 comment="LAN IPs" list=LANs
add address=xxx.xxx.xxx.xxx comment="banned on 22 may 2024" list=ban_ip
add address=xxx.xxx.xxx.xxx comment="ban on 31 may 2024" list=ban_ip
/ip firewall filter
add action=accept chain=input comment="defconf: accept ICMP after RAW" \
    protocol=icmp
add action=accept chain=input comment=\
    "defconf: accept established,related, untracked" connection-state=\
    established,related,untracked
add action=drop chain=input comment="defconf: drop all not coming from LAN" \
    in-interface-list=!LAN log-prefix=drop_nolan
add action=accept chain=forward comment=\
    "defconf: accept all that matches IPSec policy" disabled=yes \
    ipsec-policy=in,ipsec
add action=fasttrack-connection chain=forward comment=\
    "defconf: fasttrack accept estabilished related" 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 log-prefix=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=drop chain=forward comment="defconf: drop bad forward IPs" \
    src-address-list=no_forward_ipv4
add action=drop chain=forward comment="defconf: drop bad forward IPs" \
    dst-address-list=no_forward_ipv4
/ip firewall mangle
add action=mark-connection chain=prerouting comment=\
    "Mark connections for hairpin NAT" disabled=yes dst-address-list=WANs \
    new-connection-mark="Hairpin NAT" passthrough=yes src-address-list=LANs
/ip firewall nat
add action=accept chain=srcnat comment=\
    "defconf: accept all that matches IPSec policy" disabled=yes \
    ipsec-policy=out,ipsec
add action=masquerade chain=srcnat comment="defconf: masquerade" \
    out-interface-list=WAN
add action=dst-nat chain=dstnat comment="ssh on 192.168.0.3" \
    dst-address-list=WANs dst-port=2203 protocol=tcp to-addresses=192.168.0.3 \
    to-ports=2203
add action=masquerade chain=srcnat comment=\
    "using public address from LAN - ssh 192.168.0.3" dst-address=192.168.0.3 \
    dst-port=2203 out-interface=bridge protocol=tcp src-address=\
    192.168.0.0/24
add action=dst-nat chain=dstnat comment="https on 192.168.0.3" \
    dst-address-list=WANs dst-port=443 protocol=tcp to-addresses=192.168.0.3 \
    to-ports=443
add action=masquerade chain=srcnat comment=\
    "using public address from LAN - https 192.168.0.3" dst-address=\
    192.168.0.3 dst-port=443 out-interface=bridge protocol=tcp src-address=\
    192.168.0.0/24
add action=dst-nat chain=dstnat comment="http on 192.168.0.3" \
    dst-address-list=WANs dst-port=80 protocol=tcp to-addresses=192.168.0.3 \
    to-ports=80
add action=masquerade chain=srcnat comment=\
    "using public address from LAN - http 192.168.0.3" dst-address=\
    192.168.0.3 dst-port=80 out-interface=bridge protocol=tcp src-address=\
    192.168.0.0/24
/ip firewall raw
add action=accept chain=prerouting comment=\
    "defconf: enable for transparent firewall" disabled=yes
add action=accept chain=prerouting comment="defconf: accept DHCP discover" \
    dst-address=255.255.255.255 dst-port=67 in-interface-list=LAN protocol=\
    udp src-address=0.0.0.0 src-port=68
add action=drop chain=prerouting comment="Drop banned IPs" log=yes \
    log-prefix=banIP_ src-address-list=ban_ip
add action=drop chain=prerouting comment="defconf: drop bogon IP's" \
    src-address-list=bad_ipv4
add action=drop chain=prerouting comment="defconf: drop bogon IP's" \
    dst-address-list=bad_ipv4
add action=drop chain=prerouting comment="defconf: drop bogon IP's" \
    src-address-list=bad_src_ipv4
add action=drop chain=prerouting comment="defconf: drop bogon IP's" \
    dst-address-list=bad_dst_ipv4 log-prefix=224_bad_dst
add action=drop chain=prerouting comment="defconf: drop non global from WAN" \
    in-interface-list=WAN src-address-list=not_global_ipv4
add action=drop chain=prerouting comment="DDoS protection" disabled=yes \
    dst-address-list=ddos-targets src-address-list=ddos-attackers
add action=drop chain=prerouting comment=\
    "defconf: drop forward to local lan from WAN" dst-address=192.168.0.0/24 \
    in-interface-list=WAN
add action=drop chain=prerouting comment=\
    "defconf: drop local if not from default IP range" in-interface-list=LAN \
    log-prefix=not_lan_adrs src-address=!192.168.0.0/24
add action=drop chain=prerouting comment="defconf: drop bad UDP" port=0 \
    protocol=udp
add action=jump chain=prerouting comment="defconf: jump to ICMP chain" \
    disabled=yes jump-target=icmp4 protocol=icmp
add action=jump chain=prerouting comment="defconf: jump to TCP chain" \
    jump-target=bad_tcp protocol=tcp
add action=accept chain=prerouting comment=\
    "defconf: accept everything else from LAN" in-interface-list=LAN
add action=accept chain=prerouting comment=\
    "defconf: accept everything else from WAN" in-interface-list=WAN
add action=drop chain=prerouting comment="defconf: drop the rest"
add action=drop chain=bad_tcp comment="defconf: TCP flag filter" protocol=tcp \
    tcp-flags=!fin,!syn,!rst,!ack
add action=drop chain=bad_tcp comment="defconf tcp fin, syn flag" protocol=\
    tcp tcp-flags=fin,syn
add action=drop chain=bad_tcp comment="defconf tcp fin, rst flag" protocol=\
    tcp tcp-flags=fin,rst
add action=drop chain=bad_tcp comment="defconf tcp fin, !ack flag" protocol=\
    tcp tcp-flags=fin,!ack
add action=drop chain=bad_tcp comment="defconf tcp fin, urg flag" protocol=\
    tcp tcp-flags=fin,urg
add action=drop chain=bad_tcp comment="defconf tcp syn, rst flag" protocol=\
    tcp tcp-flags=syn,rst
add action=drop chain=bad_tcp comment="defconf tcp rst, urg flag" protocol=\
    tcp tcp-flags=rst,urg
add action=drop chain=bad_tcp comment="defconf: TCP port 0 drop" port=0 \
    protocol=tcp
/ip firewall service-port
set ftp disabled=yes
set tftp disabled=yes
set h323 disabled=yes
set sip disabled=yes
set pptp disabled=yes
set udplite disabled=yes
set dccp disabled=yes
set sctp disabled=yes
/ip nat-pmp
set enabled=yes
/ip nat-pmp interfaces
add interface=ether1 type=external
add interface=bridge type=internal
/ip service
set telnet disabled=yes
set ftp disabled=yes
set www address=192.168.0.0/24 disabled=yes port=8000
set ssh address=192.168.0.0/24 port=2201
set www-ssl address=192.168.0.0/24 certificate=https-cert disabled=no port=\
    8000
set api address=192.168.0.0/24 disabled=yes port=12345
set winbox address=192.168.0.0/24
set api-ssl address=192.168.0.0/24 port=12346
/ip smb shares
set [ find default=yes ] directory=/flash/pub
/ip ssh
set strong-crypto=yes
/ip traffic-flow
set active-flow-timeout=1m
/ip traffic-flow target
add dst-address=192.168.0.2 v9-template-timeout=1m
/ip upnp
set show-dummy-rule=no
/ip upnp interfaces
add interface=ether1 type=external
add interface=bridge type=internal
/ipv6 address
add disabled=yes eui-64=yes from-pool=ipv6-pool interface=bridge
/ipv6 dhcp-client
add add-default-route=yes disabled=yes interface=ether1 pool-name=ipv6-pool \
    prefix-hint=::/64 request=prefix use-interface-duid=yes use-peer-dns=no
/ipv6 firewall address-list
add address=fe80::/16 disabled=yes list=allowed
add address=ff02::/16 comment=multicast disabled=yes list=allowed
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
add address=::224.0.0.0/100 comment="defconf: other" list=bad_ipv6
add address=::127.0.0.0/104 comment="defconf: other" list=bad_ipv6
add address=::/104 comment="defconf: other" list=bad_ipv6
add address=::255.0.0.0/104 comment="defconf: other" list=bad_ipv6
add address=fe80::/10 comment="defconf: RFC6890 Linked-Scoped Unicast" list=\
    no_forward_ipv6
add address=ff00::/8 comment="defconf: multicast" list=no_forward_ipv6
add address=100::/64 comment="defconf: RFC6890 Discard-only" list=\
    not_global_ipv6
add address=2001::/32 comment="defconf: RFC6890 TEREDO" list=not_global_ipv6
add address=2001:2::/48 comment="defconf: RFC6890 Benchmark" list=\
    not_global_ipv6
add address=fc00::/7 comment="defconf: RFC6890 Unique-Local" list=\
    not_global_ipv6
add address=::/128 comment="defconf: unspecified" list=bad_dst_ipv6
add address=::/128 comment="defconf: unspecified" list=bad_src_ipv6
add address=ff00::/8 comment="defconf: multicast" list=bad_src_ipv6
/ipv6 firewall filter
add action=accept chain=input comment="defconf: accept ICMPv6 after RAW" \
    protocol=icmpv6
add action=accept chain=input comment=\
    "defconf: accept established,related,untracked" connection-state=\
    established,related,untracked
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=drop chain=input comment="defconf: drop all 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 bad forward IPs" \
    src-address-list=no_forward_ipv6
add action=drop chain=forward comment="defconf: drop bad forward IPs" \
    dst-address-list=no_forward_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 after RAW" \
    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 AH" protocol=\
    ipsec-ah
add action=accept chain=forward comment="defconf: accept 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
/ipv6 firewall mangle
add action=change-mss chain=forward new-mss=clamp-to-pmtu out-interface=\
    ether1 passthrough=yes protocol=tcp tcp-flags=syn
/ipv6 firewall raw
add action=accept chain=prerouting comment=\
    "defconf: enable for transparent firewall" disabled=yes
add action=accept chain=prerouting comment="defconf: RFC4291, section 2.7.1" \
    dst-address=ff02::1:ff00:0/104 icmp-options=135 protocol=icmpv6 \
    src-address=::/128
add action=drop chain=prerouting comment="defconf: drop bogon IP's" \
    src-address-list=bad_ipv6
add action=drop chain=prerouting comment="defconf: drop bogon IP's" \
    dst-address-list=bad_ipv6
add action=drop chain=prerouting comment=\
    "defconf: drop packets with bad SRC ipv6" src-address-list=bad_src_ipv6
add action=drop chain=prerouting comment=\
    "defconf: drop packets with bad dst ipv6" dst-address-list=bad_dst_ipv6
add action=drop chain=prerouting comment="defconf: drop non global from WAN" \
    in-interface-list=WAN src-address-list=not_global_ipv6
add action=jump chain=prerouting comment="defconf: jump to ICMPv6 chain" \
    disabled=yes jump-target=icmp6 protocol=icmpv6
add action=accept chain=prerouting comment=\
    "defconf: accept local multicast scope" dst-address=ff02::/16
add action=drop chain=prerouting comment=\
    "defconf: drop other multicast destinations" dst-address=ff00::/8
add action=accept chain=prerouting comment=\
    "defconf: accept everything else from WAN" in-interface-list=WAN
add action=accept chain=prerouting comment=\
    "defconf: accept everything else from LAN" in-interface-list=LAN
add action=drop chain=prerouting comment="defconf: drop the rest"
add action=drop chain=icmp6 comment=\
    "defconf: rfc4890 drop ll if hop-limit!=255" disabled=yes dst-address=\
    fe80::/10 hop-limit=not-equal:255 protocol=icmpv6
add action=accept chain=icmp6 comment="defconf: dst unreachable" disabled=yes \
    icmp-options=1:0-255 protocol=icmpv6
add action=accept chain=icmp6 comment="defconf: packet too big" disabled=yes \
    icmp-options=2:0-255 protocol=icmpv6
add action=accept chain=icmp6 comment="defconf: limit exceeded" disabled=yes \
    icmp-options=3:0-1 protocol=icmpv6
add action=accept chain=icmp6 comment="defconf: bad header" disabled=yes \
    icmp-options=4:0-2 protocol=icmpv6
add action=accept chain=icmp6 comment=\
    "defconf: Mobile home agent address discovery" disabled=yes icmp-options=\
    144:0-255 protocol=icmpv6
add action=accept chain=icmp6 comment=\
    "defconf: Mobile home agent address discovery" disabled=yes icmp-options=\
    145:0-255 protocol=icmpv6
add action=accept chain=icmp6 comment="defconf: Mobile prefix solic" \
    disabled=yes icmp-options=146:0-255 protocol=icmpv6
add action=accept chain=icmp6 comment="defconf: Mobile prefix advert" \
    disabled=yes icmp-options=147:0-255 protocol=icmpv6
add action=accept chain=icmp6 comment="defconf: echo request limit 5,10" \
    disabled=yes icmp-options=128:0-255 limit=5,10:packet protocol=icmpv6
add action=accept chain=icmp6 comment="defconf: echo reply limit 5,10" \
    disabled=yes icmp-options=129:0-255 limit=5,10:packet protocol=icmpv6
add action=accept chain=icmp6 comment=\
    "defconf: rfc4890 router solic limit 5,10 only LAN" disabled=yes \
    hop-limit=equal:255 icmp-options=133:0-255 in-interface-list=LAN limit=\
    5,10:packet protocol=icmpv6
add action=accept chain=icmp6 comment=\
    "defconf: rfc4890 router advert limit 5,10 only LAN" disabled=yes \
    hop-limit=equal:255 icmp-options=134:0-255 in-interface-list=LAN limit=\
    5,10:packet protocol=icmpv6
add action=accept chain=icmp6 comment=\
    "defconf: rfc4890 neighbor solic limit 5,10 only LAN" disabled=yes \
    hop-limit=equal:255 icmp-options=135:0-255 in-interface-list=LAN limit=\
    5,10:packet protocol=icmpv6
add action=accept chain=icmp6 comment=\
    "defconf: rfc4890 neighbor advert limit 5,10 only LAN" disabled=yes \
    hop-limit=equal:255 icmp-options=136:0-255 in-interface-list=LAN limit=\
    5,10:packet protocol=icmpv6
add action=accept chain=icmp6 comment=\
    "defconf: rfc4890 inverse ND solic limit 5,10 only LAN" disabled=yes \
    hop-limit=equal:255 icmp-options=141:0-255 in-interface-list=LAN limit=\
    5,10:packet protocol=icmpv6
add action=accept chain=icmp6 comment=\
    "defconf: rfc4890 inverse ND advert limit 5,10 only LAN" disabled=yes \
    hop-limit=equal:255 icmp-options=142:0-255 in-interface-list=LAN limit=\
    5,10:packet protocol=icmpv6
add action=drop chain=icmp6 comment="defconf: drop other icmp" disabled=yes \
    protocol=icmpv6
/ipv6 nd
set [ find default=yes ] disabled=yes hop-limit=64 interface=ether1 \
    managed-address-configuration=yes other-configuration=yes ra-interval=\
    20s-1m
/routing bfd configuration
add disabled=no interfaces=all min-rx=200ms min-tx=200ms multiplier=5
/system clock
set time-zone-name=Asia/Tokyo
/system console
set [ find ] disabled=yes
/system leds
set 0 disabled=yes
/system note
set show-at-login=no
/system ntp client
set enabled=yes
/system ntp client servers
add address=80.67.184.129
add address=193.54.76.41
/system scheduler
/tool bandwidth-server
set enabled=no
/tool e-mail
set from=xxxx@xxxxxxxxxx.com port=465 server=xxxxxxxxxxxx tls=yes user=\
    xxxxxxxxxxxxxxx
/tool graphing interface
add allow-address=192.168.0.0/24 interface=*8 store-on-disk=no
add allow-address=192.168.0.0/24 interface=ether2 store-on-disk=no
add allow-address=192.168.0.0/24 interface=ether3 store-on-disk=no
add allow-address=192.168.0.0/24 interface=ether4 store-on-disk=no
add allow-address=192.168.0.0/24 interface=bridge store-on-disk=no
add allow-address=192.168.0.0/24 store-on-disk=no
/tool graphing resource
add allow-address=192.168.0.0/24 store-on-disk=no
/tool mac-server
set allowed-interface-list=none
/tool mac-server mac-winbox
set allowed-interface-list=none
/tool mac-server ping
set enabled=no

Thanks for the answer

Why do you think/state "…upon analyzing the logs of the server 192.168.0.3, I’ve noticed continuous SSH brute force or scanning attempts (I’m not sure) on random ports (not the standard SSH port or my SSH port 2203) originating from an IP address in China:

Apr 28 11:36:54 cloud sshd[28265]: Connection closed by 113.XXX.XXX.XXX port 58753 [preauth]
Apr 28 11:36:54 cloud sshd[28271]: Connection closed by 113.XXX.XXX.XXX port 58927 [preauth]
Apr 28 11:36:54 cloud sshd[28266]: Connection closed by 113.XXX.XXX.XXX port 58782 [preauth]
Apr 28 11:36:54 cloud sshd[28269]: Connection closed by 113.XXX.XXX.XXX port 58840 [preauth]
… (continue to try on many different ports)

For sure some 113.x.x.x IP is giving it a try, but the “port” value is the (“random”) SOURCE port on the other side, nothing to be bothered with.
So for sure the remote party of trying to SSH on your public-IP port 2203 just like you configured, but no luck getting in.

Not familiar with IPV6, and I was always given the impression that IPV6 was perfectly safe, obviously not only do you not have the additional protection of NAT, one still needs full set of firewall rules… dont see why its any better.

I know I shouldn’t worry. But my question was different:
Why does this request reach the server 192.168.0.3, when the router firewall should drop all new connections in forward except those to the ports set in NAT (80,443,2203)?

/ip firewall filter
......
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 raw
......
add action=drop chain=prerouting comment="defconf: drop forward to local lan from WAN" dst-address=192.168.0.0/24 in-interface-list=WAN
......

According to the above rules, the request shouldn’t reach the server 192.168.0.3 because it should be dropped before reaching the server. These requests arrive on ports that are not open in NAT, and that I think it’s a new connection.

I just want to understand why this request reaches the server 192.168.0.3 when the firewall should close all ports except those present in NAT. I want only the connections to ports 80, 443, and 2203 to reach the server 192.168.0.3 and drop everything else, as for the rules above that I set.

Thanks

Maybe you posted in the wrong thread? It doesn’t seem on topic.

Perhaps, do you or do you not have an IPV6 internet connection?? If not why do you have ipv6 rules, and lists…

Maybe the internet host found open port 2203 and is now trying to brute-force in? I’ve seen that as well … one has to keep in mind that using non-standard ports doesn’t really prevent somebody to get in, it only makes probability lower as many port scanners only probe standard ports (to expedite the scanning).

  1. Best → have all users wireguard to the inside of the router and then access server.
  2. Better → Ensure you use a source address or source address list for external originators when possible (on dstnat rules). Then ports do not appear on scans, open or closed.

Indeed I’m pretty sure them Chinese ARE hitting your public IP on port 2203 (hence otherwise your sshd on the Linux box would not pickup the connections). What I meant was that in the output your described (see below) you will not find port 2203 or something.

*sshd[28265] is no tcp-port but a PID of the nix process.
113.xxx.xxx.xxx port 58753 is the SOURCE/ORIGIN of the attempt and not the target YOUR.IP:2203

Apr 28 11:36:54 cloud sshd[28265]: Connection closed by 113.XXX.XXX.XXX port 58753 [preauth]
Apr 28 11:36:54 cloud sshd[28271]: Connection closed by 113.XXX.XXX.XXX port 58927 [preauth]
Apr 28 11:36:54 cloud sshd[28266]: Connection closed by 113.XXX.XXX.XXX port 58782 [preauth]
Apr 28 11:36:54 cloud sshd[28269]: Connection closed by 113.XXX.XXX.XXX port 58840 [preauth]

So I think nothing is abnormal here. Everything works as configured.

Correct, pretty much any number with “22” in it will get hit by scanners, security by obscurity does not work!

OK, thanks for explaining it to me. I have only one doubt. When I banned the IP on the router firewall, the banned log says:

banIP_ prerouting: in:ether1 out:(unknown 0), connection-state:invalid src-mac XX:XX:XX:XX:XX:XX, proto TCP (SYN), 113.XXX.XXX.XXX:49987->61.XXX.XXX.XXX:10031, len 40
...
...

This seems to be a connection to port 10031, and other logs are on random ports. It’s true that we cannot know if the attacker changed their method after I banned them. So maybe it’s all OK like you say. I will monitor the connection, but this attacker stopped attacking me after one week of the ban. Anyway, thanks.




I changed the port because before, I had more than one server using SSH, and I used different ports to connect to different servers. Now I have only one server using SSH, but I have not changed the old port. I know that this is not a effective way to protect the SSH port.


I changed the ISP. The previous one supported IPv6, but the current ISP does not support IPv6. The settings from the previous ISP remain on the router. Anyway, I think it’s not relevant to this issue, and I have checked the router to ensure disable-ipv6=yes.

Thanks

banIP_ prerouting: in:ether1 out:(unknown 0), connection-state:invalid src-mac XX:XX:XX:XX:XX:XX, proto TCP (SYN), 113.XXX.XXX.XXX:49987->[color=61.XXX.XXX.XXX:10031

This is only the first packet (SYN) arriving at your router targetted at your public IP 61.x.x.x on 10031.
Since there is no DNAT associated with it on port 10031 it should get dropped anyway.
It would be really concerning if your logs on the SERVER also have this in their logs, that would mean the SYN “leaked” through up to the server.

/ip neighbor discovery-settings
set discover-interface-list=LAN

/ip settings
set rp-filter=loose tcp-syncookies=no

/interface detect-internet
set detect-interface-list=none

REMOVE -
/ip dns static
add address=192.168.0.1 comment=defconf name=router.lan

REMOVE net mask if you entered it manually. Remove NTP server you have it defined already on the router… Any device that needs NTP will require you to add 192.168.0.1 as the address to acquire NTP from the router.

/ip dhcp-server network
add address=192.168.0.0/24 comment=defconf dns-server=
192.168.0.1,1.1.1.2,1.0.0.2,8.8.8.8 domain=home-net gateway=192.168.0.1
netmask=24

/ip firewall address-list
add 192.168.0.X list=Authorized comment=“admin desktop”
add 192.168.0.Y list=Authorized comment=“admin other device”

/ip firewall filter
{ default rules to keep }
add action=accept chain=input connection-state=established,related,untracked
add action=drop chain=input connection-state=invalid invalid log-prefix=invalid
add action=accept chain=input protocol=icmp

{ admin rules }
add action=accept chain=input comment=“admin access” in-interface-list=LAN src-address-list=Authorized
add action=accept chain=input comment=“user services” dst-port=53,123 protocol=udp in-interface-list=LAN
add action=accept chain=input comment=“user services” dst-port=53 protocol=tcp in-interface-list=LAN
add action=drop chain=input comment=“drop all else”

+++++++++++++++++++++++++++++++++++++++++++++
{ default rules to keep }
add action=fasttrack-connection chain=forward connection-state=established,related hw-offload=yes
add action=accept chain=forward connection-state=established,related,untracked
add action=drop chain=forward connection-state=invalid log-prefix=invalid

{ admin rules }
add action=accept chain=forward comment=“internet traffic” in-interface-list=LAN out-interface-list=WAN
add action=accept chain=forward comment=“port forwarding” connection-nat-state=dstnat
add action=drop chain=forward comment=“drop all else”

REMOVE ALL RAW RULES

Do you need upnp enabled?

/tool mac-server mac-winbox
set allowed-interface-list=LAN

/ip firewall nat
add action=masquerade chain=srcnat comment=“defconf: masquerade”
out-interface-list=WAN
add action=masquerade chain=srcnat comment=hairpin src-address=192.168.0.0/24 dst-address=192.168.0.0/24
add action=dst-nat chain=dstnat comment=“ssh on 192.168.0.3”
dst-address-list=WANs dst-port=2203 protocol=tcp to-addresses=192.168.0.3
to-ports=2203
add action=masquerade chain=srcnat comment=
“using public address from LAN - ssh 192.168.0.3” dst-address=192.168.0.3
dst-port=2203 out-interface=bridge protocol=tcp src-address=
192.168.0.0/24
add action=dst-nat chain=dstnat comment=“https on 192.168.0.3”
dst-address-list=WANs dst-port=443 protocol=tcp to-addresses=192.168.0.3
to-ports=443
add action=masquerade chain=srcnat comment=
“using public address from LAN - https 192.168.0.3” dst-address=
192.168.0.3 dst-port=443 out-interface=bridge protocol=tcp src-address=
192.168.0.0/24
add action=dst-nat chain=dstnat comment=“http on 192.168.0.3”
dst-address-list=WANs dst-port=80 protocol=tcp to-addresses=192.168.0.3
to-ports=80
add action=masquerade chain=srcnat comment=
“using public address from LAN - http 192.168.0.3” dst-address=
192.168.0.3 dst-port=80 out-interface=bridge protocol=tcp src-address=
192.168.0.0/24


The dstnat rules seem fine, not sure why you have to add a masquerade rule, for each one.
What is the purpose or requirements you are trying to achieve ???