summaryrefslogtreecommitdiff
path: root/unblock
blob: f685690f4efcc6809241af02df55978bde7d2934 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/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