Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New parser: nftables #601

Open
chriscroome opened this issue Sep 28, 2024 · 0 comments
Open

New parser: nftables #601

chriscroome opened this issue Sep 28, 2024 · 0 comments

Comments

@chriscroome
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants