From d32cfa07ef7f897d16e053305ce6feef397d5794 Mon Sep 17 00:00:00 2001 From: vijay Date: Thu, 8 May 2025 02:08:04 +0000 Subject: [PATCH] Update manage_iptables --- manage_iptables | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/manage_iptables b/manage_iptables index 11b93f5..0df9c27 100644 --- a/manage_iptables +++ b/manage_iptables @@ -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..."