Created
November 15, 2013 18:56
-
-
Save gene1wood/7489673 to your computer and use it in GitHub Desktop.
Script to delete an iptables rule inserted by knockd based on an IP address
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script is called by knockd and configured in the knockd.conf : https://gist.github.com/gene1wood/7489372 | |
if [ -z "$1" ]; then | |
echo "usage : $0 IPADDRESS" | |
exit 1 | |
fi | |
num="`iptables --list INPUT -n --line-numbers | awk '$13 == "knockd" {print $0}' | awk -v IP=$1 '$5 == IP {print $1}' | head -1`" | |
if [ -n "$num" ]; then | |
iptables -D INPUT $num | |
else | |
echo "Couldn't find IP $1" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment