Quantcast
Viewing latest article 1
Browse Latest Browse All 2

Answer by Lobz for How can I idempotently add an input rule to preconfigured nftables

It will be easier to manage it using sets:

table inet filter {    set myport_tcp {        type inet_service        elements = { 4848 }    }       chain input {        type filter hook input priority 0; policy drop;        # existing rules        tcp dport @myport_tcp ct state new,established counter accept        # more existing rules    }}

You can empty the set by:

nft flush set inet filter myport_tcp 

And you can add a new port to the set by:

nft add element inet filter myport_tcp elements = { 4949 }

Or add a multiple ports to the set by:

nft add element inet filter myport_tcp elements = { 14949, 9494 }

Viewing latest article 1
Browse Latest Browse All 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>