Yes you can redefine an already existing base chain's policy without changing its content. There's no separate keyword for this, it's still add:
nft add chain family mytable mychain '{ policy drop; }'
Complete example in a namespace:
test.nft:
flush ruleset
table ip t {
chain c {
type filter hook output priority 0; policy accept;
oif lo accept
counter
}
}
setup:
# ip netns add test
# ip netns exec test nft -f test.nft
alteration:
# ip netns exec test nft add 'chain ip t c { policy drop; }'
# ip netns exec test nft list ruleset
table ip t {
chain c {
type filter hook output priority filter; policy drop;
oif "lo" accept
counter packets 0 bytes 0
}
}
The policy was changed, without altering the rules. Using here nft 0.9.5 and kernel 5.7.x . Depending on version behaviour might differ.
Yes you can redefine an already existing base chain's policy without changing its content. There's no separate keyword for this, it's still
add
:Complete example in a namespace:
test.nft
:setup:
alteration:
The policy was changed, without altering the rules. Using here nft 0.9.5 and kernel 5.7.x . Depending on version behaviour might differ.
There's a kernel commit from 2015 allowing to do only this:
Before this (around kernel 4.1), one had to provide again the base chain definition (which can't be changed by the way):