Page MenuHomeClusterLabs Projects

booth_path
No OneTemporary

booth_path

#!/bin/sh
#
# manage iptables rules for the given port
#
[ $# -lt 1 ] && exit
action=$1
port=${2:-9929}
testip() {
local chain=$1
iptables -L $chain | grep -wq ^DROP.*$port
}
logcmd() {
logger -p local7.info "$*"
eval $*
}
case "$action" in
start)
logcmd iptables -D INPUT -p udp --dport $port -j DROP
logcmd iptables -D OUTPUT -p udp --dport $port -j DROP
logcmd iptables -D INPUT -p udp --sport $port -j DROP
logcmd iptables -D OUTPUT -p udp --sport $port -j DROP
;;
stop)
testip INPUT && {
echo "packets from/to $port already being dropped!"
exit
}
logcmd iptables -A INPUT -p udp --dport $port -j DROP
logcmd iptables -A OUTPUT -p udp --dport $port -j DROP
logcmd iptables -A INPUT -p udp --sport $port -j DROP
logcmd iptables -A OUTPUT -p udp --sport $port -j DROP
;;
esac

File Metadata

Mime Type
text/x-shellscript
Expires
Sat, Jan 25, 6:31 AM (1 d, 7 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1116023
Default Alt Text
booth_path (786 B)

Event Timeline