Skip to contentSkip to conversation

Multiple Address specification or match

DISCUSSION Temp02 4 participants 7 messages Sep 30, 2004 – Oct 1, 2004 netfilter

lore
Share & tools
lore

Temp02

author
#0 lore raw

thanks for your feedback but neither of these solutions are particularly elegant.

The first (using more than one rule), requires the use of a lot more rules than are really necessary, as an example, lets say that I wanted to prevent access a range of subnets but allow everything else. Ideally I should be able to:

iptables -A PREROUTING -d ! 10.0.0.0/8 -d ! 192.168.1.0/24 -d ! 172.16.0.0/16 -m whatever -j ACCEPT

instead I would need three explicit drop rules and then an allow everything else rule. (assuming a default drop policy).

The problem with the IPset/pool options are that they match only on a range of addresses, not specifically by source or destination, also they seem to require the use of another userspace program to actually build the sets which in itself complicates the process.

Is it hard to extend the source and destination match functions to accept multiple arguments?

Quoted 12 lines

----- Original Message -----
From: "Henrik Nordstrom" <[email protected]>
To: "Temp02" <[email protected]>
Cc: <[email protected]>; "Swapnil Nagle" <[email protected]>
Sent: Thursday, September 30, 2004 6:34 PM
Subject: Re: Multiple Address specification or match

Quoted 3 lines · On Thu, 30 Sep 2004, Temp02 wrote:
Quoted 2 lines

No obviously a single source can't be both addresses, but the intent

is

Quoted 2 lines

to

Quoted 1 line
Quoted 1 line

allow a single rule to be used to match sources from both source

ranges.

Quoted 11 lines
Quoted 10 lines

There is two ways for doing this

a) Using two rules, one per IP address.

b) Using an ippool/ipset storing the IP addresses.

Regards
Henrik

#1 lore raw
Quoted 2 lines · On Thu, 2004-09-30 at 11:01, Temp02 wrote:

thanks for your feedback but neither of these solutions are particularly elegant.

iptables/netfilter has to be efficient, rules generation script has to be elegant. Having 3 rules is as efficient as your masked "or" rules if it was coded and 3 separate rules are more simple than your global one so in a way this is more elegant.

BR,

Signature · 2 lines
Eric Leblond <[email protected]>
INL
#3 lore raw
In reply to Temp02
Quoted 2 lines · On Thu, 30 Sep 2004, Temp02 wrote:

The problem with the IPset/pool options are that they match only on a range of addresses, not specifically by source or destination

Eh? They match specificaly on either source or destination.

Quoted 1 line

also they seem to require the use of another userspace program to actually build the sets which in itself complicates the process.

True.

Quoted 2 lines

Is it hard to extend the source and destination match functions to accept multiple arguments?

Yes and no.

It is not hard to make a custom match matching multiple IP addresses, but it would be restricted in the number of addresses you can match.

If you need to group very many addresses then ippool/ipset is the correct tool.

Regards
Henrik

#2 lore raw
In reply to Eric Leblond
Quoted 4 lines · Eric Leblond

iptables/netfilter has to be efficient, rules generation script has to be elegant. Having 3 rules is as efficient as your masked "or" rules if it was coded and 3 separate rules are more simple than your global one so in a way this is more elegant.

For hipac this is true, but not really when using iptables.

Regards
Henrik

author
#4 lore raw
In reply to Henrik Nordstrom

The ippool and ipset matches only support linux 2.4 not 2.6 unfortunately. The iprange match would suit my needs but it only allows a single match as well. What would I need to change in iptables to allow the match to be called more than once, as in:

iptables -m iprange 10.0.0.0-10.255.255.255 -m iprange 172.16.0.0-172.16.255.255

is this an easy to add switch somewhere?

thanks,

----- Original Message -----
From: "Henrik Nordstrom" <[email protected]>
To: "Temp02" <[email protected]>
Cc: <[email protected]>; "Swapnil Nagle" <[email protected]>
Sent: Thursday, September 30, 2004 9:38 PM
Subject: Re: Multiple Address specification or match

Quoted 3 lines · On Thu, 30 Sep 2004, Temp02 wrote:
Quoted 2 lines

The problem with the IPset/pool options are that they match only on a

range

Quoted 10 lines
Quoted 1 line

of addresses, not specifically by source or destination

Eh? They match specificaly on either source or destination.

Quoted 2 lines

also they seem to require the use of another userspace program to actually build the sets which in itself complicates the process.

True.

Quoted 1 line

Is it hard to extend the source and destination match functions to

accept

Quoted 13 lines
Quoted 1 line

multiple arguments?

Yes and no.

It is not hard to make a custom match matching multiple IP addresses, but it would be restricted in the number of addresses you can match.

If you need to group very many addresses then ippool/ipset is the correct tool.

Regards
Henrik

#5 lore raw
Quoted 1 line · On Fri, 1 Oct 2004, Temp02 wrote:

The ippool and ipset matches only support linux 2.4 not 2.6 unfortunately.

I'm working on the rewriting of ipset, together with porting to 2.6.

Quoted 8 lines

The iprange match would suit my needs but it only allows a single match as well. What would I need to change in iptables to allow the match to be called more than once, as in:

iptables -m iprange 10.0.0.0-10.255.255.255 -m iprange 172.16.0.0-172.16.255.255

is this an easy to add switch somewhere?

The basic problem is that iptables matches are AND-ed. In you example you imply OR-ed matches.

Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics

          H-1525 Budapest 114, POB. 49, Hungary
#6 lore raw
In reply to Temp02
Quoted 4 lines · On Fri, 1 Oct 2004, Temp02 wrote:

iptables -m iprange 10.0.0.0-10.255.255.255 -m iprange 172.16.0.0-172.16.255.255

is this an easy to add switch somewhere?

Should work fine, except that it will then be a AND (both ranges must match) so it does not make much sense..

Regards
Henrik