DDoS help

Hello,

somebody decided, we are too successful in what we are doing and started regular DDoS on our business. I ve managed to mitigate it somehow (various UDP based amplifications attacks by simply not letting almost anything from UDP in), but I am failing to solve something, which should be really simple to solve.

I have simple setup, public IP, NAT, several open ports for allowing some traffic inside, but each of them allows dstnat happen only based on list of IPs. So nothing goes inside the network. But there is attack, which is using tons of IPS and should be very simple to solve. I added simple rule for dropping everything not dst nated, but it didnt help. I tried rule for dropping everyhing forwarded except these several allowed ports. Also anti ddoes rule showed on wiki (didnt catch anything from this attack, just par of differenet one). I ve tried just to be sure to drop in prerouting everything going to this one attacked port (see attached picture), but connections are still established, zero bytes dropped (rule is on the top), and i dont understand why, there are tens of thousands of them, which causes our clients to disconnect several times during attack. Last week I am reading wiki, googling, but nothing helps. Any ideas? Thanks:
attach.jpg

Please share your config:

/export file=anynameyoulike

Remove serial and any other private information from it and post the output in between code tags by using the </> button

If truly DDOS then its the responsibility of your ISP and their upstream providers to counter an attack.
Your router is not equipped to do so.

Hi,

try this…

https://help.mikrotik.com/docs/pages/viewpage.action?pageId=28606504

The router probably crashes after some time when the memory is full…
I only see different IPs:ports and a form of blacklist that after a while fills the memory and crashes the router.
The best way to protect yourself is to ignore attacks and leave your firewall configured well.

However, the best way would be to ask the ISP, which in these cases, at the cost of a little additional latency on that IP,
filters the traffic a priori, allowing only wanted (at least) traffic to reach the customer’s router.

Sounds like shooting oneself in the foot…

Regarding my ISP (t-mobile), they told me, that they have some anti DDoS protection and cant do more for me more (so it was like we cant care less). Actually they even didnt notice, until I told them to check logs of traffic increase during that time, like if I have whole day cca 2mbit/second and than 6/Gbit/second, there is something suspicious. They dont even have basic monitoring to notify clients.
My other server on professional hosting was also under attack and they properly detected attack:

Impact: 146.15 Mbps/15.00 Kpps;6.42 Gbps/749.60 Kpps
Importance: High
Description: IP Fragmentation, UDP, NTP Amplification, DNS Amplification

But again they told me, we have some anti DDoS and we cant do more. This is lie, there are indeed specialized network devices like Radware DefensePro to filter such traffic meant for hostings with hundreds of gigs of bandwith like this. It is even more lie in that sense, that my amateurish attempts mitigated it quite a lot.

My first router (CRS125) was "fried" in several seconds and indeed crashed, so I ve bought more powerfull (CCR2116-). From totally unusable service for cca 30-40 minutes during each attack, we have now just several 1 seconds lags, and in worst case few disconnects of clients. Router does not crash, cpu load is not above 14 percent during attack and attack consumes only cca 2GB of memory, still 14GB free. I have feeling, that if I manage to solve this attack (to not let these connection establish), it will be almost invisible to users. It looks like this router has enough power to handle these small scale attacks (according to my ISP only 2-8Gbit/sec) and because my line is only 1000/1000mbit fiber, this makes limit what they can get on my router.

"Hi,
try this....
https://help.mikrotik.com/docs/pages/vi ... d=28606504
"
Sure, this is implemented, but didnt help much. Drops on thes rules are minimal.

"Remove serial and any other private information from it and post the output in between code tags by using the </> button"

Yes, I will do it. I did it somehow and after taking care of UDP type attacks impact is quite low, but since I am new to that, I have feeling that it can be done in much better and systematic way. Thanks for help.

T-Mobile has indeed a feature for DDoS protection. A paid feature. Their reluctance is simply that they don’t want to provide it for free, even if that means that you are being disconnected due to the attack. Yes, ISP have a nasty tendency to leave people in a lurch.

One issue I see is that port tcp/65372 is exposed. If you are seeing a lot of established connections, it means these are available to the whole world. Could you limit them in the filter instead? Another change you can make is to more aggressively terminate the unacked connections (IP → Firewall → Connections → Tracking → TCP Unacked Timeout). By default, this is 5 minutes, which means that the connection will be kept in the half-open state, waiting for the final ACK, for 5 minutes. Consider diminishing this to 1 minute or even 30 seconds.

Looking at the addresses in the screenshot, this seems to be randomly generated, some are assigned to Level3, IBM, … Unluckily these big guys are attacking you.

Please share the conf without sensitive informations.

The very first set I will disable LOOSE TCP Connection in ip firewall connection tracking

share the conf or we are blind and cannot help you

This was first thing I asked. How much for something better. Sorry, we dont provide. Bye. Services in our country sucks.

Here is setup, I hope i didnt break anything, I had to censor lots of stuff (IPs, names, descriptions…). Also some parts are WIP, so some rules are useless, or redundant. My goal in this phase is to prevent all these TCP connections establish, but allow internet traffic from inside to work. Which is something I didnt managed to make working (only on UDP side), even I though I copied varios examples in wiki, forums, etc…I always cut internet off. There maybe some fundamental problem.

# 2024-01-11 21:04:33 by RouterOS 7.13
# software id = censored
#
# model = CCR2116-12G-4S+
# serial number = censored
/interface bridge
add fast-forward=no name=bridge-home-88
add fast-forward=no name=bridge-servers-78
/interface ethernet
set [ find default-name=sfp-sfpplus1 ] name=sfp-sfpplus1-LAN
set [ find default-name=sfp-sfpplus2 ] name=sfp-sfpplus2-WAN
/interface pppoe-client
add add-default-route=yes disabled=no interface=sfp-sfpplus2-WAN max-mru=1492 \
    max-mtu=1492 mrru=1500 name=pppoe-out1 user=\
    censored
/interface vlan
add interface=bridge-home-88 name=vlan-home-88 vlan-id=88
add interface=bridge-servers-78 name=vlan-servers-78 vlan-id=78
/interface list
add comment=defconf name=LAN
add comment=defconf name=WAN
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/ip pool
add name=dhcp_pool0 ranges=192.168.88.2-192.168.88.254
add name=dhcp_pool1 ranges=192.168.78.2-192.168.78.254
/ip dhcp-server
add address-pool=dhcp_pool0 interface=bridge-home-88 lease-time=1d name=dhcp1
add address-pool=dhcp_pool1 interface=bridge-servers-78 lease-time=1d name=\
    dhcp2
/port
set 0 name=serial0
/system logging action
add name=remotekiwi remote=192.168.78.27 target=remote
/interface bridge port
add bridge=bridge-servers-78 interface=ether2 pvid=78
add bridge=bridge-servers-78 interface=ether3 pvid=78
add bridge=bridge-servers-78 interface=ether4 pvid=78
add bridge=bridge-servers-78 interface=ether5 pvid=78
add bridge=bridge-servers-78 interface=ether6 pvid=78
add bridge=bridge-servers-78 interface=ether7 pvid=78
add bridge=bridge-servers-78 interface=ether8 pvid=78
add bridge=bridge-servers-78 interface=ether9 pvid=78
add bridge=bridge-servers-78 interface=ether10 pvid=78
add bridge=bridge-home-88 interface=ether11 pvid=88
add bridge=bridge-home-88 interface=ether12 pvid=88
add bridge=bridge-home-88 interface=sfp-sfpplus1-LAN pvid=88
add bridge=bridge-home-88 interface=ether1 pvid=88
/ip firewall connection tracking
set udp-stream-timeout=30s
/ip neighbor discovery-settings
set discover-interface-list=!dynamic
/ip settings
set tcp-syncookies=yes
/interface list member
add interface=bridge-home-88 list=LAN
add interface=bridge-servers-78 list=LAN
add interface=sfp-sfpplus2-WAN list=WAN
add interface=pppoe-out1 list=WAN
/ip address
add address=192.168.88.1/24 interface=bridge-home-88 network=192.168.88.0
add address=192.168.78.1/24 interface=bridge-servers-78 network=192.168.78.0
/ip dhcp-server lease
add address=192.168.88.19 client-id=1:9c:6b:0:b:95:15 comment=KVM \
    mac-address=9C:6B:00:0B:95:15 server=dhcp1
add address=192.168.78.253 client-id=1:9c:6b:0:b:92:1e comment=Hypervisor \
    mac-address=9C:6B:00:0B:92:1E server=dhcp2
add address=192.168.78.21 client-id=1:0:c:29:77:75:cb comment=server0 \
    mac-address=00:0C:29:77:75:CB server=dhcp2
add address=192.168.78.15 client-id=\
    ff:9f:6e:85:24:0:2:0:0:ab:11:f3:d9:d1:53:f4:c6:2b:ed comment=\
    Reverse_proxy mac-address=00:0C:29:81:4A:91 server=dhcp2
add address=192.168.78.250 client-id=1:0:c:29:13:ef:cf comment="www" \
    mac-address=00:0C:29:13:EF:CF server=dhcp2
add address=192.168.78.249 client-id=\
    ff:29:c9:f5:c7:0:1:0:1:2c:bd:10:cf:0:c:29:c9:f5:c7 comment=NAS \
    mac-address=00:0C:29:C9:F5:C7 server=dhcp2
add address=192.168.78.27 client-id=1:0:c:29:dd:fa:e6 comment=server1 \
    mac-address=00:0C:29:DD:FA:E6 server=dhcp2
add address=192.168.78.31 client-id=1:0:c:29:75:c9:1d comment=\
    workstation mac-address=00:0C:29:75:C9:1D server=dhcp2
add address=192.168.88.5 client-id=1:8:d1:f9:2d:4e:ef comment=\
    "Tasmota" mac-address=08:D1:F9:2D:4E:EF server=dhcp1
add address=192.168.88.16 client-id=1:20:f8:3b:0:2e:fe comment=\
    "home assistant" mac-address=20:F8:3B:00:2E:FE server=dhcp1
/ip dhcp-server network
add address=192.168.78.0/24 dns-server=192.168.78.1 gateway=192.168.78.1
add address=192.168.88.0/24 dns-server=192.168.88.1 gateway=192.168.88.1
/ip dns
set allow-remote-requests=yes servers=1.1.1.1,8.8.8.8
/ip firewall address-list
add list=ddos-attackers
add list=ddos-targets
add address=censored_allowed_IP comment=censored1 list=censored_list
add address=censored_allowed_IP comment=censored2 list=censored_list
add address=censored_allowed_IP comment=censored3 list=censored_list
add address=censored_allowed_IP comment=censored4 list=censored_list
add address=censored_allowed_IP comment=censored5 list=censored_list
add address=censored_allowed_IP comment=censored6 list=censored_list
add address=censored_allowed_IP comment=censored7 list=censored_list
add address=censored_allowed_IP comment=censored8 list=censored_list
add address=censored_allowed_IP comment=censored9 list=censored_list
add address=censored_allowed_IP comment=censored9 list=censored_list
add address=censored_allowed_IP comment=censored10 list=censored_list
add address=censored_allowed_IP comment=censored11 list=censored_list
add address=censored_allowed_IP comment=censored12 list=censored_list
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=censored_allowed_IP comment="censored13" list=secure
add address=censored_allowed_IP comment="censored14" list=secure
add address=censored_allowed_IP comment="censored15" list=censored_list
add address=1.1.1.1 list=secure_dns
add address=8.8.8.8 list=secure_dns
add address=censored_allowed_IP comment="censored" list=censored_list
add address=censored_allowed_IP comment="censored" list=censored_list
add list=bad_attempts
/ip firewall filter
add action=fasttrack-connection chain=forward connection-state=\
    established,related hw-offload=yes
add action=jump chain=forward comment="All new jump to detect-ddos" \
    connection-state=new jump-target=detect-ddos src-address=!192.168.0.0/16
add action=return chain=detect-ddos dst-limit=32,32,src-and-dst-addresses/10s
add action=add-dst-to-address-list address-list=ddos-targets \
    address-list-timeout=25m chain=detect-ddos
add action=add-src-to-address-list address-list=ddos-attackers \
    address-list-timeout=25m chain=detect-ddos
add action=jump chain=forward comment="SYN Flood protect" connection-state=\
    new jump-target=SYN-Protect protocol=tcp src-address=!192.168.0.0/16 \
    tcp-flags=syn
add action=drop chain=forward comment=\
    "Drop tries to reach not public addresses from LAN" disabled=yes \
    dst-address-list=not_in_internet in-interface=bridge-home-88 \
    out-interface=!bridge-home-88
add action=add-src-to-address-list address-list=port:censored \
    address-list-timeout=1m chain=input comment="Start of port knocking" \
    dst-port=8666 log=yes log-prefix=_endor_knock protocol=tcp
add action=add-src-to-address-list address-list=port:censored2 \
    address-list-timeout=1m chain=input dst-port=censored2 log=yes log-prefix=\
    _endor_knock protocol=tcp src-address-list=port:censored
add action=add-src-to-address-list address-list=bad_attempts \
    address-list-timeout=none-dynamic chain=input dst-port=censored2 log=yes \
    log-prefix=_endor_bad_knock protocol=tcp src-address-list=!port:censored4
add action=add-src-to-address-list address-list=bad_attempts \
    address-list-timeout=none-dynamic chain=input dst-port=censored3 log=yes \
    log-prefix=_endor_bad_knock protocol=tcp src-address-list=!port:censored2
add action=add-src-to-address-list address-list=port:censored3 \
    address-list-timeout=1m chain=input dst-port=censored3 log=yes log-prefix=\
    _endor_knock protocol=tcp src-address-list=port:censored2
add action=add-src-to-address-list address-list=bad_attempts \
    address-list-timeout=none-dynamic chain=input dst-port=censored5 log=yes \
    log-prefix=_endor_bad_knock_last protocol=tcp src-address-list=!port:censored3
add action=add-src-to-address-list address-list=secure address-list-timeout=\
    1m chain=input dst-port=censored5 log=yes log-prefix=_endor_knock_last \
    protocol=tcp src-address-list=port:censored3
add action=accept chain=forward dst-port=853 protocol=tcp
add action=accept chain=forward dst-port="" protocol=tcp src-port=853
add action=accept chain=forward in-interface-list=LAN
add action=accept chain=forward connection-nat-state=dstnat
add action=drop chain=forward connection-nat-state="" connection-state=\
    invalid,related,new,untracked
add action=jump chain=forward comment="jump to ICMP filters" jump-target=icmp \
    protocol=icmp
add action=drop chain=forward comment=\
    "Drop incoming packets that are not NAT`ted" connection-nat-state=!dstnat \
    connection-state=new
add action=drop chain=input connection-state=!established,related,new
add action=drop chain=input connection-state="" disabled=yes src-address=\
    !192.168.0.0/16
add action=accept chain=icmp comment="echo reply" icmp-options=0:0 protocol=\
    icmp
add action=accept chain=icmp comment="net unreachable" icmp-options=3:0 \
    protocol=icmp
add action=accept chain=icmp comment="host unreachable" icmp-options=3:1 \
    protocol=icmp
add action=accept chain=icmp comment=\
    "host unreachable fragmentation required" icmp-options=3:4 protocol=icmp
add action=accept chain=icmp comment="allow echo request" icmp-options=8:0 \
    protocol=icmp
add action=accept chain=icmp comment="allow time exceed" icmp-options=11:0 \
    protocol=icmp
add action=accept chain=icmp comment="allow parameter bad" icmp-options=12:0 \
    protocol=icmp
add action=drop chain=icmp comment="deny all other types"
add action=accept chain=SYN-Protect connection-state=new limit=150,5:packet \
    protocol=tcp tcp-flags=syn
add action=drop chain=SYN-Protect connection-state=new protocol=tcp \
    tcp-flags=syn
/ip firewall nat
add action=masquerade chain=srcnat out-interface=pppoe-out1
add action=dst-nat chain=dstnat comment=server dst-port=5005 \
    in-interface=pppoe-out1 protocol=tcp src-address-list=secure \
    to-addresses=192.168.78.21 to-ports=5005
add action=dst-nat chain=dstnat comment=server dst-port=2593 \
    in-interface=pppoe-out1 protocol=tcp src-address-list=secure \
    to-addresses=192.168.78.21 to-ports=5005
add action=dst-nat chain=dstnat comment=server dst-port=13000 \
    in-interface=pppoe-out1 protocol=tcp src-address-list=censored_list \
    to-addresses=192.168.78.21 to-ports=3389
add action=dst-nat chain=dstnat comment=server dst-port=13003 \
    in-interface=pppoe-out1 protocol=tcp src-address-list=censored_list \
    to-addresses=192.168.78.21 to-ports=3306
add action=dst-nat chain=dstnat comment="server" disabled=yes \
    dst-port=13004 in-interface=pppoe-out1 protocol=tcp src-address-list=\
    censored_list to-addresses=192.168.78.21 to-ports=23
add action=dst-nat chain=dstnat comment=server dst-port=13005 \
    in-interface=pppoe-out1 protocol=tcp src-address-list=censored_list \
    to-addresses=192.168.78.21 to-ports=2597
add action=dst-nat chain=dstnat comment=server dst-port=\
    13006 in-interface=pppoe-out1 protocol=tcp src-address-list=censored_list \
    to-addresses=192.168.78.21 to-ports=2598
add action=dst-nat chain=dstnat comment=server dst-port=23 \
    in-interface=pppoe-out1 protocol=tcp src-address-list=censored_list \
    to-addresses=192.168.78.21 to-ports=23
add action=dst-nat chain=dstnat comment=server dst-port=24 \
    in-interface=pppoe-out1 protocol=tcp src-address-list=censored_list \
    to-addresses=192.168.78.27 to-ports=24
add action=dst-nat chain=dstnat comment=server dst-port=13001 \
    in-interface=pppoe-out1 protocol=tcp src-address-list=censored_list \
    to-addresses=192.168.78.27 to-ports=3389
add action=dst-nat chain=dstnat comment=server dst-port=13007 \
    in-interface=pppoe-out1 protocol=tcp src-address-list=censored_list \
    to-addresses=192.168.78.27 to-ports=8080
add action=dst-nat chain=dstnat comment=server dst-port=13002 \
    in-interface=pppoe-out1 protocol=tcp src-address-list=censored_list \
    to-addresses=192.168.78.31 to-ports=3389
add action=dst-nat chain=dstnat comment=server dst-port=5010 \
    in-interface=pppoe-out1 protocol=tcp src-address-list=secure \
    to-addresses=192.168.78.31 to-ports=5010
add action=dst-nat chain=dstnat comment=server dst-address=\
    censored_ip dst-port=80 in-interface=pppoe-out1 protocol=tcp \
    to-addresses=192.168.78.15 to-ports=80
/ip firewall raw
add action=drop chain=prerouting dst-address-list="" src-address-list=\
    ddos-attackers
add action=drop chain=prerouting dst-port=65372 protocol=tcp
add action=accept chain=prerouting comment=\
    "accept only google and cloudfare DNS" dst-port="" protocol=udp \
    src-address-list=secure_dns src-port=53
add action=drop chain=prerouting comment="drop DNS (UDP) except inside" \
    in-interface-list=!LAN protocol=udp
add action=accept chain=prerouting comment=\
    "defconf: enable for transparent firewall" disabled=yes
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
add action=drop chain=prerouting comment="defconf: drop non global from WAN" \
    in-interface=pppoe-out1 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/16 \
    in-interface-list=WAN
add action=drop chain=prerouting comment=\
    "defconf: drop local if not from default IP range" in-interface-list=LAN \
    src-address=!192.168.0.0/16 src-address-list=""
add action=jump chain=prerouting comment="jump to TCP chain" disabled=yes \
    jump-target=tcp
add action=jump chain=prerouting comment="defconf: jump to TCP chain" \
    jump-target=tcp protocol=tcp
add action=jump chain=prerouting comment="defconf: jump to bad TCP chain" \
    jump-target=bad_tcp protocol=tcp
add action=accept chain=tcp protocol=tcp src-address-list=censored_list
add action=accept chain=tcp dst-port=80 protocol=tcp
add action=accept chain=tcp dst-port=443 protocol=tcp
add action=accept chain=tcp dst-port=8666 protocol=tcp
add action=accept chain=tcp dst-port=915 protocol=tcp
add action=accept chain=tcp dst-port=6000 protocol=tcp
add action=accept chain=tcp dst-port=9000 protocol=tcp
add action=accept chain=tcp dst-port=2593 protocol=tcp
add action=accept chain=tcp dst-port=5010 protocol=tcp
add action=accept chain=tcp dst-port=5005 protocol=tcp
add action=accept chain=tcp dst-address=192.168.0.0/16 in-interface=\
    pppoe-out1
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=bad_tcp comment="defconf: TCP flag filter" protocol=tcp \
    tcp-flags=!fin,!syn,!rst,!ack
add action=drop chain=bad_tcp comment=defconf protocol=tcp tcp-flags=fin,syn
add action=drop chain=bad_tcp comment=defconf protocol=tcp tcp-flags=fin,rst
add action=drop chain=bad_tcp comment=defconf protocol=tcp tcp-flags=fin,!ack
add action=drop chain=bad_tcp comment=defconf protocol=tcp tcp-flags=fin,urg
add action=drop chain=bad_tcp comment=defconf protocol=tcp tcp-flags=syn,rst
add action=drop chain=bad_tcp comment=defconf 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
/ip service
set telnet disabled=yes
set ftp disabled=yes
set www address=192.168.88.0/24
set ssh disabled=yes
set api disabled=yes
set api-ssl disabled=yes
/system clock
set time-zone-name=censored
/system logging
add action=remotekiwi topics=info
/system note
set show-at-login=no
/system routerboard settings
set enter-setup-on=delete-key
/tool graphing interface
add allow-address=192.168.0.0/16 interface=pppoe-out1
add allow-address=192.168.0.0/16 interface=bridge-servers-78
/tool graphing queue
add allow-address=192.168.0.0/16
/tool graphing resource
add allow-address=192.168.0.0/16

I have also question related to dynamic allowed lists. On my dstnat rule I have dynamic list of allowed IPs (duration cca 1 minute), to allow only verified IPs in. After this list expires, connection is still established (which is OK for me), but I dont understand why. I thought dstnat happens in prerouting phase and until packets are send to forwad or input phase, there are no fast forward, connection state or filtering rules applied..

Thanks a lot for any insights!

Do I understand well, that it reestablishes nat entry in case of some timeoutst? That turning it off it makes it more strict for evalluating what is new connection (must have syn flag and does not match any existing connection)? Are there any negative consequences for turning this off (real life experience)? Thanks!

Actually this is what I am trying to do. One drop all rule in end of filtering, but still allowing internet to work via rules before that. On UDP I succeded, but not on TCP. Currently I am dropping everything except established connections (when i start to drop, internet from inside is not working). But that ddos was established connection…And I dont understand why, it is not going through nat to any server behind, because only verified IPs are dstnated.

Can you post you ip firewall config, with the sensitive bits removed?

I saw you posted earlier. Having a look.

My comments:

The fasttrack, invalid, and established in the chain=forward should come on top, then the rules for the new packets.

The rule with the connection-nat-state=dstnat accepts everything coming from any network, as long as a dstnat was done. Consider changing it to reflect the NAT (source, real destination, real port).

/ip firewall filter
...
add action=accept chain=forward connection-nat-state=dstnat
...

You have an empty port, not sure how the router reacts to that.

/ip firewall filter
...
add action=accept chain=forward dst-port="" protocol=tcp src-port=853

Similar situation a bit further, empty connection-nat-state.

/ip firewall filter
...
add action=drop chain=forward connection-nat-state="" connection-state=\
    invalid,related,new,untracked

Not really sure what the empty address-list is or what it does but it could be that it never matches.

/ip firewall raw
...
add action=drop chain=prerouting dst-address-list="" src-address-list=\
    ddos-attackers

Same a bit further

/ip firewall raw
...
add action=drop chain=prerouting comment=\
    "defconf: drop local if not from default IP range" in-interface-list=LAN \
    src-address=!192.168.0.0/16 src-address-list=""

The destination you obscured on the screenshot, destination port 65372, is it the IP of the Mikrotik itself or one of the NAT addresses?

The chain=input rulebase misses all the bits for fasttrack, established, invalid, related and so forth, and doesn’t have a global drop for the WAN.

This drops anything coming directly at the router from the identified DDoSers. Likely redundant with the ACL in the raw prerouting, but could catch stuff if the other one doesn’t work. I readded the default rules, plus a few ones for accepting local stuff, your remote management addresses and block everything else.

/ip firewall filter
add action=drop chain=input comment="Cybervermin B-Gone" in-interface-list=WAN src-address-list=ddos-attackers
add chain=input action=accept connection-state=established,related,untracked comment="default rule for accepting established connections, should be 0"
add chain=input action=drop connection-state=invalid comment="default rule for refusing invalid packets"
# Add this one if you manage the router from the 'ternet
add chain=input action=accept in-interface-list=WAN src-address-list=whereiadministerfrom comment="Remote management - consider using a VPN"
add chain=input action=accept in-interface-list=LAN comment="Local stuff, don't block"
add chain=input action=drop in-interface-list=!LAN comment="Block everything else not from the local network"

This is my public IP, so address of mikrotik router. Thanks a lot for your comments!

Then the last rule of the input chain I suggested will take care of it.

Btw, are things getting better?

you will avoid null connections, established connections with 0 replied byte. Have the LOOSE CONNTRACK disabled.

I have it enabled. But advice was to disable it. So I am quite confused now :slight_smile: