added iptables recent tracking script

This commit is contained in:
Oliver Ladner 2013-04-12 11:21:39 +02:00
commit 862612a8e9

14
iptables-show-recent.sh Executable file
View file

@ -0,0 +1,14 @@
#!/bin/bash
# Author: Oliver Ladner <oli@lugh.ch>
# License: LGPL
#
# Shows recent connections tracked by the iptables "recent" module.
# Requirements:
# - iptables with rules for the "recent" module
# - Shell cmds: geoiplookup
for ip in $(cat /proc/net/xt_recent/DEFAULT | awk {'print $1'} | sed 's/src=//'); do
IP=$(geoiplookup $ip | sed 's/GeoIP Country Edition:.*, //')
COUNT=$(cat /proc/net/xt_recent/DEFAULT | grep "$ip" | awk {'print $7'})
echo -e "$COUNT\t$ip\t($IP)"
done | sort -rn