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