Create and use the following script:
cat > closeRB.sh
#!/bin/bash
usage() {
cat <<EOF
Usage:
$0 open|close
Script to open/close the RB with iptables rules.
EOF
}
RB=`/bin/hostname`
#echo "RB="$RB
echo "/sbin/iptables -D INPUT -p tcp --source $RB --destination-port
9002 -j ACCEPT"
case "$1" in
open)
/sbin/iptables -D INPUT -p tcp --source 127.0.0.1 --destination-port 9002 -j ACCEPT
/sbin/iptables -D INPUT -p tcp --source $RB --destination-port 9002 -j ACCEPT
/sbin/iptables -D INPUT -p tcp --destination-port 9002 -j REJECT
;;
close)
/sbin/iptables -I INPUT 1 -p tcp --source 127.0.0.1 --destination-port 9002 -j ACCEPT
/sbin/iptables -I INPUT 2 -p tcp --source $RB --destination-port 9002 -j ACCEPT
/sbin/iptables -I INPUT 4 -p tcp --destination-port 9002 -j REJECT
;;
*)
usage
exit
esac
[Ctrl-C]
chmod 755 closeRB.sh
Suggested by this link.