All of lore.kernel.org
 help / color / mirror / Atom feed
From: bash <0x62ash@gmail.com>
To: netfilter@lists.netfilter.org
Subject: need an elegant solution
Date: Tue, 28 Mar 2006 00:52:55 +0400	[thread overview]
Message-ID: <20060328005255.680651ad.0x62ash@gmail.com> (raw)

  Hello All,

From my routers point of view internet devided in 3 zones:
1) MYNET="10.20.0.0/16"
2) FRIENDNET="10.21.0.0/16 10.22.0.0/16 10.23.0.3 10.24.0.4"
3) all other networks and IPs

As you can see $FRIENDNET contains not just NETs, but IPs too. I
can't use one IPSET set, so i decided not to use IPSET functionally and
wait for some "union" types in IPSET in future releases
[http://lists.netfilter.org/pipermail/netfilter/2006-March/065103.html].

Problem is that manipulation with $FRIENDNET in form:
---%<-----------------------------------
for net in $FRIENDNET
do
   iptables -A (FORWARD|INPUT) (-s|-d) $net [...]
done
---%<-----------------------------------
Is not elegant when you need to grant/drop access to many
resourses/services/etc. netfilter will be clutter up with identical
rules...

So I want to find elegant solution for this situation :))

My current approach is:
---%<-----------------------------------
iptables -N FRIENDNET_IN_ACCEPT
iptables -F FRIENDNET_IN_ACCEPT
for net in $FRIENDNET
do
   iptables -s $net -j ACCEPT
done

iptables -N FRIENDNET_OUT_ACCEPT
iptables -F FRIENDNET_OUT_ACCEPT
for net in $FRIENDNET
do
   iptables -d $net -j ACCEPT
done

# grant access to some service
iptables -p tcp -A INPUT -s $MYNET --dport some-service -j ACCEPT
iptables -p tcp -A INPUT --dport some-service -j FRIENDNET_IN_ACCEPT
iptables -p tcp -A INPUT --dport some-service -j DROP

# forward from my net to friends net and vice versa
iptables -P FORWARD DROP
iptables -A FORWARD -d $MYNET -j FRIENDNET_IN_ACCEPT
iptables -A FORWARD -s $MYNET -j FRIENDNET_OUT_ACCEPT
---%<-----------------------------------

Maybe you know more elegant solution?

-- 
Biomechanica Artificial Sabotage Humanoid


                 reply	other threads:[~2006-03-27 20:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060328005255.680651ad.0x62ash@gmail.com \
    --to=0x62ash@gmail.com \
    --cc=netfilter@lists.netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.