Rule management in nftables

391 Views Asked by At

I get the ports as a variable and I need to delete the rule in nftables. If the port is present in rule then i would grep the handle number and delete the rule. But in nftables service name would be present in rule so how can I delete the rule. Is there any way to find the what port belongs to service or any other way to delete the nftable rule other than handle or any other suggestions ??

1

There are 1 best solutions below

0
On BEST ANSWER

Ports and service name are listed in /etc/services.

You can force the listing to use numeric ports by

nft -nna list ruleset/chain/set/table

I don't know the use case but a better solution may be achieved by using named sets, from which elements can be easily removed.