-
Notifications
You must be signed in to change notification settings - Fork 221
Open
Labels
Description
The nftables CLI supports JSON input and JSON output, for example:
# Check JSON file
nft --check --json --file /tmp/nft.json
# List curent rules as JSON
nft --json --stateless list ruleset | jq
# Import JSON rules, first flushing existing rules
nft flush ruleset && \
nft --json --file /tmp/nft.jsonHowever as far as I can see there is no way to take a non-JSON nftables file and render it as JSON or the reverse -- you can only read and write JSON to the kernel directly.
It would be nice to be able to do this:
# Render nftables conf as JSON
cat /etc/nftables.conf | jc --nftables -pOf course the reverse would also be nice but that would be beyond the scope of jc!
I haven't been able to find an existing way to do this, I'm not a programmer so I don't know how hard this would be to implement but this tutorial and these presentation slides have some useful background on nftables and Python / JSON support.