43 lines
826 B
Bash
Executable File
43 lines
826 B
Bash
Executable File
#!/bin/bash
|
|
|
|
echo ""
|
|
|
|
NUM=$(sudo iptables -L --line-numbers | grep 'usa_state' | head -n 1 | cut -c1)
|
|
|
|
if [ -z "$NUM" ]
|
|
then
|
|
if [ $@ == "enable" ]
|
|
then
|
|
echo "Enabling IP White Listing"
|
|
|
|
sudo iptables -A INPUT -m set ! --match-set usa_state src -j DROP &>/dev/null
|
|
|
|
if [ $? -eq 0 ]
|
|
then
|
|
echo "Success"
|
|
else
|
|
echo "Error"
|
|
fi
|
|
else
|
|
echo "Already Disabled"
|
|
fi
|
|
else
|
|
if [ $@ == "disable" ]
|
|
then
|
|
echo "Disabling IP White Listing"
|
|
|
|
NUM=`iptables -L --line-numbers | grep 'usa_state' | head -n 1 | cut -c1`
|
|
sudo iptables -D INPUT $NUM &>/dev/null
|
|
|
|
if [ $? -eq 0 ]
|
|
then
|
|
echo "Sucess"
|
|
else
|
|
echo "Error"
|
|
fi
|
|
else
|
|
echo "Already Enabled"
|
|
fi
|
|
|
|
fi
|