Skip to content

Instantly share code, notes, and snippets.

@MrStonedOne
Last active December 29, 2023 22:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MrStonedOne/20be12dd7715809c7d7b1d3b5cc47b3f to your computer and use it in GitHub Desktop.
Save MrStonedOne/20be12dd7715809c7d7b1d3b5cc47b3f to your computer and use it in GitHub Desktop.
Load newline ipv4 subnet list into nftables set. ip blacklist blackhole denylist filter
nft add set netdev filter blackhole {type ipv4_addr\; counter\; auto-merge\; flags interval\; elements={$(grep -oP '^ *(?:[0-9]{1,3}\.){3}[0-9]{1,3}/{0,1}[0-9]{0,2}' blacklist.txt | tr '\n' ',' | sed 's/,*$//')}\;}
# (don't forget to add a drop rule checking the @blackhole rule)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment