All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Mindaugas" <mind@bi.lt>
To: netfilter@lists.netfilter.org
Subject: How to simplify iptables rules
Date: Wed, 20 Sep 2006 17:19:28 +0300	[thread overview]
Message-ID: <029a01c6dcbf$c9db3b10$f20214ac@bite.lt> (raw)


  Hello,

  How to configure restrictive NAT firewall with different rules?

  For example I want to NAT packets from net 10.0.0.0/8 to tcp ports 25 and 
80. Also I want to NAT packets from host 192.168.1.1.
  Now I understand that I need the following rules:

iptables -A FORWARD -s 10.0.0.0/8 -i eth0 -o eth1 -m multiport --dports 
25,80 -j ACCEPT
iptables -A FORWARD -d 10.0.0.0/8 -i eth1 -o eth0 -m multiport --sports 
25,80 -j ACCEPT
iptables -A FORWARD -s 192.168.1.1 -i eth0 -o eth1 -j ACCEPT
iptables -A FORWARD -d 192.168.1.1 -i eth1 -o eth0 -j ACCEPT
iptables -A FORWARD -j DROP
iptables -t nat -A POSTROUTING -s 10.0.0.0/8 -o eth1 -m multiport --dports 
25,80 -j SNAT --to-source=1.1.1.1
iptables -t nat -A POSTROUTING -s 192.168.1.1 -o eth1 -j 
SNAT --to-source=2.2.2.2

  So there are 3 rules for every host - forward out, forward back in, NAT. 
Maybe it is possible to simplify rules? E.g. will this work for forwarding 
packets back:

-A FORWARD -i eth1 -o eth0 -m conntrack --ctstate SNAT -j ACCEPT

  If I would have simple SNAT I then could also mark packets in PREROUTING 
and simply let marked packets to forward and SNAT. But as one can notice I 
need to SNAT them to different source addresses.

  Thanks,

  Mindaugas



                 reply	other threads:[~2006-09-20 14:19 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='029a01c6dcbf$c9db3b10$f20214ac@bite.lt' \
    --to=mind@bi.lt \
    --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.