Commit 2f323861 authored by Vitaly Lipatov's avatar Vitaly Lipatov

eterban.sh: add check command for exact IP lookup

Checks IPv4/IPv6 ban lists, firehol and whitelist via ipset test. Co-Authored-By: 's avatarClaude Opus 4.6 (1M context) <noreply@anthropic.com>
parent 40fec33d
......@@ -30,6 +30,40 @@ if [ "$command" = "ban" ] ; then
exit
fi
if [ "$command" = "check" ] ; then
ip="$1"
if [ -z "$ip" ] ; then
echo "Usage: eterban check <ip>"
exit 1
fi
found=0
if echo "$ip" | grep -q ':' ; then
# IPv6
if ipset test $setname_ipv6 "$ip" 2>/dev/null ; then
echo "$ip is BANNED (in $setname_ipv6)"
found=1
fi
else
# IPv4
if ipset test $setname "$ip" 2>/dev/null ; then
echo "$ip is BANNED (in $setname)"
found=1
fi
if ipset test firehol_level1 "$ip" 2>/dev/null ; then
echo "$ip is in firehol_level1"
found=1
fi
if ipset test eterban_white "$ip" 2>/dev/null ; then
echo "$ip is WHITELISTED"
found=1
fi
fi
if [ "$found" = "0" ] ; then
echo "$ip is NOT banned"
fi
exit
fi
if [ "$command" = "search" ] ; then
mask="$(echo "$1" | sed -e 's|\.|\\.|g')"
ipset list $setname | grep --color "$mask"
......@@ -70,6 +104,7 @@ Usage:
Commands:
count - print count of banned IPs
list - list all banned IPs
check <ip> - check if IP is banned (exact match)
search <ip> - search for ip in the list of banned IPs
unban <ip> - unban IP
ban <ip> - ban IP
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment