netfilter.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Using iptables and ipset to DROP a list of 2 million addresses
@ 2024-04-11 12:39 Mason Kaufer
  2024-04-11 15:08 ` Le Chevalier
  2024-04-11 15:37 ` Stephen Satchell
  0 siblings, 2 replies; 4+ messages in thread
From: Mason Kaufer @ 2024-04-11 12:39 UTC (permalink / raw)
  To: netfilter

Hi,
I am currently trying to set up a firewall on an Ubuntu 22.04 machine
that will block a list of 2 million plus ip addresses without slowing
the network speed down tremendously. I have tried using ipset but I
get an error that the hash size isn't large enough. I have tried
manually setting the hash size but it only allows that option to be so
large. Is there something I am doing wrong or is there a better way to
achieve this? Any help with this would be much appreciated.
--
Mason Kaufer

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

* Re: Using iptables and ipset to DROP a list of 2 million addresses
  2024-04-11 12:39 Using iptables and ipset to DROP a list of 2 million addresses Mason Kaufer
@ 2024-04-11 15:08 ` Le Chevalier
  2024-04-13 14:01   ` Jozsef Kadlecsik
  2024-04-11 15:37 ` Stephen Satchell
  1 sibling, 1 reply; 4+ messages in thread
From: Le Chevalier @ 2024-04-11 15:08 UTC (permalink / raw)
  To: Mason Kaufer, netfilter

On 2024-04-11 14:39, Mason Kaufer wrote:
> Hi,
> I am currently trying to set up a firewall on an Ubuntu 22.04 machine
> that will block a list of 2 million plus ip addresses without slowing
> the network speed down tremendously. I have tried using ipset but I
> get an error that the hash size isn't large enough. I have tried
> manually setting the hash size but it only allows that option to be so
> large. Is there something I am doing wrong or is there a better way to
> achieve this? Any help with this would be much appreciated.
> --
> Mason Kaufer
>
Look at the 'list:set' feature. I have not tested this myself, but from 
the description it may act as a compound list.

https://ipset.netfilter.org/features.html


~Forza


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

* Re: Using iptables and ipset to DROP a list of 2 million addresses
  2024-04-11 12:39 Using iptables and ipset to DROP a list of 2 million addresses Mason Kaufer
  2024-04-11 15:08 ` Le Chevalier
@ 2024-04-11 15:37 ` Stephen Satchell
  1 sibling, 0 replies; 4+ messages in thread
From: Stephen Satchell @ 2024-04-11 15:37 UTC (permalink / raw)
  To: Mason Kaufer, netfilter

On 4/11/24 5:39 AM, Mason Kaufer wrote:
> Hi,
> I am currently trying to set up a firewall on an Ubuntu 22.04 machine
> that will block a list of 2 million plus ip addresses without slowing
> the network speed down tremendously. I have tried using ipset but I
> get an error that the hash size isn't large enough. I have tried
> manually setting the hash size but it only allows that option to be so
> large. Is there something I am doing wrong or is there a better way to
> achieve this? Any help with this would be much appreciated.

There could be another way, that would work for both inbound and 
outbound blocking.  Consolidate the list into net ranges, and add the 
ranges as BLACK HOLE routes in the routing table.

I'm less and less enamored with using IP lists in a firewall when the 
routing table is optimized to handle BIG lists of addresses, if you do 
the consolidation properly.

Also, be sure to have short-circuit rules for established connections in 
your firewall list, if you do decide to lard up an IP table list.  That 
will help the speed problem, by restricting the loading to new connections.


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

* Re: Using iptables and ipset to DROP a list of 2 million addresses
  2024-04-11 15:08 ` Le Chevalier
@ 2024-04-13 14:01   ` Jozsef Kadlecsik
  0 siblings, 0 replies; 4+ messages in thread
From: Jozsef Kadlecsik @ 2024-04-13 14:01 UTC (permalink / raw)
  To: Le Chevalier; +Cc: Mason Kaufer, netfilter

On Thu, 11 Apr 2024, Le Chevalier wrote:

> On 2024-04-11 14:39, Mason Kaufer wrote:
> > I am currently trying to set up a firewall on an Ubuntu 22.04 machine 
> > that will block a list of 2 million plus ip addresses without slowing 
> > the network speed down tremendously. I have tried using ipset but I 
> > get an error that the hash size isn't large enough. I have tried 
> > manually setting the hash size but it only allows that option to be so 
> > large. Is there something I am doing wrong or is there a better way to 
> > achieve this? Any help with this would be much appreciated.

There's no upper limit in the hash size (except that the number must fit 
into u32). On my laptop:

# ipset n test hash:ip hashsize 10000000 maxelem 10000000
# ipset l
Name: test
Type: hash:ip
Revision: 5
Header: family inet hashsize 16777216 maxelem 10000000 bucketsize 12 initval 0xc61d4797
Size in memory: 393392
References: 0
Number of entries: 0
Members:

Please note, you must tune both hashsize and maxelem parameters in order 
to be able to store the given number of entries.

Best regards,
Jozsef
-- 
E-mail  : kadlec@blackhole.kfki.hu, kadlecsik.jozsef@wigner.hu
PGP key : https://wigner.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics
          H-1525 Budapest 114, POB. 49, Hungary

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

end of thread, other threads:[~2024-04-13 14:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-11 12:39 Using iptables and ipset to DROP a list of 2 million addresses Mason Kaufer
2024-04-11 15:08 ` Le Chevalier
2024-04-13 14:01   ` Jozsef Kadlecsik
2024-04-11 15:37 ` Stephen Satchell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).