All of lore.kernel.org
 help / color / mirror / Atom feed
* Atomic changes to IP sets
       [not found] <ECC8F67CE961104EB2AFE8F7FD50F5D045F1E6@exchange2010.sirrix.de>
@ 2015-04-13  8:23 ` Anna Fischer
  2015-04-13  9:44   ` Nikolay S.
  2015-04-13 10:31   ` Koen Zandberg
  0 siblings, 2 replies; 6+ messages in thread
From: Anna Fischer @ 2015-04-13  8:23 UTC (permalink / raw)
  To: netfilter


Hi,

I'm using ip sets in my iptables firwall rules. I don't just use those for firewalling, but also for packet mangling (marking). Now I'm quite frequently changing these sets and also the firewall rules. I know that I can atomically switch firewall rules by using iptables-restore. But how can I make changes to ip sets atomic? It seems to be as if packets are always passing the firewall whilst I do ipset commands. Currently I flush all ip sets, and then rebuild them. I understand this will cause problems because at times my ip sets are empty and so the firewall does not behave how I want it to behave. But what is the correct way to atomically update ip sets? I have seen that there is a command to swap an ip set. So I would build up a new set, then swap it with the old one, and then delete the
  old one. Is that the right way of changing ip sets? The other option would be to create a whole new set of ipsets and the a new set of iptables rules with these sets, and then I use iptables-restore to atomically switch the full firewall table. This seems like quite a bit of overkill though, doesn't it? Does anyone have an idea about how to best work with ip sets without building glitches into my firewall whilst reconfiguring ip sets?

Thanks for any pointers.

Anna






^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Atomic changes to IP sets
  2015-04-13  8:23 ` Atomic changes to IP sets Anna Fischer
@ 2015-04-13  9:44   ` Nikolay S.
       [not found]     ` <ECC8F67CE961104EB2AFE8F7FD50F5D045F57D@exchange2010.sirrix.de>
  2015-04-13 10:31   ` Koen Zandberg
  1 sibling, 1 reply; 6+ messages in thread
From: Nikolay S. @ 2015-04-13  9:44 UTC (permalink / raw)
  To: Anna Fischer; +Cc: netfilter

В Пн, 13/04/2015 в 08:23 +0000, Anna Fischer пишет:
> Hi,
> 
> I'm using ip sets in my iptables firwall rules. I don't just use those for firewalling, but also for packet mangling (marking). Now I'm quite frequently changing these sets and also the firewall rules. I know that I can atomically switch firewall rules by using iptables-restore. But how can I make changes to ip sets atomic? It seems to be as if packets are always passing the firewall whilst I do ipset commands. Currently I flush all ip sets, and then rebuild them. I understand this will cause problems because at times my ip sets are empty and so the firewall does not behave how I want it to behave. But what is the correct way to atomically update ip sets? I have seen that there is a command to swap an ip set. So I would build up a new set, then swap it with the old one, and then delete the old one. Is that the right way of changing ip sets? The other option would be to create a whole new set of ipsets and the a new set of iptables rules with these sets, and then I use iptables-restore to atomically switch the full firewall table. This seems like quite a bit of overkill though, doesn't it? Does anyone have an idea about how to best work with ip sets without building glitches into my firewall whilst reconfiguring ip sets?
> 
> Thanks for any pointers.

Did you try ipset {save,restore}? This will pass all the commands in one
transaction through netlink.

> Anna
> 
> 
> 
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe netfilter" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Atomic changes to IP sets
  2015-04-13  8:23 ` Atomic changes to IP sets Anna Fischer
  2015-04-13  9:44   ` Nikolay S.
@ 2015-04-13 10:31   ` Koen Zandberg
  2015-04-13 16:20     ` Neal Murphy
  1 sibling, 1 reply; 6+ messages in thread
From: Koen Zandberg @ 2015-04-13 10:31 UTC (permalink / raw)
  To: Anna Fischer, netfilter

On 13/04/15 10:23, Anna Fischer wrote:
> Hi,
>
> I'm using ip sets in my iptables firwall rules. I don't just use those for firewalling, but also for packet mangling (marking). Now I'm quite frequently changing these sets and also the firewall rules. I know that I can atomically switch firewall rules by using iptables-restore. But how can I make changes to ip sets atomic? It seems to be as if packets are always passing the firewall whilst I do ipset commands. Currently I flush all ip sets, and then rebuild them. I understand this will cause problems because at times my ip sets are empty and so the firewall does not behave how I want it to behave. But what is the correct way to atomically update ip sets? I have seen that there is a command to swap an ip set. So I would build up a new set, then swap it with the old one, and then delete t
 he old one. Is that the right way of changing ip sets? The other option would be to create a whole new set of ipsets and the a new set of iptables rules with these sets, and then I use iptables-restor
>   e to atomically switch the full firewall table. This seems like quite a bit of overkill though, doesn't it? Does anyone have an idea about how to best work with ip sets without building glitches into my firewall whilst reconfiguring ip sets?
>
> Thanks for any pointers.
>
> Anna
The way I learned to do this atomically was by creating a new set and 
using "ipset swap $OLDLIST $NEWLIST" to swap your old set with your new set.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Atomic changes to IP sets
  2015-04-13 10:31   ` Koen Zandberg
@ 2015-04-13 16:20     ` Neal Murphy
  2015-04-13 21:16       ` Paul Robert Marino
  0 siblings, 1 reply; 6+ messages in thread
From: Neal Murphy @ 2015-04-13 16:20 UTC (permalink / raw)
  To: netfilter

On Monday, April 13, 2015 06:31:47 AM Koen Zandberg wrote:
> On 13/04/15 10:23, Anna Fischer wrote:
> > Hi,
> > 
> > I'm using ip sets in my iptables firwall rules. I don't just use those
> > for firewalling, but also for packet mangling (marking). Now I'm quite
> > frequently changing these sets and also the firewall rules. I know that
> > I can atomically switch firewall rules by using iptables-restore. But
> > how can I make changes to ip sets atomic? It seems to be as if packets
> > are always passing the firewall whilst I do ipset commands. Currently I
> > flush all ip sets, and then rebuild them. I understand this will cause
> > problems because at times my ip sets are empty and so the firewall does
> > not behave how I want it to behave. But what is the correct way to
> > atomically update ip sets? I have seen that there is a command to swap
> > an ip set. So I would build up a new set, then swap it with the old one,
> > and then delete the old one. Is that the right way of changing ip sets?
> > The other option would be to create a whole new set of ipsets and the a
> > new set of iptables rules with these sets, and then I use
> > iptables-restor
> > 
> >   e to atomically switch the full firewall table. This seems like quite a
> >   bit of overkill though, doesn't it? Does anyone have an idea about how
> >   to best work with ip sets without building glitches into my firewall
> >   whilst reconfiguring ip sets?
> > 
> > Thanks for any pointers.
> > 
> > Anna
> 
> The way I learned to do this atomically was by creating a new set and
> using "ipset swap $OLDLIST $NEWLIST" to swap your old set with your new
> set.

I believe it waits for relative quiesence, then atomically swaps the names of 
the two sets. So don't forget to delete set $NEWLIST after the swap (which is 
now the old set).

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Atomic changes to IP sets
  2015-04-13 16:20     ` Neal Murphy
@ 2015-04-13 21:16       ` Paul Robert Marino
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Robert Marino @ 2015-04-13 21:16 UTC (permalink / raw)
  To: Neal Murphy; +Cc: netfilter

take a look at my tool ipset-manager
https://github.com/prmarino1/HadrianWall/tree/master/Tools/IPSet-Manager

This uses a swap method which can update changes sets without deleting them.
documentation is embedded in the script in POD format. It can be
extracted with pod2man, pod2text, pod2html, etc.

It requires two Perl 5 modules  XML::Twig and Getopt::Long





On Mon, Apr 13, 2015 at 12:20 PM, Neal Murphy
<neal.p.murphy@alum.wpi.edu> wrote:
> On Monday, April 13, 2015 06:31:47 AM Koen Zandberg wrote:
>> On 13/04/15 10:23, Anna Fischer wrote:
>> > Hi,
>> >
>> > I'm using ip sets in my iptables firwall rules. I don't just use those
>> > for firewalling, but also for packet mangling (marking). Now I'm quite
>> > frequently changing these sets and also the firewall rules. I know that
>> > I can atomically switch firewall rules by using iptables-restore. But
>> > how can I make changes to ip sets atomic? It seems to be as if packets
>> > are always passing the firewall whilst I do ipset commands. Currently I
>> > flush all ip sets, and then rebuild them. I understand this will cause
>> > problems because at times my ip sets are empty and so the firewall does
>> > not behave how I want it to behave. But what is the correct way to
>> > atomically update ip sets? I have seen that there is a command to swap
>> > an ip set. So I would build up a new set, then swap it with the old one,
>> > and then delete the old one. Is that the right way of changing ip sets?
>> > The other option would be to create a whole new set of ipsets and the a
>> > new set of iptables rules with these sets, and then I use
>> > iptables-restor
>> >
>> >   e to atomically switch the full firewall table. This seems like quite a
>> >   bit of overkill though, doesn't it? Does anyone have an idea about how
>> >   to best work with ip sets without building glitches into my firewall
>> >   whilst reconfiguring ip sets?
>> >
>> > Thanks for any pointers.
>> >
>> > Anna
>>
>> The way I learned to do this atomically was by creating a new set and
>> using "ipset swap $OLDLIST $NEWLIST" to swap your old set with your new
>> set.
>
> I believe it waits for relative quiesence, then atomically swaps the names of
> the two sets. So don't forget to delete set $NEWLIST after the swap (which is
> now the old set).
> --
> To unsubscribe from this list: send the line "unsubscribe netfilter" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: AW: Atomic changes to IP sets
       [not found]     ` <ECC8F67CE961104EB2AFE8F7FD50F5D045F57D@exchange2010.sirrix.de>
@ 2015-04-14  8:29       ` Nikolay S.
  0 siblings, 0 replies; 6+ messages in thread
From: Nikolay S. @ 2015-04-14  8:29 UTC (permalink / raw)
  To: Anna Fischer; +Cc: netfilter

В Вт, 14/04/2015 в 05:36 +0000, Anna Fischer пишет:
> > Hi,
> >
> > I'm using ip sets in my iptables firwall rules. I don't just use those for firewalling, but also for packet mangling (marking). Now I'm quite frequently changing these sets and also the firewall rules. I know that I can atomically switch firewall rules by using iptables-restore. But how can I make changes to ip sets atomic? It seems to be as if packets are always passing the firewall whilst I do ipset commands. Currently I flush all ip sets, and then rebuild them. I understand this will cause problems because at times my ip sets are empty and so the firewall does not behave how I want it to behave. But what is the correct way to atomically update ip sets? I have seen that there is a command to swap an ip set. So I would build up a new set, then swap it with the old one, and then delete the old one. Is that the right way of changing ip sets? The other option would be to create a whole new set of ipsets and the a new set of iptables rules with these sets, and then I use iptables-restore to atomically switch the full firewall table. This seems like quite a bit of overkill though, doesn't it? Does anyone have an idea about how to best work with ip sets without building glitches into my firewall whilst reconfiguring ip sets?
> >
> > Thanks for any pointers.
> 
> > Did you try ipset {save,restore}? This will pass all the commands in one
> > transaction through netlink.
> 
> I have tried ipset {save, restore} but it does not seem to work if I have a large set of commands to restore. Is there a limit on the number of commands I can save/restore?
> 
> Thanks, Anna

I don't know of such a limit. Quick test with adding 100000 addresess
through restore gives correct result here



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-04-14  8:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <ECC8F67CE961104EB2AFE8F7FD50F5D045F1E6@exchange2010.sirrix.de>
2015-04-13  8:23 ` Atomic changes to IP sets Anna Fischer
2015-04-13  9:44   ` Nikolay S.
     [not found]     ` <ECC8F67CE961104EB2AFE8F7FD50F5D045F57D@exchange2010.sirrix.de>
2015-04-14  8:29       ` AW: " Nikolay S.
2015-04-13 10:31   ` Koen Zandberg
2015-04-13 16:20     ` Neal Murphy
2015-04-13 21:16       ` Paul Robert Marino

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.