diff --git a/iptables-show-recent.sh b/iptables-show-recent.sh new file mode 100755 index 0000000..f2a4169 --- /dev/null +++ b/iptables-show-recent.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Author: Oliver Ladner +# 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