Skip to contentSkip to conversation

Multiple Address specification or match

DISCUSSION Temp02 5 participants 7 messages Sep 30, 2004 netfilter

lore
Share & tools
lore

Temp02

author
#0 lore raw

Hello,

How difficult would it be to extend netfilter/iptables to allow multiple source/destination address pairs (with negation) 'anded' together, as in -s 192.168.0.0/24 -s 10.0.0.0/8 -s ! 230.22.22.0/24. Or a match to do this same thing?

regards,
Andrew.

#1 lore raw
Quoted 7 lines

How difficult would it be to extend netfilter/iptables to allow multiple source/destination address pairs (with negation) 'anded' together, as in -s 192.168.0.0/24 -s 10.0.0.0/8 -s ! 230.22.22.0/24. Or a match to do this same thing?

How can the source address be "anded" ?
The source address cannot be both 192.168.0.1 and 10.0.0.1.

-- Swapnil

author
#2 lore raw

No obviously a single source can't be both addresses, but the intent is to allow a single rule to be used to match sources from both source ranges.

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

Quoted 3 lines
Quoted 3 lines

How difficult would it be to extend netfilter/iptables to allow multiple source/destination address pairs (with negation) 'anded' together, as

in -s

Quoted 1 line
Quoted 1 line

192.168.0.0/24 -s 10.0.0.0/8 -s ! 230.22.22.0/24. Or a match to do this

same

Quoted 7 lines
Quoted 3 lines

thing?

How can the source address be "anded" ?
The source address cannot be both 192.168.0.1 and 10.0.0.1.

-- Swapnil

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

No obviously a single source can't be both addresses, but the intent is to allow a single rule to be used to match sources from both source ranges.

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

author
#4 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?

----- 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

to

Quoted 11 lines
Quoted 1 line

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

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

#5 lore raw
Quoted 2 lines

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

Yes, they are pretty wired into iptables. And I would worry about their performance.

But it should be easy to create a new match to do it. There is already multiport and mport. The equivalent for addresses should not be hard.

Simon

#6 lore raw
In reply to Swapnil Nagle

Yes you're right, I meant 'or'd not 'anded' together.

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

Quoted 3 lines
Quoted 3 lines

How difficult would it be to extend netfilter/iptables to allow multiple source/destination address pairs (with negation) 'anded' together, as

in -s

Quoted 1 line
Quoted 1 line

192.168.0.0/24 -s 10.0.0.0/8 -s ! 230.22.22.0/24. Or a match to do this

same

Quoted 8 lines
Quoted 3 lines

thing?

How can the source address be "anded" ?
The source address cannot be both 192.168.0.1 and 10.0.0.1.

-- Swapnil