From: "Dimitri Yioulos" <dyioulos@firstbhph.com>
To: netfilter@lists.netfilter.org
Subject: Re: NAT question
Date: Fri, 11 Mar 2005 10:41:11 -0500 [thread overview]
Message-ID: <200503111541.j2BFfAK8006512@mail1.firstbhph.com> (raw)
In-Reply-To: <1110553981.4767.28.camel@hubcap.ljm.dom>
> >> Hello, all.
> >>
> >> I've recently set up iptables-1.2.8-12.3 on a CentOS 3.4 (RHEL AS 3)
box.
> >> Among other things, I've created a DMZ where my Web and mail servers
> >>live.
> >> My problem is that my Web and mail servers identify themselves with the
> >> NAT
> >> ip address that I've assigned Here's my NAT rule:
> >>
> >> IPTABLES -t nat -A POSTROUTING -o $INET_IFACE -j SNAT --to-source
> >> $INET_IP
> >>
> >> How can I get these two servers to identify themselves by their own ip
> >> addresses and still provide NAT for my users?
>
> >specify the source address so that only packets from the inside network
> >match the SNAT rule:
>
> > iptables -t nat -A POSTROUTING -o $INET_IFACE -s $INSIDE_NET \
> > -j SNAT --to-source $INET_IP
>
>
> Thanks to all for your replies!
>
> I was hopeful about applying the above rule. Internet connectivity is
fine;
> inbound mail is fine; outbound mail seems not to make it (if the list
> receives this, it's because I rolled back to the original rule). Does
that
> make any sense?
>
> Dimitri
-are your web and mail servers NAT-ed as well? it was unclear from your
-original post, an i assumed that you were using Internet-routed IP space
-in your DMZ. if this is not the case--you need to put your rules in the
-proper order.
-
-if you have a static (one-to-one) NAT for a DMZ machine, and also want
-to perform a hide NAT (many-to-one) NAT for your internal net's outbound
-traffic--you'd have something like:
-
- # inbound one-to-one NAT for web server
- iptables -t nat -A PREROUTING -i $INET_IFACE -d $WEB_SRV_PUB_IP \
- -j DNAT --to-destination $WEB_SRV_PRIV_IP
-
- # outbound one-to-one NAT for web server
- iptables -t nat -A POSTROUTING -o $INET_IFACE -s $WEB_SRV_PRIV_IP \
- -j SNAT --to-source $WEB_SRV_PUB_IP
-
- # outbound many-to-one NAT for inside net
- iptables -t nat -A POSTROUTING -o $INET_IFACE -s $INSIDE_NET \
- -j SNAT --to-source $INET_IP
-order matters--place the one-to-one SNAT rules before any many-to-one
-SNAT rules.
-in order for packets destined for $WEB_SRV_PUB_IP to make it to your
-firewall's $INET_IFACE, it either needs to be routed that way by your
-upstream Internet router, or you need to add it as an alias:
- ip addr add $WEB_SRV_PUB_IP dev $INET_IFACE
-HTH... any sorry for misleading before.
Sorry for any confusion I may be causing. Here's a little more info.:
I've aliased my Web and mail server public addresses to eth0:0 and eth0:1
(eth0 being the external interface). I think I've read that this isn't the
optimal set-up, but it does work. That shouldn't matter, should it?
The key here may be in omitting a NAT postrouting rule (sorry if the
terminology is incorrect). Here's what I have:
IPTABLES -t nat -A PREROUTING -p TCP -i $INET_IFACE -d $HTTP_IP --dport 80 \
-j DNAT --to-destination $DMZ_HTTP_IP
IPTABLES -t nat -A PREROUTING -p TCP -i $INET_IFACE -d $SMTP_IP --dport 25 \
-j DNAT --to-destination $DMZ_SMTP_IP
IPTABLES -t nat -A PREROUTING -p UDP -i $INET_IFACE -d $SMTP_IP --dport 25 \
-j DNAT --to-destination $DMZ_SMTP_IP
IPTABLES -t nat -A PREROUTING -p TCP -i $INET_IFACE -d $SMTP_IP --dport \
110 -j DNAT --to-destination $DMZ_SMTP_IP
IPTABLES -t nat -A PREROUTING -p UDP -i $INET_IFACE -d $SMTP_IP --dport \
110 -j DNAT --to-destination $DMZ_SMTP_IP
IPTABLES -t nat -A POSTROUTING -o $INET_IFACE -j SNAT --to-source $INET_IP
in that order. I will change the last rule to include -s $INSIDE_NET. I
also notice that I don't have the outbound one-to-one NAT for web or mail
servers. So, if I add:
IPTABLES -t nat -A POSTROUTING -o $INET_IFACE -s $WEB_SRV_PRIV_IP \
-j SNAT --to-source $WEB_SRV_PUB_IP
and
IPTABLES -t nat -A POSTROUTING -o $INET_IFACE -s $MAIL_SRV_PRIV_IP \
-j SNAT --to-source $MAIL_SRV_PUB_IP
just after the outbound many-to-one NAT for inside net as above, will I be
good?
Thanks so much for your time.
next prev parent reply other threads:[~2005-03-11 15:41 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-11 12:43 NAT question Dimitri Yioulos
2005-03-11 12:50 ` Jason Opperisano
2005-03-11 13:56 ` Dimitri Yioulos
2005-03-11 15:13 ` Jason Opperisano
2005-03-11 15:41 ` Dimitri Yioulos [this message]
2005-03-11 15:46 ` Jason Opperisano
2005-03-11 13:06 ` John A. Sullivan III
-- strict thread matches above, loose matches on Subject: below --
2012-01-25 16:16 Stephen Clark
2012-01-25 17:30 ` Jan Engelhardt
2005-03-11 15:15 Justin Piszcz
2004-06-30 13:28 Kiran Kumar Immidi
2004-06-30 14:02 ` Vijaya Chandra Vupputuri
2004-06-30 13:25 Kiran Kumar Immidi
2004-06-30 14:21 ` Henrik Nordstrom
2004-06-30 11:36 Kiran Kumar Immidi
2004-06-30 11:55 ` Henrik Nordstrom
2004-06-30 12:26 ` Vijaya Chandra Vupputuri
2003-07-19 15:09 Ray Blair
2003-04-10 10:30 Philippe Dhont (Sea-ro)
2003-04-09 9:51 Philippe Dhont (Sea-ro)
2003-04-09 10:27 ` Cedric Blancher
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=200503111541.j2BFfAK8006512@mail1.firstbhph.com \
--to=dyioulos@firstbhph.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 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.