Monitoring UDP datagrams

Run script udpstat.sh in console

#!/bin/sh
while true
do
HOUR=`date '+%H'`
echo $HOUR
sar -n UDP 1 -1 >/var/log/stats/udpstats$HOUR.txt
done

Add job to crontab

0 * * * * /usr/bin/kill $(/usr/bin/ps aux |/usr/bin/grep '[s]ar -n UDP 1 -1' |/usr/bin/awk '{print $2}')

Limit UDP packets

/sbin/iptables -A OUTPUT -p udp -m state --state NEW -j ACCEPT
/sbin/iptables -A OUTPUT -p udp -m limit --limit 10000/s -j ACCEPT
/sbin/iptables -A OUTPUT -p udp -j DROP

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.