Score:0

Compare on-disk rules and in-memory rules (find the difference) for nftables

cn flag

I want to check that rules was loaded (e.g. ruleset in files are the same as in the kernel). I want to do it without modifying kernel rules. I can't compare files and nft list ruleset due to ordering, comments, formatting and so on.

Is there a way to see difference? Or, may be, there is a way to make nft to 'normalize' rules to match the format kernel rules are shown?

Score:0
my flag

You could try using the -j option, that outputs a json instead of the human readable output with nft -j list ruleset.

You then only have to compare two json outputs, a task that can be done easily using a tool like jd.

The only issue would be how to convert the ruleset from the file to json.

George Shuklin avatar
cn flag
Yes, that part (of converting config to some convergent machine-readable format) is the main topic for the question. If I can do this, I can do the same for nftables list ruleset. unfortunately, it's still open question
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.