From: "Rob Sterenborg" <rob@sterenborg.info>
To: netfilter@lists.netfilter.org
Subject: Re: DNAT Problem
Date: Tue, 27 Apr 2004 09:20:15 +0200 [thread overview]
Message-ID: <001201c42c28$16064480$1202a8c0@admin> (raw)
In-Reply-To: 1443.80.0.0.23.1083045451.squirrel@80.0.0.175
> I have an email server running behind the firewall serving POP3 &
SMTP.
> Now all requests DNAT from the firewall are logged as if received from
the
> firewall itself and thus considered as trusted ip. I want all the DNAT
> requests to be logged as received real source ip and not from firewall
ip.
...
> # Default Policy Rules
> iptables -P INPUT DROP
> iptables -P OUTPUT ACCEPT
> iptables -P FORWARD ACCEPT
Set this one to DROP and use an ACCEPT rule for what you want to accept
(see below).
That way you won't easily make a mistake when forwarding.
> iptables -t nat -P PREROUTING ACCEPT
> iptables -t nat -P POSTROUTING ACCEPT
> iptables -t nat -P OUTPUT ACCEPT
>
> # Allow only incoming connections that we establish first
> iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
>
> # Rules for lo
> iptables -A INPUT -s 127.0.0.0/255.0.0.0 -i ! lo -j DROP
That should read :
iptables -A INPUT -i lo -s 127.0.0.0/8 -j ACCEPT
iptables -A INPUT -i ! lo -s 127.0.0.0/255.0.0.0 -j DROP
You want to accept traffic from 127.0.0.0/8 on interface lo.
> # Rules for eth0 - LAN
> iptables -A INPUT -i eth0 -p tcp --dport 22 -j ACCEPT
>
> # Rules for eth1 - Internet
> iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
You say eth1 is internet. Why eth0 ?
Should this say :
iptables -t nat -A POSTROUTING -o eth1 -s <net_lan> -j SNAT \
--to-source <ip_inet>
> iptables -A INPUT -i eth1 -p icmp -j DROP
You already do this since you don't have a rule acceping it and policy
is DROP.
> iptables -A INPUT -i eth1 -p tcp -m tcp ! --tcp-flags SYN,RST,ACK
SYN -j
> ACCEPT
Why are you accepting this ?
You have set policy to DROP for the INPUT chain. Nice. Everything will
be dropped that doesn't match a rule.
You accept RELATED and ESTABLISHED traffic. Good.
The nex rule you accept tcp packets, that has not SYN set out of the
SYN, RST and ACK flags. Could it be you're matching related/established
traffic ? You already do that.
> # SSH
> iptables -A INPUT -i eth1 -p tcp --dport 22 -j ACCEPT
>
If you have set policy DROP for the FORWARD chain, you now have to
ACCEPT (and LOG, because that is what you wanted after all) certain
traffic. Below I see you're forwarding to 2 different servers :
192.168.0.6 and 192.168.0.190.
So I think you want this :
iptables -A FORWARD -i eth1 -o eth0 -d 192.168.0.6 -p tcp --dport 25 \
-j LOG --log-prefix "ipt:SMTP "
iptables -A FORWARD -i eth1 -o eth0 -d 192.168.0.6 -p tcp --dport 25 \
-j ACCEPT
iptables -A FORWARD -i eth1 -o eth0 -d 192.168.0.6 -p tcp --dport 110 \
-j LOG --log-prefix "ipt:POP3 "
iptables -A FORWARD -i eth1 -o eth0 -d 192.168.0.6 -p tcp --dport 110 \
-j ACCEPT
iptables -A FORWARD -i eth1 -o eth0 -d 192.168.0.6 -p tcp --dport 8000 \
-j LOG --log-prefix "ipt:WEBMAIL "
iptables -A FORWARD -i eth1 -o eth0 -d 192.168.0.6 -p tcp --dport 8000 \
-j ACCEPT
iptables -A FORWARD -i eth1 -o eth0 -d 192.168.0.6 -p tcp --dport 80 \
-j LOG --log-prefix "ipt:WEB "
iptables -A FORWARD -i eth1 -o eth0 -d 192.168.0.6 -p tcp --dport 80 \
-j ACCEPT
> # Email Server Access From Outside
> # SMTP
> iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 25 -j DNAT --to
> 192.168.0.6:25
> # Web
> iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j DNAT --to
> 192.168.0.190:80
>
> # POP3
> iptables -t nat -A PREROUTING -p tcp -i eth1 --dport 110 -j DNAT --to
> 192.168.0.6:110
>
> # WebMail
> iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 8000 -j DNAT --to
> 192.168.0.6:80
> iptables -A INPUT -i eth1 -j DROP
You have set the INPUT policy to DROP so there is no reason to do this.
Gr,
Rob
next prev parent reply other threads:[~2004-04-27 7:20 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-27 5:57 [Fwd: Re: DNAT Problem] test
2004-04-27 7:20 ` Rob Sterenborg [this message]
[not found] ` <1081.80.0.0.23.1083127867.squirrel@80.0.0.175>
[not found] ` <000901c42cef$68603d40$1202a8c0@admin>
2004-05-04 5:32 ` DNAT Problem test
[not found] <45227670.8040702@mail.nankai.edu.cn>
2006-10-03 14:48 ` DNAT problem Marco Berizzi
[not found] <4521C6A3.1040902@mail.nankai.edu.cn>
2006-10-03 10:11 ` Marco Berizzi
-- strict thread matches above, loose matches on Subject: below --
2006-10-02 8:00 Stefan Friedel
2006-10-02 8:25 ` Marco Berizzi
2006-10-02 10:42 ` Pascal Hambourg
2006-10-02 12:01 ` Stefan Friedel
2006-10-02 12:51 ` Marco Berizzi
2006-10-02 13:14 ` Pascal Hambourg
2006-10-02 14:18 ` Stefan Friedel
2006-10-02 12:48 ` Marco Berizzi
2006-07-08 21:00 Antonio Di Bacco
2005-01-22 15:59 dnat problem Pablo Allietti
2005-01-22 19:45 ` Jason Opperisano
2005-01-23 0:26 ` Pablo Allietti
[not found] ` <20050125150114.GA25839@omega.lacnic.net.uy>
2005-01-25 15:24 ` Pablo Allietti
2005-01-25 15:25 ` Pablo Allietti
2004-06-10 11:03 DNAT problem Paul M. Goorskis
2004-05-29 15:25 Patrick Leslie Polzer
2004-05-29 15:36 ` Alexis
2004-05-29 16:03 ` Patrick Leslie Polzer
2004-05-30 1:00 ` Alexis
2004-04-19 5:07 DNAT Problem test
2004-04-19 13:43 ` Joel Newkirk
2004-04-20 4:31 ` test
2004-04-22 10:40 ` test
2004-04-22 11:07 ` Antony Stone
[not found] ` <1589.80.0.0.23.1082637754.squirrel@80.0.0.175>
2004-04-22 12:47 ` Antony Stone
2004-04-22 13:06 ` test
2004-04-22 13:21 ` Antony Stone
2004-04-22 18:18 ` test
2004-04-22 19:13 ` Antony Stone
2004-04-23 12:22 ` test
2003-03-30 14:58 DNAT problem Alexandru Coseru
2003-03-30 15:41 ` Joel Newkirk
2002-11-27 19:28 Geoff Silver
2002-11-19 8:07 HCLFM
2002-11-21 21:53 ` Rahul Jadhav
2002-05-21 20:53 dnat problem support
2002-06-13 17:28 ` 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='001201c42c28$16064480$1202a8c0@admin' \
--to=rob@sterenborg.info \
--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.