#!/bin/sh # Check for root user CURR_USER=`/usr/bin/whoami` if [ "$CURR_USER" != "root" ]; then echo "I need root rights... Please login from root" exit fi # Save current rules to file iptables-save > /etc/iptables.up.rules cat /etc/iptables.up.rules # Add auto load at server startup ifprefile="/etc/network/if-pre-up.d/iptables" if [ ! -f "$ifprefile" ]; then touch $ifprefile echo "#!/bin/sh" > $ifprefile echo "" >> $ifprefile echo "/sbin/iptables-restore < /etc/iptables.up.rules" >> $ifprefile chmod 0744 $ifprefile fi