add filter_ip.sh

master
ademant 2019-02-11 15:03:08 +01:00
parent f807b0d26b
commit 0c2525f4ef
2 changed files with 26 additions and 0 deletions

24
filter_ip.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/sh
startstop=$1
if [ -z "$startstop" ]; then
startstop="start"
fi
table="OUTPUT"
ipsrc=$(cat ./ip.txt)
case "$startstop" in
start)
for i in $ipsrc; do
iptables -I ${table} -d $i -m comment --comment "ipfiltering" -j DROP
done
;;
stop)
ipdel=$(iptables -S ${table} |grep ipfiltering|sed -e 's/\ /\n/g'|grep \\-d -A 1 |grep \\.|cut -d/ -f1)
for i in $ipdel; do
iptables -D ${table} -d $i -m comment --comment "ipfiltering" -j DROP
done
;;
esac

2
ip.txt Normal file
View File

@ -0,0 +1,2 @@
172.24.42.107
172.24.42.108