iptables-http-clear 447 B

123456789101112131415161718192021
  1. #!/bin/bash
  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. # Clear all rules for port 80
  9. while :
  10. do
  11. last_num="0"
  12. while read rnum; do
  13. last_num="$rnum"
  14. done < <(/sbin/iptables -L INPUT -n --line-numbers | /bin/grep 'tcp dpt:80' | /usr/bin/awk '{print $1}')
  15. if [ "$last_num" = "0" ]; then
  16. break
  17. fi
  18. /sbin/iptables -D INPUT $last_num
  19. done