Skip to content

New parser: nftables #601

@chriscroome

Description

@chriscroome

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.json

However 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 -p

Of 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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions