Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ################
- ################
- ### usage: openport [-p] port
- ### usage: closeport [-p PROTOCOL] port
- ### options:
- ### -p, --protocol : protocol (default=tcp)
- ################
- #
- #
- function openport () {
- protocol=tcp
- OPTS=`getopt -o p: -l protocol: -- "$@"`
- if [ $? -ne 0 ];
- then
- return 1
- fi
- eval set -- "$OPTS"
- while true ; do
- case "$1" in
- -p|--protocol) protocol=$2; shift 2;;
- --) shift; break;;
- *) break;;
- esac
- done
- port=$1
- sudo iptables -A INPUT -p $protocol --dport $port -j ACCEPT; }
- function closeport () {
- protocol=tcp
- OPTS=`getopt -o p: -l protocol: -- "$@"`
- if [ $? -ne 0 ];
- then
- return 1
- fi
- eval set -- "$OPTS"
- while true ; do
- case "$1" in
- -p|--protocol) protocol=$2; shift 2;;
- --) shift; break;;
- *) break;;
- esac
- done
- port=$1
- sudo iptables -A INPUT -p $protocol --dport $port -j REJECT; }
- #############################################3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement