Search This Blog

how to reset iptables

  • Reset iptables(IPV4):
      # set default policies to allow everything
      sudo /sbin/iptables --policy INPUT   ACCEPT
      sudo /sbin/iptables --policy OUTPUT  ACCEPT
      sudo /sbin/iptables --policy FORWARD ACCEPT
    
      # flush rules
      sudo /sbin/iptables -F
    
      # delete all user defined chains
      sudo /sbin/iptables -X
    
      # zero counters
      sudo /sbin/iptables -Z
    
      # reset all the tables
      for table in filter nat mangle; do
        sudo /sbin/iptables -t $table -F
        sudo /sbin/iptables -t $table -X
        sudo /sbin/iptables -t $table -Z
      done
    
  • Reset ip6tables(IPV6):
      # set default policies to allow everything
      sudo /sbin/ip6tables --policy INPUT   ACCEPT
      sudo /sbin/ip6tables --policy OUTPUT  ACCEPT
      sudo /sbin/ip6tables --policy FORWARD ACCEPT
    
      # flush rules
      sudo /sbin/ip6tables -F
    
      # delete all user defined chains
      sudo /sbin/ip6tables -X
    
      # zero counters
      sudo /sbin/ip6tables -Z
    
      # reset all the tables
      for table in filter mangle; do
        sudo /sbin/ip6tables -t $table -F
        sudo /sbin/ip6tables -t $table -X
        sudo /sbin/ip6tables -t $table -Z
      done
    

2 comments: