From: Jason Opperisano <opie@817west.com>
To: netfilter@lists.netfilter.org
Subject: Re: NAT to a client
Date: Thu, 28 Apr 2005 10:35:38 -0400 [thread overview]
Message-ID: <20050428143538.GA29900@bender.817west.com> (raw)
In-Reply-To: <652c9e655b89.655b89652c9e@vsnl.net>
On Thu, Apr 28, 2005 at 11:22:21AM +0500, varun_saa@vsnl.net wrote:
> Hello,
> My server is om Mandrake 10.1
> eth0 is WAN with static IP connected to 512K DSL.
> eth1 is LAN - 192.168.0.0/24.
>
> I have the iptables rules :
>
> # Generated by iptables-save v1.2.9 on Tue Apr 26 14:50:01 2005
> *nat
> :OUTPUT ACCEPT [0:0]
> :PREROUTING ACCEPT [0:0]
> :POSTROUTING ACCEPT [0:0]
> -A POSTROUTING -o eth0 -j MASQUERADE
so you MASQ all outbound traffic
> COMMIT
> # Completed on Tue Apr 26 14:50:01 2005
> # Generated by iptables-save v1.2.9 on Tue Apr 26 14:50:01 2005
> *mangle
> :PREROUTING ACCEPT [707:100355]
> :INPUT ACCEPT [704:99811]
> :FORWARD ACCEPT [0:0]
> :OUTPUT ACCEPT [541:74129]
> :POSTROUTING ACCEPT [611:85191]
> COMMIT
> # Completed on Tue Apr 26 14:50:01 2005
> # Generated by iptables-save v1.2.9 on Tue Apr 26 14:50:01 2005
> *filter
> :FORWARD ACCEPT [0:0]
> :INPUT DROP [0:0]
> :OUTPUT ACCEPT [0:0]
the policies of FORWARD and OUTPUT are set to ACCEPT.
> -A INPUT -j ACCEPT
and hey--so is INPUT. no further rule in INPUT will ever be matched as
you just accepted all packets.
> -A INPUT -s 127.0.0.1 -j ACCEPT
normally written as "-A INPUT -i lo -j ACCEPT"
> -A INPUT -p tcp -m tcp -i eth1 --dport 3128 --sport 80 -j ACCEPT
the source port of traffic destined to a squid proxy is not 80, it's
1024:65535...why do i *constantly* see this in rules sets?
> -A INPUT -p udp -m udp -i eth1 --dport 3128 --sport 80 -j ACCEPT
and it's tcp only, not udp.
> -A INPUT -s 62.0.0.0/255.0.0.0 -i eth0 -j REJECT
> -A INPUT -p tcp -m tcp -s 217.81.0.0/255.255.0.0 -i eth0 -j REJECT
> -A INPUT -i eth0 -j DROP
> -A INPUT -p tcp -m tcp -i eth1 --sport 80 -j DROP
> -A INPUT -m state -i eth1 --state ESTABLISHED,RELATED -j ACCEPT
again--all of those are completely irrelevant. good thing too--since
you're not allowing any ESTABLISHED,RELATED to come back through eth0,
which i guess is pretty secure, but it'd be less hassle to just power
off the firewall and cancel your ISP service.
> -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
> -A FORWARD -p tcp -i eth1 -o eth0 --dport 25 --sport 1024: -j ACCEPT --syn
> -A FORWARD -p tcp -i eth1 -o eth0 --dport 110 --sport 1024: -j ACCEPT --syn
> -A FORWARD -p tcp -i eth1 -o eth0 --dport 1863 --sport 1024: -j ACCEPT --syn
> -A FORWARD -p tcp -i eth1 -o eth0 --dport 5050 --sport 1024: -j ACCEPT --syn
those all look pretty good; but remember, you set the policy of FORWARD
to ACCEPT, so any packets not matching the above rules will make it
through anyways.
> -A OUTPUT -p udp --dport 53 --sport 1024: -j ACCEPT
> -A OUTPUT -p tcp -m owner -o eth0 --dport 80 --sport 1024: --uid-owner squid -j ACCEPT --syn
nice work there. oh, and since the policy of OUTPUT is ACCEPT, all
other output traffic is allowed out anyways.
> I would like to bypass squid proxy and do
> a NAT for a client - 192.168.0.253.
i can't see how that would possibly be dropped anyways, but:
-A FORWARD -i eth1 -o eth0 -p tcp --syn -s 192.168.0.253 \
--sport 1024: --dport 80 -j ACCEPT
you'd probably also need to allow DNS resolution for that client as well
(unless you have an internal DNS server):
-A FORWARD -i eth1 -o eth0 -p udp -s 192.168.0.253 \
--sport 1024: --dport 53 -j ACCEPT
you already have the necessary MASQ rule.
-j
--
"Stewie: For God's sake, shake me. Shake me like a British nanny."
--Family Guy
next prev parent reply other threads:[~2005-04-28 14:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-28 6:22 NAT to a client varun_saa
2005-04-28 14:35 ` Jason Opperisano [this message]
2005-04-28 17:21 ` Taylor, Grant
2005-04-28 17:38 ` Jason Opperisano
2005-04-28 19:28 ` Taylor, Grant
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=20050428143538.GA29900@bender.817west.com \
--to=opie@817west.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