Created
December 17, 2013 15:21
-
-
Save danmactough/8006629 to your computer and use it in GitHub Desktop.
Block port except via localhost. Optionally, pass `-D` as second argument to remove the block.
This file contains hidden or 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 | |
PORT=$1 | |
ACTION=${2:-"-A"} | |
iptables $ACTION INPUT -p tcp -s localhost --dport $PORT -j ACCEPT | |
iptables $ACTION INPUT -p tcp --dport $PORT -j DROP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment