summarylogtreecommitdiffstats
path: root/iptables-nft-flush
blob: 5038d329ac967c1247127ed29120318308bf1c6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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