Script to BLOCK the ports ------------------------ #!/bin/bash #Block certain outgoing ports #blockports.sh iptables -P output ACCEPT iptables -A output -p tcp -sport portnumbers -j DROP ------------------------ Script to OPEN the ports ------------------------ #!/bin/bash #Open outgoing ports #blockports.sh iptables -A output -p tcp -sport portnumbers -j ACCEPT ------------------------ Entries in crontab (sudo crontab -e) Run block port script at midnight Run open port script at noon. ------------------------ # m h dom mon dow command 0 0 * * * /bin/bash /path/to/script/blockports.sh 0 12 * * * /bin/bash /path/to/script/openports.sh