From: "Brad Morgan" <B-Morgan@concentric.net>
To: 'Pierre Gillet' <gpg__gpg@hotmail.com>, netfilter@lists.netfilter.org
Cc: gpg.gpg@caramail.com
Subject: RE: problem with forward/nat
Date: Sun, 7 Mar 2004 07:47:47 -0700 [thread overview]
Message-ID: <006301c40453$2885f1c0$0400a8c0@bradmorgan> (raw)
In-Reply-To: <BAY1-F168WzqJX7rVGS00004a39@hotmail.com>
> my script:
> echo "1" > /proc/sys/net/ipv4/ip_forward
>
> #vidage des tables
> iptables -F
> iptables -X
>
> #policies par defaut
> iptables -P INPUT DROP
> iptables -P OUTPUT DROP
> iptables -P FORWARD DROP
>
> #autorise boucle locale
>
> iptables -A OUTPUT -o lo -m state --state RELATED,ESTABLISHED,NEW -j
> ACCEPT
> iptables -A OUTPUT -o eth0 -p tcp --dport 80 -j ACCEPT
> iptables -A OUTPUT -o eth0 -p tcp --dport 443 -j ACCEPT
> iptables -A OUTPUT -o eth0 -p udp --dport 53 -j ACCEPT
> iptables -A OUTPUT -o eth1 -d 192.168.1.0/24 -j ACCEPT
> iptables -A OUTPUT -o eth0 -p tcp --dport 23 -j ACCEPT
>
> iptables -A INPUT -i lo -m state --state RELATED,ESTABLISHED,NEW -j ACCEPT
> iptables -A INPUT -i eth0 -p udp --sport 53 -j ACCEPT
> iptables -A INPUT -i eth0 -p tcp --sport 80 -j ACCEPT
> iptables -A INPUT -i eth0 -p tcp --sport 443 -j ACCEPT
> iptables -A INPUT -i eth1 -s 192.168.1.0/24 -j ACCEPT
> iptables -A INPUT -i eth0 -p tcp --sport 23 -j ACCEPT
>
> #forward
>
> iptables -A POSTROUTING -t nat -o eth0 -j MASQUERADE
> iptables -A FORWARD -s 192.168.1.0/24 -j ACCEPT -o eth0
> #iptables -A FORWARD -i eth0 -o eth0 -m state --state ESTABLISHED,RELATED
> -j
> ACCEPT
>
> problem:
> pc firewall can acces on web
> pc firewall can acces in private network
> private network can acces in pc firewall
> private network CAN'T acces on web
>
The first problem I see is that you allow ESTABLISHED,RELATED,NEW in your
INPUT and OUTPUT chains. Once you hit that rule, the only thing going past
are INVALID packets so the rest of the INPUT and OUTPUT chains aren't doing
anything useful.
The second problem I see is the FORWARD chain has "-i eth0 -o eth0" on the
ESTABLISHED,RELATED rule which can't be right. All the packets on the
FORWARD chain are going to be either "-i eth0 -o eth1" or "-i eth1 -o eth0".
Since your private address space (192.168.1.0/24) shouldn't exist on the
outside, there's little need to specify both the address and the interface
in your rules.
It looks like you have rules in your INPUT and OUTPUT chains intended to
pass traffic through the firewall. Only packets directed at the firewall go
through INPUT and only packets generated by the firewall go through OUTPUT.
Packets passing through the firewall are seen on FORWARD.
Look at (make that study!) the tutorial, including a nice diagram (in
"Traversing of Tables and Chains"), written by Oskar Andreasson at
http://iptables-tutorial.frozentux.net.
Here's what I suggest to help get you going...
Change your default policies to ACCEPT (temporarily).
# Keep this
iptables -A POSTROUTING -t nat -o eth0 -j MASQUERADE
The first two rules in each chain should be:
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -m state --state INVALID -j DROP
iptables -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -m state --state INVALID -j DROP
iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -m state --state INVALID -j DROP
Now the only packets the rest of the rules in each chain see are state NEW.
Add your rules one at a time and check the packet counts using the command:
iptables -nvL
If you add a rule for web traffic and then surf the web. The rule should
have a count associated with it. If not, then the rule isn't doing what you
expect!
When all the rules you add have counts then you can change the default
policies back to DROP and your firewall is complete. Optionally you can add
the following to the end of each chain so when something doesn't work, you
can examine the firewall syslog to see what went wrong. Make sure if you do
this that you have set up some kind of log rotation so you don't fill the
disk up with log files.
#
# Log whats left before dropping (should be last rule in each chain)
#
iptables -A FORWARD -m limit --limit 20/minute -j LOG --log-level \
notice --log-prefix "[FORWARD] "
iptables -A INPUT -m limit --limit 20/minute -j LOG --log-level \
notice --log-prefix "[INPUT] "
iptables -A OUTPUT -m limit --limit 20/minute -j LOG --log-level \
notice --log-prefix "[OUTPUT] "
next prev parent reply other threads:[~2004-03-07 14:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-07 3:13 problem with forward/nat Pierre Gillet
2004-03-07 9:26 ` Antony Stone
2004-03-07 9:46 ` Antony Stone
2004-03-07 14:47 ` Brad Morgan [this message]
2004-03-07 15:03 ` Antony Stone
2004-03-07 15:57 ` Brad Morgan
2004-03-07 18:24 ` Fabian Hartmann
2004-03-07 18:37 ` Antony Stone
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='006301c40453$2885f1c0$0400a8c0@bradmorgan' \
--to=b-morgan@concentric.net \
--cc=gpg.gpg@caramail.com \
--cc=gpg__gpg@hotmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox