iptables-write 535 B

12345678910111213141516171819202122
  1. #!/bin/sh
  2. # Check for root user
  3. CURR_USER=`/usr/bin/whoami`
  4. if [ "$CURR_USER" != "root" ]; then
  5. echo "I need root rights... Please login from root"
  6. exit
  7. fi
  8. # Save current rules to file
  9. iptables-save > /etc/iptables.up.rules
  10. cat /etc/iptables.up.rules
  11. # Add auto load at server startup
  12. ifprefile="/etc/network/if-pre-up.d/iptables"
  13. if [ ! -f "$ifprefile" ]; then
  14. touch $ifprefile
  15. echo "#!/bin/sh" > $ifprefile
  16. echo "" >> $ifprefile
  17. echo "/sbin/iptables-restore < /etc/iptables.up.rules" >> $ifprefile
  18. chmod 0744 $ifprefile
  19. fi