All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joel Newkirk <netfilter@newkirk.us>
To: Damon Brinkley <damon@betcoinc.com>, stewart.thompson@shaw.ca
Cc: netfilter@lists.netfilter.org
Subject: Re: Filter by IP address problems
Date: Thu, 12 Dec 2002 09:39:29 -0500	[thread overview]
Message-ID: <200212120939.29993.netfilter@newkirk.us> (raw)
In-Reply-To: <1039702392.6682.14.camel@damon.betcolan>

On Thursday 12 December 2002 09:13 am, Damon Brinkley wrote:
> Thanks Stu but I'm still doing something wrong.
>
> Here's the rules I have now.
>
> ###############################
>
> echo 0 > /proc/sys/net/ipv4/ip_forward
>
> /sbin/modprobe iptable_nat
> /sbin/modprobe ip_conntrack
> /sbin/modprobe ip_conntrack_ftp
>
> /sbin/iptables -F
> /sbin/iptables -t nat -F
> /sbin/iptables -X
> /sbin/iptables -t nat -X
>
> /sbin/iptables -P INPUT DROP
> /sbin/iptables -P OUTPUT DROP
> /sbin/iptables -P FORWARD DROP
>
> # INPUT CHAIN
> # NONUSERS = 172.17.0.0/20
> /sbin/iptables -A INPUT -s $NONUSERS -j ACCEPT
>
> # FORWARD CHAIN
> /sbin/iptables -A FORWARD -s $NONUSERS -j ACCEPT
>
> # POSTROUTING
> /sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
>
> echo 1 > /proc/sys/net/ipv4/ip_forward
>
> ######################################
>
> This should give my laptop, IP 172.17.0.244, complete access but I get
> Request timed out when pinging www.yahoo.com
>
> Here's what I get when running iptables -nL

You can also run "iptables -t nat -nL" to show the nat table chains.  As 
with most iptables calls, if you don't specify it assumes filter table.

anyway, make sure you are also doing:
echo 1 > /proc/sys/net/ipv4/ip_dynaddr
so that it will actually have (and maintain) the current IP address for 
masquerading.

Finally, you are not allowing any return connection back to the laptop 
through the FORWARD chain.  Try adding:

/sbin/iptables -A FORWARD -d $NONUSERS -m state \
--state ESTABLISHED -j ACCEPT

and it should work for browsing.  If you use "ESTABLISHED,RELATED" 
instead then it should be more reliable, since it will allow icmp 
traffic related to the browsing.

Also, you are allowing the laptop to communicate to the firewall box 
local processes (INPUT) but not allowing anything back from it to the 
laptop (OUTPUT).  If you need them to communicate with each other, apart 
from the firewall forwarding (separate issues) then you need to allow 
communications in OUTPUT that go to the laptop as well, either simply 
ACCEPTing appropriate traffic, or using a state rule as above in OUTPUT 
to allow local processes on the firewall box to reply, but not initiate 
connections to the laptop.

I've never worked with ipchains, just iptables, but I gather that with 
ipchains it was necessary to allow traffic through INPUT in order to 
forward.  (I've seen this a lot this past week :^)  With iptables the 
packets hit prerouting then netfilter decides whether the packet is 
destined for the local box, or forwarding, and it goes to EITHER one or 
the other, but not both.  INPUT and OUTPUT are for the local box itself, 
and don't have any affect at all on forwarding, SNAT/DNAT, etc.

j



  reply	other threads:[~2002-12-12 14:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-11 21:40 Filter by IP address problems Damon Brinkley
2002-12-11 21:04 ` Marcello Scacchetti
2002-12-11 23:26 ` Stewart Thompson
2002-12-12 14:13   ` Damon Brinkley
2002-12-12 14:39     ` Joel Newkirk [this message]
2002-12-12 15:16       ` Damon Brinkley

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=200212120939.29993.netfilter@newkirk.us \
    --to=netfilter@newkirk.us \
    --cc=damon@betcoinc.com \
    --cc=netfilter@lists.netfilter.org \
    --cc=stewart.thompson@shaw.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.