* Is it possible to change a chains default policy when rules are already present? @ 2020-08-13 12:28 Andreas Hoefler 2020-08-13 12:48 ` Reindl Harald 2020-08-14 11:07 ` Pablo Neira Ayuso 0 siblings, 2 replies; 15+ messages in thread From: Andreas Hoefler @ 2020-08-13 12:28 UTC (permalink / raw) To: netfilter@vger.kernel.org Hi I have a chain with default policy drop. I would like to first have the default policy set to accept, then add rules and later change it to drop. Is this possible? Thx Andy ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Is it possible to change a chains default policy when rules are already present? 2020-08-13 12:28 Is it possible to change a chains default policy when rules are already present? Andreas Hoefler @ 2020-08-13 12:48 ` Reindl Harald 2020-08-13 12:50 ` Andreas Hoefler 2020-08-14 11:07 ` Pablo Neira Ayuso 1 sibling, 1 reply; 15+ messages in thread From: Reindl Harald @ 2020-08-13 12:48 UTC (permalink / raw) To: Andreas Hoefler, netfilter@vger.kernel.org Am 13.08.20 um 14:28 schrieb Andreas Hoefler: > I have a chain with default policy drop. > I would like to first have the default policy set to accept, then add rules and later change it to drop. > Is this possible? iptables -t <table> -P <CHAIN> ACCEPT iptables -t <table> -P <CHAIN> DROP ^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: Is it possible to change a chains default policy when rules are already present? 2020-08-13 12:48 ` Reindl Harald @ 2020-08-13 12:50 ` Andreas Hoefler 2020-08-13 13:38 ` Duncan Roe 0 siblings, 1 reply; 15+ messages in thread From: Andreas Hoefler @ 2020-08-13 12:50 UTC (permalink / raw) To: Reindl Harald, netfilter@vger.kernel.org Hi Thx for the quick reply. Forgot to mention I am using NFTables...but I guess this should be then possible as well. Thx Andy Am 13.08.20 um 14:28 schrieb Andreas Hoefler: > I have a chain with default policy drop. > I would like to first have the default policy set to accept, then add rules and later change it to drop. > Is this possible? iptables -t <table> -P <CHAIN> ACCEPT iptables -t <table> -P <CHAIN> DROP ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Is it possible to change a chains default policy when rules are already present? 2020-08-13 12:50 ` Andreas Hoefler @ 2020-08-13 13:38 ` Duncan Roe 0 siblings, 0 replies; 15+ messages in thread From: Duncan Roe @ 2020-08-13 13:38 UTC (permalink / raw) To: netfilter@vger.kernel.org On Thu, Aug 13, 2020 at 12:50:54PM +0000, Andreas Hoefler wrote: > Hi > > Thx for the quick reply. Forgot to mention I am using NFTables...but I guess this should be then possible as well. > > Thx > Andy > > Am 13.08.20 um 14:28 schrieb Andreas Hoefler: > > I have a chain with default policy drop. > > I would like to first have the default policy set to accept, then add rules and later change it to drop. > > Is this possible? > > iptables -t <table> -P <CHAIN> ACCEPT > iptables -t <table> -P <CHAIN> DROP Hi Andy, If you are using individual nft commands then yes, you can do that. But there is no need to do it if using an nft script (#!/usr/sbin/nft -f), since nothing is sent to the kernel until the script is all done, and then the kernel makes all the changes atomically (i.e. all processes are locked out until all the changes are done). Cheers ... Duncan. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Is it possible to change a chains default policy when rules are already present? 2020-08-13 12:28 Is it possible to change a chains default policy when rules are already present? Andreas Hoefler 2020-08-13 12:48 ` Reindl Harald @ 2020-08-14 11:07 ` Pablo Neira Ayuso 2020-08-14 11:21 ` Daniel 2020-08-14 11:43 ` Andreas Hoefler 1 sibling, 2 replies; 15+ messages in thread From: Pablo Neira Ayuso @ 2020-08-14 11:07 UTC (permalink / raw) To: Andreas Hoefler; +Cc: netfilter@vger.kernel.org On Thu, Aug 13, 2020 at 12:28:34PM +0000, Andreas Hoefler wrote: > Hi > > I have a chain with default policy drop. > I would like to first have the default policy set to accept, then add rules and later change it to drop. > Is this possible? For the record: nft add chain x y { policy accept\; } Assuming an existing basechain 'y'. The backlash (\) before the semicolon is there in case of invoking this from bash. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Is it possible to change a chains default policy when rules are already present? 2020-08-14 11:07 ` Pablo Neira Ayuso @ 2020-08-14 11:21 ` Daniel 2020-08-14 11:36 ` Reindl Harald 2020-08-14 11:43 ` Andreas Hoefler 1 sibling, 1 reply; 15+ messages in thread From: Daniel @ 2020-08-14 11:21 UTC (permalink / raw) To: Pablo Neira Ayuso, Andreas Hoefler; +Cc: netfilter@vger.kernel.org Hello Le 14/08/2020 à 13:07, Pablo Neira Ayuso a écrit : > On Thu, Aug 13, 2020 at 12:28:34PM +0000, Andreas Hoefler wrote: >> Hi >> >> I have a chain with default policy drop. >> I would like to first have the default policy set to accept, then add rules and later change it to drop. >> Is this possible? > For the record: > > nft add chain x y { policy accept\; } > > Assuming an existing basechain 'y'. The backlash (\) before the > semicolon is there in case of invoking this from bash. From bash how to you set priority leaded by - like priority -150 \; We always get invalid option dh@peech:~$ sudo nft add chain ip6 mangle output { type nat hook prerouting priority -350 \; policy accept \; } nft: invalid option -- '3' -- Daniel Huhardeaux +33.368460088@tootai.net sip:820@sip.tootai.net +41.445532125@swiss-itech.ch tootaiNET ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Is it possible to change a chains default policy when rules are already present? 2020-08-14 11:21 ` Daniel @ 2020-08-14 11:36 ` Reindl Harald 2020-08-14 12:54 ` Daniel 0 siblings, 1 reply; 15+ messages in thread From: Reindl Harald @ 2020-08-14 11:36 UTC (permalink / raw) To: Daniel, Pablo Neira Ayuso, Andreas Hoefler; +Cc: netfilter@vger.kernel.org Am 14.08.20 um 13:21 schrieb Daniel: > Le 14/08/2020 à 13:07, Pablo Neira Ayuso a écrit : >> On Thu, Aug 13, 2020 at 12:28:34PM +0000, Andreas Hoefler wrote: >>> Hi >>> >>> I have a chain with default policy drop. >>> I would like to first have the default policy set to accept, then add >>> rules and later change it to drop. >>> Is this possible? >> For the record: >> >> nft add chain x y { policy accept\; } >> >> Assuming an existing basechain 'y'. The backlash (\) before the >> semicolon is there in case of invoking this from bash. > > From bash how to you set priority leaded by - like priority -150 \; We > always get invalid option > > dh@peech:~$ sudo nft add chain ip6 mangle output { type nat hook > prerouting priority -350 \; policy accept \; } > nft: invalid option -- '3' because you don't escape - with \- don't nft understand quoted params? nft add chain ip6 mangle output "{ type nat hook prerouting priority -350 ; policy accept ; }" ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Is it possible to change a chains default policy when rules are already present? 2020-08-14 11:36 ` Reindl Harald @ 2020-08-14 12:54 ` Daniel 2020-08-14 13:08 ` Florian Westphal 0 siblings, 1 reply; 15+ messages in thread From: Daniel @ 2020-08-14 12:54 UTC (permalink / raw) To: Reindl Harald, Pablo Neira Ayuso, Andreas Hoefler Cc: netfilter@vger.kernel.org Le 14/08/2020 à 13:36, Reindl Harald a écrit : > > Am 14.08.20 um 13:21 schrieb Daniel: >> Le 14/08/2020 à 13:07, Pablo Neira Ayuso a écrit : >>> On Thu, Aug 13, 2020 at 12:28:34PM +0000, Andreas Hoefler wrote: >>>> Hi >>>> >>>> I have a chain with default policy drop. >>>> I would like to first have the default policy set to accept, then add >>>> rules and later change it to drop. >>>> Is this possible? >>> For the record: >>> >>> nft add chain x y { policy accept\; } >>> >>> Assuming an existing basechain 'y'. The backlash (\) before the >>> semicolon is there in case of invoking this from bash. >> From bash how to you set priority leaded by - like priority -150 \; We >> always get invalid option >> >> dh@peech:~$ sudo nft add chain ip6 mangle output { type nat hook >> prerouting priority -350 \; policy accept \; } >> nft: invalid option -- '3' > because you don't escape - with \- I already tested by escaping - sign, same error > don't nft understand quoted params? > > nft add chain ip6 mangle output "{ type nat hook prerouting priority > -350 ; policy accept ; }" Not working either dh@peech:~$ sudo nft add chain ip6 mangle prerouting "{ type nat hook prerouting priority -350 ; policy accept ; }" Error: Could not process rule: Operation not supported add chain ip6 mangle prerouting { type nat hook prerouting priority -350; policy accept; } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- Daniel Huhardeaux +33.368460088@tootai.net sip:820@sip.tootai.net +41.445532125@swiss-itech.ch tootaiNET ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Is it possible to change a chains default policy when rules are already present? 2020-08-14 12:54 ` Daniel @ 2020-08-14 13:08 ` Florian Westphal 2020-08-14 13:21 ` Andreas Hoefler 0 siblings, 1 reply; 15+ messages in thread From: Florian Westphal @ 2020-08-14 13:08 UTC (permalink / raw) To: Daniel Cc: Reindl Harald, Pablo Neira Ayuso, Andreas Hoefler, netfilter@vger.kernel.org Daniel <tech@tootai.net> wrote: > > Le 14/08/2020 à 13:36, Reindl Harald a écrit : > > > > Am 14.08.20 um 13:21 schrieb Daniel: > > > Le 14/08/2020 à 13:07, Pablo Neira Ayuso a écrit : > > > > On Thu, Aug 13, 2020 at 12:28:34PM +0000, Andreas Hoefler wrote: > > > > > Hi > > > > > > > > > > I have a chain with default policy drop. > > > > > I would like to first have the default policy set to accept, then add > > > > > rules and later change it to drop. > > > > > Is this possible? > > > > For the record: > > > > > > > > nft add chain x y { policy accept\; } > > > > > > > > Assuming an existing basechain 'y'. The backlash (\) before the > > > > semicolon is there in case of invoking this from bash. > > > From bash how to you set priority leaded by - like priority -150 \; We > > > always get invalid option > > > > > > dh@peech:~$ sudo nft add chain ip6 mangle output { type nat hook > > > prerouting priority -350 \; policy accept \; } > > > nft: invalid option -- '3' > > because you don't escape - with \- > I already tested by escaping - sign, same error > > don't nft understand quoted params? > > > > nft add chain ip6 mangle output "{ type nat hook prerouting priority > > -350 ; policy accept ; }" > Not working either > > dh@peech:~$ sudo nft add chain ip6 mangle prerouting "{ type nat hook > prerouting priority -350 ; policy accept ; }" > Error: Could not process rule: Operation not supported > add chain ip6 mangle prerouting { type nat hook prerouting priority -350; > policy accept; } Historic artifact, try a value larger than -200, e.g. -199. I've sent a patch to zap this outdated check. ^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: Is it possible to change a chains default policy when rules are already present? 2020-08-14 13:08 ` Florian Westphal @ 2020-08-14 13:21 ` Andreas Hoefler 2020-08-14 13:40 ` Florian Westphal 2020-08-14 14:37 ` Pablo Neira Ayuso 0 siblings, 2 replies; 15+ messages in thread From: Andreas Hoefler @ 2020-08-14 13:21 UTC (permalink / raw) To: Florian Westphal, Daniel Cc: Reindl Harald, Pablo Neira Ayuso, netfilter@vger.kernel.org > Daniel <tech@tootai.net> wrote: > > > > Le 14/08/2020 à 13:36, Reindl Harald a écrit : > > > > > > Am 14.08.20 um 13:21 schrieb Daniel: > > > > Le 14/08/2020 à 13:07, Pablo Neira Ayuso a écrit : > > > > > On Thu, Aug 13, 2020 at 12:28:34PM +0000, Andreas Hoefler wrote: > > > > > > Hi > > > > > > > > > > > > I have a chain with default policy drop. > > > > > > I would like to first have the default policy set to accept, > > > > > > then add rules and later change it to drop. > > > > > > Is this possible? > > > > > For the record: > > > > > > > > > > nft add chain x y { policy accept\; } > > > > > > > > > > Assuming an existing basechain 'y'. The backlash (\) before the > > > > > semicolon is there in case of invoking this from bash. > > > > From bash how to you set priority leaded by - like priority -150 > > > > \; We always get invalid option > > > > > > > > dh@peech:~$ sudo nft add chain ip6 mangle output { type nat hook > > > > prerouting priority -350 \; policy accept \; } > > > > nft: invalid option -- '3' > > > because you don't escape - with \- > > I already tested by escaping - sign, same error > > > don't nft understand quoted params? > > > > > > nft add chain ip6 mangle output "{ type nat hook prerouting priority > > > -350 ; policy accept ; }" > > Not working either > > > > dh@peech:~$ sudo nft add chain ip6 mangle prerouting "{ type nat hook > > prerouting priority -350 ; policy accept ; }" > > Error: Could not process rule: Operation not supported add chain ip6 > > mangle prerouting { type nat hook prerouting priority -350; policy > > accept; } > > Historic artifact, try a value larger than -200, e.g. -199. > I've sent a patch to zap this outdated check. Didn't work for me either: #nft add chain ip6 x y {type filter hook input priority \-100\;} nft: invalid option -- '1' ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Is it possible to change a chains default policy when rules are already present? 2020-08-14 13:21 ` Andreas Hoefler @ 2020-08-14 13:40 ` Florian Westphal 2020-08-14 13:44 ` Andreas Hoefler 2020-08-14 14:37 ` Pablo Neira Ayuso 1 sibling, 1 reply; 15+ messages in thread From: Florian Westphal @ 2020-08-14 13:40 UTC (permalink / raw) To: Andreas Hoefler Cc: Florian Westphal, Daniel, Reindl Harald, Pablo Neira Ayuso, netfilter@vger.kernel.org Andreas Hoefler <andreas.hoefler@hitachi-powergrids.com> wrote: > > Daniel <tech@tootai.net> wrote: > > > dh@peech:~$ sudo nft add chain ip6 mangle prerouting "{ type nat hook > > > prerouting priority -350 ; policy accept ; }" > > > Error: Could not process rule: Operation not supported add chain ip6 > > > mangle prerouting { type nat hook prerouting priority -350; policy > > > accept; } > > > > Historic artifact, try a value larger than -200, e.g. -199. > > I've sent a patch to zap this outdated check. > > Didn't work for me either: > #nft add chain ip6 x y {type filter hook input priority \-100\;} > nft: invalid option -- '1' Different problem. Just follow Daniels example and quote everything, i.e. nft add chain ip6 x y "{ type filter hook input priority -100; }" ^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: Is it possible to change a chains default policy when rules are already present? 2020-08-14 13:40 ` Florian Westphal @ 2020-08-14 13:44 ` Andreas Hoefler 2020-08-14 15:31 ` Daniel 0 siblings, 1 reply; 15+ messages in thread From: Andreas Hoefler @ 2020-08-14 13:44 UTC (permalink / raw) To: Florian Westphal Cc: Daniel, Reindl Harald, Pablo Neira Ayuso, netfilter@vger.kernel.org > Andreas Hoefler <andreas.hoefler@hitachi-powergrids.com> wrote: > > > Daniel <tech@tootai.net> wrote: > > > > dh@peech:~$ sudo nft add chain ip6 mangle prerouting "{ type nat > > > > hook prerouting priority -350 ; policy accept ; }" > > > > Error: Could not process rule: Operation not supported add chain > > > > ip6 mangle prerouting { type nat hook prerouting priority -350; > > > > policy accept; } > > > > > > Historic artifact, try a value larger than -200, e.g. -199. > > > I've sent a patch to zap this outdated check. > > > > Didn't work for me either: > > #nft add chain ip6 x y {type filter hook input priority \-100\;} > > nft: invalid option -- '1' > > Different problem. Just follow Daniels example and quote everything, i.e. nft add chain ip6 x y "{ type filter hook input priority -100; }" ah ok that did the trick, thx a lot. Andy ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Is it possible to change a chains default policy when rules are already present? 2020-08-14 13:44 ` Andreas Hoefler @ 2020-08-14 15:31 ` Daniel 0 siblings, 0 replies; 15+ messages in thread From: Daniel @ 2020-08-14 15:31 UTC (permalink / raw) To: Andreas Hoefler, Florian Westphal Cc: Reindl Harald, Pablo Neira Ayuso, netfilter@vger.kernel.org Le 14/08/2020 à 15:44, Andreas Hoefler a écrit : >> Andreas Hoefler <andreas.hoefler@hitachi-powergrids.com> wrote: >>>> Daniel <tech@tootai.net> wrote: >>>>> dh@peech:~$ sudo nft add chain ip6 mangle prerouting "{ type nat >>>>> hook prerouting priority -350 ; policy accept ; }" >>>>> Error: Could not process rule: Operation not supported add chain >>>>> ip6 mangle prerouting { type nat hook prerouting priority -350; >>>>> policy accept; } >>>> Historic artifact, try a value larger than -200, e.g. -199. >>>> I've sent a patch to zap this outdated check. >>> Didn't work for me either: >>> #nft add chain ip6 x y {type filter hook input priority \-100\;} >>> nft: invalid option -- '1' >> Different problem. Just follow Daniels example and quote everything, i.e. nft add chain ip6 x y "{ type filter hook input priority -100; }" > ah ok that did the trick, thx a lot. Confirmed, thanks. -- Daniel Huhardeaux +33.368460088@tootai.net sip:820@sip.tootai.net +41.445532125@swiss-itech.ch tootaiNET ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Is it possible to change a chains default policy when rules are already present? 2020-08-14 13:21 ` Andreas Hoefler 2020-08-14 13:40 ` Florian Westphal @ 2020-08-14 14:37 ` Pablo Neira Ayuso 1 sibling, 0 replies; 15+ messages in thread From: Pablo Neira Ayuso @ 2020-08-14 14:37 UTC (permalink / raw) To: Andreas Hoefler Cc: Florian Westphal, Daniel, Reindl Harald, netfilter@vger.kernel.org On Fri, Aug 14, 2020 at 01:21:08PM +0000, Andreas Hoefler wrote: > > Daniel <tech@tootai.net> wrote: > > > > > > Le 14/08/2020 à 13:36, Reindl Harald a écrit : > > > > > > > > Am 14.08.20 um 13:21 schrieb Daniel: > > > > > Le 14/08/2020 à 13:07, Pablo Neira Ayuso a écrit : > > > > > > On Thu, Aug 13, 2020 at 12:28:34PM +0000, Andreas Hoefler wrote: > > > > > > > Hi > > > > > > > > > > > > > > I have a chain with default policy drop. > > > > > > > I would like to first have the default policy set to accept, > > > > > > > then add rules and later change it to drop. > > > > > > > Is this possible? > > > > > > For the record: > > > > > > > > > > > > nft add chain x y { policy accept\; } > > > > > > > > > > > > Assuming an existing basechain 'y'. The backlash (\) before the > > > > > > semicolon is there in case of invoking this from bash. > > > > > From bash how to you set priority leaded by - like priority -150 > > > > > \; We always get invalid option > > > > > > > > > > dh@peech:~$ sudo nft add chain ip6 mangle output { type nat hook > > > > > prerouting priority -350 \; policy accept \; } > > > > > nft: invalid option -- '3' > > > > because you don't escape - with \- > > > I already tested by escaping - sign, same error > > > > don't nft understand quoted params? > > > > > > > > nft add chain ip6 mangle output "{ type nat hook prerouting priority > > > > -350 ; policy accept ; }" > > > Not working either > > > > > > dh@peech:~$ sudo nft add chain ip6 mangle prerouting "{ type nat hook > > > prerouting priority -350 ; policy accept ; }" > > > Error: Could not process rule: Operation not supported add chain ip6 > > > mangle prerouting { type nat hook prerouting priority -350; policy > > > accept; } > > > > Historic artifact, try a value larger than -200, e.g. -199. > > I've sent a patch to zap this outdated check. > > Didn't work for me either: > #nft add chain ip6 x y {type filter hook input priority \-100\;} > nft: invalid option -- '1' This is fixed in recent nftables version there is no need to disable the getopt_long() parser anymore via -- nft -- add chain ip6 x y {type filter hook input priority -100 \;} see: commit fb9cea50e8b370b6931e7b53b1a881d3b95b1c91 Author: Pablo Neira Ayuso <pablo@netfilter.org> Date: Fri Dec 13 11:32:46 2019 +0100 main: enforce options before commands ^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: Is it possible to change a chains default policy when rules are already present? 2020-08-14 11:07 ` Pablo Neira Ayuso 2020-08-14 11:21 ` Daniel @ 2020-08-14 11:43 ` Andreas Hoefler 1 sibling, 0 replies; 15+ messages in thread From: Andreas Hoefler @ 2020-08-14 11:43 UTC (permalink / raw) To: Pablo Neira Ayuso, netfilter@vger.kernel.org Hi Thx a lot, that worked. I expected the add cmd to produce an error since the chain already exists, but seems to work fine. Andreas Hoefler On Thu, Aug 13, 2020 at 12:28:34PM +0000, Andreas Hoefler wrote: > Hi > > I have a chain with default policy drop. > I would like to first have the default policy set to accept, then add rules and later change it to drop. > Is this possible? For the record: nft add chain x y { policy accept\; } Assuming an existing basechain 'y'. The backlash (\) before the semicolon is there in case of invoking this from bash. ^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2020-08-14 15:31 UTC | newest] Thread overview: 15+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-08-13 12:28 Is it possible to change a chains default policy when rules are already present? Andreas Hoefler 2020-08-13 12:48 ` Reindl Harald 2020-08-13 12:50 ` Andreas Hoefler 2020-08-13 13:38 ` Duncan Roe 2020-08-14 11:07 ` Pablo Neira Ayuso 2020-08-14 11:21 ` Daniel 2020-08-14 11:36 ` Reindl Harald 2020-08-14 12:54 ` Daniel 2020-08-14 13:08 ` Florian Westphal 2020-08-14 13:21 ` Andreas Hoefler 2020-08-14 13:40 ` Florian Westphal 2020-08-14 13:44 ` Andreas Hoefler 2020-08-14 15:31 ` Daniel 2020-08-14 14:37 ` Pablo Neira Ayuso 2020-08-14 11:43 ` Andreas Hoefler
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.