Step1:
Add the below entry in syslog to log the iptables activity in to seperate file.
kern.* /var/log/firewall.log
Step2:
Limit the traffic in single second.
# iptables -A INPUT -p tcp --dport 53 -m state --state NEW -m recent --set --name DNSQF --rsource
chmod 600 /sys/module/xt_recent/parameters/ip_pkt_list_tot
echo 200 > /sys/module/xt_recent/parameters/ip_pkt_list_tot
chmod 400 /sys/module/xt_recent/parameters/ip_pkt_list_tot
echo 200 > /sys/module/xt_recent/parameters/ip_pkt_list_tot
chmod 400 /sys/module/xt_recent/parameters/ip_pkt_list_tot
# iptables -A INPUT -p tcp --dport 53 -m state --state NEW -m recent --update --seconds 1 --hitcount "30" --name DNSQF --rsource -j LOG
# iptables -A INPUT -p tcp --dport 53 -m state --state NEW -m recent --update --seconds 1 --hitcount "30" --name DNSQF --rsource -j DROP
# iptables -A INPUT -p tcp --dport 53 -m state --state NEW -m recent --update --seconds 1 --hitcount "30" --name DNSQF --rsource -j DROP
Step3:
Limit the traffic in 5 Sec (Backup rule)
# iptables -A INPUT -p tcp --dport 53 -m state --state NEW -m recent --set --name DNSHF --rsource
# iptables -A INPUT -p tcp --dport 53 -m state --state NEW -m recent --update --seconds 5 --hitcount "150" --name DNSHF --rsource -j LOG
# iptables -A INPUT -p tcp --dport 53 -m state --state NEW -m recent --update --seconds 5 --hitcount "150" --name DNSHF --rsource -j DROP
# iptables -A INPUT -p tcp --dport 53 -m state --state NEW -m recent --update --seconds 5 --hitcount "150" --name DNSHF --rsource -j DROP
Any traffic hitting the rule will be logged to the file /var/log/firewall.log or can use below command
#iptables -L -n -v