Protect Router From DDOS Attacks - Mikrotik Script RouterOS

Anticipate DDoS attacks, namely by limiting the number of connections in firewall rules. 

When there is a DDoS attack, the system detects the number of connection requests exceeding the specified limit.

/ip firewall filter
add chain=forward connection-state=new action=jump jump-target=block-ddos
add chain=forward connection-state=new src-address-list=ddoser dst-address-list=ddosed action=drop
add chain=block-ddos dst-limit=50,50,src-and-dst-addresses/10s action=return
add chain=block-ddos action=add-dst-to-address-list address-list=ddosed address-list-timeout=10m
add chain=block-ddos action=add-src-to-address-list address-list=ddoser address-list-timeout=10m
Credit: Unknown