#!/bin/bash # # script to unblock IPs host_ip="0.0.0.0/0" # Set to your host IP incoming_chain="INPUT" # Modify if needed outgoing_chain="OUTPUT" # Modify uf needed target_chain="DROP" # Whee to send the packet. Usually this or REJECT. # Check for and remove inbound rules echo "Checking $incoming_chain for: $1" iptables -C "$incoming_chain" -s "$1" -d "$host_ip" -p all -j "$target_chain" if [ $? == 0 ]; then echo "Found Unblocking.." iptables -D "$incoming_chain" -s "$1" -d "$host_ip" -p all -j "$target_chain" else echo "$1 not $incoming_chain chain." fi # Check for and remove outbound rules echo "Checking $outgoing_chain for: $1" iptables -C "$outgoing_chain" -s "$1" -d "$host_ip" -p all -j "$target_chain" if [ $? == 0 ]; then echo "Found Unblocking.." iptables -D "$outgoing_chain" -s "$1" -d "$host_ip" -p all -j "$target_chain" else echo "$1 not $outgoing_chain chain." fi