diff --git a/iptables.sh b/iptables.sh index 163b08c..45d8824 100644 --- a/iptables.sh +++ b/iptables.sh @@ -11,15 +11,14 @@ declare -A TABLE_RULES echo "[*] Extracting rules by table..." current_table="" -while IFS= read -r line; do - if [[ "$line" =~ ^\* ]]; then - current_table="${line:1}" - TABLE_RULES["$current_table"]="$TEMP_DIR/$current_table.rules" - > "${TABLE_RULES[$current_table]}" - elif [[ "$line" =~ ^-A ]]; then - echo "$line" >> "${TABLE_RULES[$current_table]}" +while IFS= read -r rule; do + if [[ -n "$rule" && "$rule" == -A* ]]; then + echo " → $rule" + if ! eval "iptables -t $table $rule"; then + echo "[!] Failed to apply: $rule" fi -done < "$BACKUP_FILE" + fi +done <<< "$DEDUPED" for table in "${!TABLE_RULES[@]}"; do echo "[*] Processing table: $table"