Networking Forums

Networking Forums > Computer Networking > Linux Networking > iptables: allow multiple source addresses

Reply
Thread Tools Display Modes

iptables: allow multiple source addresses

 
 
jqpx37
Guest
Posts: n/a

 
      10-03-2006, 11:25 PM
It's clear to me how to drop all packets except those coming from one
address/mask:
.... -s ! address/[mask] ... -j DROP

What's not so clear is what to do if I want to allow more than one
address/[mask]. Currently I'm doing it via a simple user-defined chain,
e.g.
.... -s ! address1/[mask1] ... -j chain_1
.... chain_1 ... -s ! address2/[mask2] -j DROP

Is there a more clever way of doing it than this?

TIA



Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
 
Reply With Quote
 
 
 
 
Pascal Hambourg
Guest
Posts: n/a

 
      10-03-2006, 11:43 PM
Hello,

jqpx37 a écrit :
> It's clear to me how to drop all packets except those coming from one
> address/mask:
> ... -s ! address/[mask] ... -j DROP


No, obviously this is not clear to you. :-)

> What's not so clear is what to do if I want to allow more than one
> address/[mask]. Currently I'm doing it via a simple user-defined chain,
> e.g.
> ... -s ! address1/[mask1] ... -j chain_1
> ... chain_1 ... -s ! address2/[mask2] -j DROP
>
> Is there a more clever way of doing it than this?


Yes : set default policies to DROP, and ACCEPT what you want to allow
instead of DROP what you don't want to allow. This is much safer.
 
Reply With Quote
 
jqpx37
Guest
Posts: n/a

 
      10-04-2006, 02:20 AM

"Pascal Hambourg" <boite-a-(E-Mail Removed)> wrote in message
news:efusja$9pf$(E-Mail Removed)...
> Hello,
>
> jqpx37 a écrit :
>> It's clear to me how to drop all packets except those coming from one
>> address/mask:
>> ... -s ! address/[mask] ... -j DROP

>
> No, obviously this is not clear to you. :-)
>
>> What's not so clear is what to do if I want to allow more than one
>> address/[mask]. Currently I'm doing it via a simple user-defined chain,
>> e.g.
>> ... -s ! address1/[mask1] ... -j chain_1
>> ... chain_1 ... -s ! address2/[mask2] -j DROP
>>
>> Is there a more clever way of doing it than this?

>
> Yes : set default policies to DROP, and ACCEPT what you want to allow
> instead of DROP what you don't want to allow. This is much safer.


OK.

Though what if one doesn't want the ACCEPT statement to come late in the
chain?

(My policy is already DROP.)



Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
 
Reply With Quote
 
Pascal Hambourg
Guest
Posts: n/a

 
      10-04-2006, 09:14 AM
jqpx37 a écrit :
>>
>>Yes : set default policies to DROP, and ACCEPT what you want to allow
>>instead of DROP what you don't want to allow. This is much safer.

>
> OK.
> Though what if one doesn't want the ACCEPT statement to come late in the
> chain?


What do you mean ?
 
Reply With Quote
 
jqpx37
Guest
Posts: n/a

 
      10-04-2006, 09:22 AM

"Pascal Hambourg" <boite-a-(E-Mail Removed)> wrote in message
news:efvu10$mi7$(E-Mail Removed)...
> jqpx37 a écrit :
>>>
>>>Yes : set default policies to DROP, and ACCEPT what you want to allow
>>>instead of DROP what you don't want to allow. This is much safer.

>>
>> OK. Though what if one doesn't want the ACCEPT statement to come late in
>> the chain?

>
> What do you mean ?


Once you ACCEPT, no more rules can apply.



Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
 
Reply With Quote
 
Pascal Hambourg
Guest
Posts: n/a

 
      10-04-2006, 10:08 AM
jqpx37 a écrit :
>>
>>>>Yes : set default policies to DROP, and ACCEPT what you want to allow
>>>>instead of DROP what you don't want to allow. This is much safer.
>>>
>>>OK. Though what if one doesn't want the ACCEPT statement to come late in
>>>the chain?

>>
>>What do you mean ?

>
> Once you ACCEPT, no more rules can apply.


Sure. Same when you DROP. That's the goal, isn't it ?
Again, I don't see your point. When a chain contains only ACCEPT rules,
the rule ordering does not matter so much.

Do you mean that in your case the source address is not the only match
needed to ACCEPT packets ? Then put the other matches in the rule, and
if you cannot put them all in a single rule, user-defined chains come in
handy. Every time you have an AND condition, you create a new chain.
Every time you have an OR condition, you create a new rule.

Example :
if condition1 AND (condition2 OR condition3) then ACCEPT

-A step1 condition1 -j step2
-A step2 condition2 -j ACCEPT
-A step2 condition3 -j ACCEPT

or

-A step1 condition2 -j step2
-A step1 condition3 -j step2
-A step2 condition1 -j ACCEPT
 
Reply With Quote
 
jqpx37
Guest
Posts: n/a

 
      10-04-2006, 10:57 AM

"Pascal Hambourg" <boite-a-(E-Mail Removed)> wrote in message
news:eg0178$nur$(E-Mail Removed)...
> jqpx37 a écrit :
>>>
>>>>>Yes : set default policies to DROP, and ACCEPT what you want to allow
>>>>>instead of DROP what you don't want to allow. This is much safer.
>>>>
>>>>OK. Though what if one doesn't want the ACCEPT statement to come late in
>>>>the chain?
>>>
>>>What do you mean ?

>>
>> Once you ACCEPT, no more rules can apply.

>
> Sure. Same when you DROP. That's the goal, isn't it ?
> Again, I don't see your point. When a chain contains only ACCEPT rules,
> the rule ordering does not matter so much.
>
> Do you mean that in your case the source address is not the only match
> needed to ACCEPT packets ?


Yes.

> Then put the other matches in the rule, and if you cannot put them all in
> a single rule, user-defined chains come in handy. Every time you have an
> AND condition, you create a new chain. Every time you have an OR
> condition, you create a new rule.
>
> Example :
> if condition1 AND (condition2 OR condition3) then ACCEPT
>
> -A step1 condition1 -j step2
> -A step2 condition2 -j ACCEPT
> -A step2 condition3 -j ACCEPT
>
> or
>
> -A step1 condition2 -j step2
> -A step1 condition3 -j step2
> -A step2 condition1 -j ACCEPT


Thanks for the informative reply.

Cheers.



Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
 
Reply With Quote
 
Llanzlan Klazmon the 15th
Guest
Posts: n/a

 
      10-04-2006, 10:15 PM
"jqpx37" <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

>
> "Pascal Hambourg" <boite-a-(E-Mail Removed)> wrote in message
> news:eg0178$nur$(E-Mail Removed)...
>> jqpx37 a écrit :
>>>>
>>>>>>Yes : set default policies to DROP, and ACCEPT what you want to
>>>>>>allow instead of DROP what you don't want to allow. This is much
>>>>>>safer.
>>>>>
>>>>>OK. Though what if one doesn't want the ACCEPT statement to come late
>>>>>in the chain?
>>>>
>>>>What do you mean ?
>>>
>>> Once you ACCEPT, no more rules can apply.

>>
>> Sure. Same when you DROP. That's the goal, isn't it ?
>> Again, I don't see your point. When a chain contains only ACCEPT rules,
>> the rule ordering does not matter so much.
>>
>> Do you mean that in your case the source address is not the only match
>> needed to ACCEPT packets ?

>
> Yes.
>
>> Then put the other matches in the rule, and if you cannot put them all
>> in a single rule, user-defined chains come in handy. Every time you
>> have an AND condition, you create a new chain. Every time you have an
>> OR condition, you create a new rule.
>>
>> Example :
>> if condition1 AND (condition2 OR condition3) then ACCEPT
>>
>> -A step1 condition1 -j step2
>> -A step2 condition2 -j ACCEPT
>> -A step2 condition3 -j ACCEPT
>>
>> or
>>
>> -A step1 condition2 -j step2
>> -A step1 condition3 -j step2
>> -A step2 condition1 -j ACCEPT

>
> Thanks for the informative reply.
>
> Cheers.
>
>
>
> Posted Via Usenet.com Premium Usenet Newsgroup Services
> ----------------------------------------------------------
> ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----------------------------------------------------------
> http://www.usenet.com
>


Another thing. For maximum efficiency you want the bulk of the traffic
dealt with as early in the chain as possible as that minimises the
overhead. Typically you want a rule to accept established and related
packets near the start of the chain.

Klazmon.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
iptables port forwarding for specific source addresses ynotssor Linux Networking 22 08-30-2008 03:52 AM
Server 2003 obtaining multiple multiple IP addresses via DHCP pbrommer@gmail.com Windows Networking 1 03-29-2007 02:24 AM
iptables and multiple ip-addresses? Manuel Garcia Linux Networking 4 01-08-2007 06:29 PM
Checksum of ip headers : is it changed when switching source and dest addresses ? markryde@gmail.com Linux Networking 4 10-02-2006 08:26 AM
Choosing the source IP if multiple addresses are bind to one inter circle Windows Networking 3 11-29-2005 06:13 PM



1 2 3 4 5 6 7 8 9 10 11