2

For iptables I used to run iptables-restore < /etc/iptables/rules.v4 which would flush rules and restore them from /etc/iptables/rules.v4.

For nftables, I found nft -f /etc/nftables.conf, but the rules are not flushed* prior to restoring them from /etc/nftables.conf.

Is there a one-liner that flushes nftables rules and restores them from a file?

*Note that any rules already loaded are not automatically flushed.

sunknudsen
  • 581
  • 10
  • 26

1 Answers1

3

Adding flush ruleset at the beginning of /etc/nftables.conf does the trick. See the notes on https://wiki.nftables.org/wiki-nftables/index.php/Atomic_rule_replacement.

sunknudsen
  • 581
  • 10
  • 26