I have in one of my machines a pretty annoying situation related to the fact if the UBUNTU based firewall reboot’s, the firewall doesn’t start automatically…
This is pretty annoying because it means that after a power failure, there is a need for manual intervention to restore exterior access trough the firewall to internal servers.
The solution?
Well I’ve made a bash script, named resetfw.sh that checks the server uptime and if it falls bellow a threshold of 10 minutes, it restarts the firewall:
DAYS=`uptime | cut -d ‘ ‘ -f 4`
HOURS=`uptime | cut -d ‘ ‘ -f 6`
HOUR=`echo $HOURS | cut -d ‘:’ -f 1`
MIN_NP=`echo $HOURS | cut -d ‘:’ -f 2`
MIN=`echo $MIN_NP | cut -c 1-2`if [ $DAYS = "0" ]; then
if [ $HOUR = "0" ]; then
if [ $MIN -lt "10" ]; then
/etc/init.d/shorewall stop
/etc/init.d/shorewall start
/etc/init.d/shorewall stop
/etc/init.d/shorewall restartlogger “Firewall reset due to reboot: Uptime on action: $DAYS days, $HOUR:$MIN”
fi
fifi
Then all we have to due is to run this script periodically through the crontab:
*/5 * * * * /root/resetfw.sh
