Skip to content

Instantly share code, notes, and snippets.

@amdprophet
Forked from x-yuri/reset-iptables.sh
Created May 14, 2021 19:17
Show Gist options
  • Save amdprophet/07b7466e420aa92e5dc16d7bc30fcaac to your computer and use it in GitHub Desktop.
Save amdprophet/07b7466e420aa92e5dc16d7bc30fcaac to your computer and use it in GitHub Desktop.

Revisions

  1. @x-yuri x-yuri revised this gist Jun 29, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion reset-iptables.sh
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,11 @@
    #!/usr/bin/env bash
    set -eu
    declare -A chains=(
    [filter]=INPUT:FORWARD:OUTPUT
    [raw]=PREROUTING:OUTPUT
    [mangle]=PREROUTING:INPUT:FORWARD:OUTPUT:POSTROUTING
    [security]=INPUT:FORWARD:OUTPUT
    [nat]=PREROUTING:INPUT:OUTPUT:POSTROUTING
    [filter]=INPUT:FORWARD:OUTPUT
    )
    for table in "${!chains[@]}"; do
    echo "${chains[$table]}" | tr : $"\n" | while IFS= read -r; do
  2. @x-yuri x-yuri created this gist Jun 29, 2019.
    16 changes: 16 additions & 0 deletions reset-iptables.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    #!/usr/bin/env bash
    set -eu
    declare -A chains=(
    [raw]=PREROUTING:OUTPUT
    [mangle]=PREROUTING:INPUT:FORWARD:OUTPUT:POSTROUTING
    [security]=INPUT:FORWARD:OUTPUT
    [nat]=PREROUTING:INPUT:OUTPUT:POSTROUTING
    [filter]=INPUT:FORWARD:OUTPUT
    )
    for table in "${!chains[@]}"; do
    echo "${chains[$table]}" | tr : $"\n" | while IFS= read -r; do
    iptables -t "$table" -P "$REPLY" ACCEPT
    done
    iptables -t "$table" -F
    iptables -t "$table" -X
    done