Last active
December 19, 2015 17:09
-
-
Save pyxze/5989284 to your computer and use it in GitHub Desktop.
idempotent iptables command
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
REJECT_RULE_NO=$(iptables -L INPUT --line-numbers | grep 'REJECT' | awk '{print $1}'); if ! (iptables-save | grep -q -- "-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT"); then iptables -I INPUT $REJECT_RULE_NO -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT; fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment