Created
March 20, 2017 12:11
-
-
Save lildude/4b76b96cb1c0d0b669fc3eeb6ea1187e to your computer and use it in GitHub Desktop.
Flush and delete all nftables rules, chains and tables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Name: nft-flush | |
# Auth: Gavin Lloyd <[email protected]> | |
# Date: 06 Mar 2014 | |
# Desc: Flush and delete all nftables rules, chains and tables | |
# | |
NFT=/usr/bin/nft | |
FAMILIES="ip ip6 arp bridge" | |
for FAMILY in $FAMILIES; do | |
TABLES=$($NFT list tables $FAMILY | grep "^table\s" | cut -d' ' -f2) | |
for TABLE in $TABLES; do | |
CHAINS=$($NFT list table $FAMILY $TABLE | grep "^\schain\s" | cut -d' ' -f2) | |
for CHAIN in $CHAINS; do | |
echo "Flushing chain: $FAMILY->$TABLE->$CHAIN" | |
$NFT flush chain $FAMILY $TABLE $CHAIN | |
$NFT delete chain $FAMILY $TABLE $CHAIN | |
done | |
echo "Flushing table: $FAMILY->$TABLE" | |
$NFT flush table $FAMILY $TABLE | |
$NFT delete table $FAMILY $TABLE | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should be
-f3
as mentioned by @ohhai.Edit: Better solution than listing families would be: