summarylogtreecommitdiffstats
path: root/iptables-nft-flush
diff options
context:
space:
mode:
authoredward-p2019-03-26 11:46:58 +0800
committeredward-p2019-03-26 11:46:58 +0800
commit25558cc7a0de03c3ec46242039418621705ec90d (patch)
tree702f00453a9e6504ed8ae3c339d9064be7748e34 /iptables-nft-flush
downloadaur-25558cc7a0de03c3ec46242039418621705ec90d.tar.gz
initial commit
Diffstat (limited to 'iptables-nft-flush')
-rw-r--r--iptables-nft-flush18
1 files changed, 18 insertions, 0 deletions
diff --git a/iptables-nft-flush b/iptables-nft-flush
new file mode 100644
index 000000000000..5038d329ac96
--- /dev/null
+++ b/iptables-nft-flush
@@ -0,0 +1,18 @@
+#!/bin/bash
+#
+# Usage: iptables-flush [6]
+#
+
+iptables=ip$1tables
+if ! type -p "$iptables" &>/dev/null; then
+ echo "error: invalid argument"
+ exit 1
+fi
+
+while read -r table; do
+ tables+=("/usr/share/iptables/empty-$table.rules")
+done < <(nft list tables | sed -n "s/table ip$1 //p")
+
+if (( ${#tables[*]} )); then
+ cat "${tables[@]}" | "$iptables-restore"
+fi