All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joel Newkirk <netfilter@newkirk.us>
To: Anders Fugmann <afu@fugmann.dhs.org>, "james.Q.L" <shijialeeee@yahoo.ca>
Cc: netfilter@lists.netfilter.org
Subject: Re: problem reach the internal.
Date: Fri, 29 Nov 2002 21:20:41 -0500	[thread overview]
Message-ID: <200211292120.41544.netfilter@newkirk.us> (raw)
In-Reply-To: <3DE815EA.9040303@fugmann.dhs.org>

On Friday 29 November 2002 08:35 pm, Anders Fugmann wrote:
> james.Q.L wrote:
> > sorry, i forgot mention that the request from outside my local network to
> > the INET_IP:8888 is fine. only the internal request to it fails.
> >
> > i do not see what is wrong in the rules, anyone ?
>
> It cannot be done, as the webserver will try to give an answer to the
> query directly, and not back through your router, and thus the client
> will not accept the reply.
>
> For a more complete explanation, search the email archives. This
> question has been asked and answered numerous times.

That's what his SNAT rule should handle: (snippet from original message)

> the rules i added to try to make it work are :
> 
> iptables -t nat -A PREROUTING -p tcp -i eth1 --dport 8888 \
>       -j DNAT --to-destination 192.168.0.3:80
> iptables -A FORWARD -p tcp --dport 80 -d 192.168.0.3 -j ACCEPT
> iptables -t nat -A POSTROUTING -p tcp -s 192.168.0.0/24 -d 192.168.0.3 \
>     --dport 80 -j SNAT --to-source 192.168.0.1

port 80 requests heading out to the server (192.168.0.3) from anywhere on the 
lan (already DNATted in prerouting) are SNATted to appear to come from the 
firewall/router (192.168.0.1) so that they return through it properly.  Yes, 
this has been answered before, and is covered in the DNAT section of Oscar's 
tutorial, but the rules he has here appear to be correct. (well, along with 
the FORWARD EST/REL rule I didn't include in this snippet)

James - I'd recommend that you try:
iptables -z
to clear counters, then try accessing the server from the LAN, then
iptables -L -v -n
to list your ruleset along with the packet/byte counts which matched.  This 
will often show where unexpected things are happening.  IE, if the counts in 
the FORWARD rules accepting ESTABLISHED/RELATED and packets destined for the 
server are both zero, then the problem is at PREROUTING.  If the FORWARD 
count for server-bound shows your request, but your POSTROUTING SNAT is zero, 
or if those both show counts but nothing coming back from the server 
(EST/REL) those can narrow things down.  (of course if the DNAT rule in 
PREROUTING counts 0 that pretty much nails the problem down... :^) Extreme 
Logging can help as well, where you insert a LOG rule as the first rule in 
each chain, try to connect, then check the logs.  This can generate a LOT of 
logging if there is other activity through the firewall, though.  If you do 
this, you should log nat PRE and POST, FORWARD, and INPUT.  The first three 
are where it should be, the fourth is where it shouldn't but might, if the 
DNAT isn't matching.

I'd also suggest you reconsider FORWARD rule #2, which accepts EVERYTHING, and 
limit your MASQUERADE to traffic outbound to the internet, simply with 
-o $eth0 or whatever interface connects to the world.

j



  reply	other threads:[~2002-11-30  2:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-29 19:32 problem reach the internal james.Q.L
2002-11-30  1:03 ` james.Q.L
2002-11-30  1:35   ` Anders Fugmann
2002-11-30  2:20     ` Joel Newkirk [this message]
2002-11-30  8:34       ` james.Q.L
2002-11-30 15:27         ` Joel Newkirk
2002-12-01 22:35           ` james.Q.L
2002-11-30 11:44       ` Anders Fugmann

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=200211292120.41544.netfilter@newkirk.us \
    --to=netfilter@newkirk.us \
    --cc=afu@fugmann.dhs.org \
    --cc=netfilter@lists.netfilter.org \
    --cc=shijialeeee@yahoo.ca \
    /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.