Update manage_iptables
This commit is contained in:
parent
4d4b2f02aa
commit
d32cfa07ef
@ -9,9 +9,9 @@ show_menu() {
|
|||||||
echo "=============================="
|
echo "=============================="
|
||||||
echo "1. List current iptables rules"
|
echo "1. List current iptables rules"
|
||||||
echo "2. Add IP address to whitelist (ACCEPT)"
|
echo "2. Add IP address to whitelist (ACCEPT)"
|
||||||
echo "3. Remove IP address from blacklist (DROP)"
|
echo "3. Remove IP address from whitelist (ACCEPT)"
|
||||||
echo "4. Add IP address to blacklist (DROP)"
|
echo "4. Add IP address to blacklist (DROP)"
|
||||||
echo "5. Remove IP address from whitelist (ACCEPT)"
|
echo "5. Remove IP address from blacklist (DROP)"
|
||||||
echo "6. Exit"
|
echo "6. Exit"
|
||||||
echo "=============================="
|
echo "=============================="
|
||||||
}
|
}
|
||||||
@ -45,14 +45,14 @@ add_to_whitelist() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to remove IP address from blacklist
|
# Function to remove IP address from whitelist
|
||||||
remove_from_blacklist() {
|
remove_from_whitelist() {
|
||||||
read -p "Enter the IP address to remove from blacklist: " ip_address
|
read -p "Enter the IP address to remove from whitelist: " ip_address
|
||||||
if is_in_blacklist "$ip_address"; then
|
if is_in_whitelist "$ip_address"; then
|
||||||
sudo iptables -D INPUT -s "$ip_address" -j DROP
|
sudo iptables -D INPUT -s "$ip_address" -j ACCEPT
|
||||||
echo "IP address $ip_address removed from blacklist."
|
echo "IP address $ip_address removed from whitelist."
|
||||||
else
|
else
|
||||||
echo "IP address $ip_address is not in the blacklist."
|
echo "IP address $ip_address is not in the whitelist."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,14 +67,14 @@ add_to_blacklist() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to remove IP address from whitelist
|
# Function to remove IP address from blacklist
|
||||||
remove_from_whitelist() {
|
remove_from_blacklist() {
|
||||||
read -p "Enter the IP address to remove from whitelist: " ip_address
|
read -p "Enter the IP address to remove from blacklist: " ip_address
|
||||||
if is_in_whitelist "$ip_address"; then
|
if is_in_blacklist "$ip_address"; then
|
||||||
sudo iptables -D INPUT -s "$ip_address" -j ACCEPT
|
sudo iptables -D INPUT -s "$ip_address" -j DROP
|
||||||
echo "IP address $ip_address removed from whitelist."
|
echo "IP address $ip_address removed from blacklist."
|
||||||
else
|
else
|
||||||
echo "IP address $ip_address is not in the whitelist."
|
echo "IP address $ip_address is not in the blacklist."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,13 +97,13 @@ while true; do
|
|||||||
add_to_whitelist
|
add_to_whitelist
|
||||||
;;
|
;;
|
||||||
3)
|
3)
|
||||||
remove_from_blacklist
|
remove_from_whitelist
|
||||||
;;
|
;;
|
||||||
4)
|
4)
|
||||||
add_to_blacklist
|
add_to_blacklist
|
||||||
;;
|
;;
|
||||||
5)
|
5)
|
||||||
remove_from_whitelist
|
remove_from_blacklist
|
||||||
;;
|
;;
|
||||||
6)
|
6)
|
||||||
echo "Exiting..."
|
echo "Exiting..."
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user