From: Stephen Satchell <list@satchell.net>
To: netfilter@lists.netfilter.org
Subject: DNAT problems using a single interface
Date: Wed, 12 Oct 2005 15:02:42 -0700 [thread overview]
Message-ID: <434D8802.40702@satchell.net> (raw)
I have a knotty problem. I have 31 servers running older versions of
QMail. There is proprietary software on those 31 servers that prevents
me from updating to the latest QMail patches, and even if I could the
spam control in qmail is, um, sucky. So I have built a gateway mail
server, using PostFix, that will "front-end" the 31 QMail servers.
(There is also a colostomy bag, also running Postfix, to catch and
retain spam spewing from the servers from things like raped PHP/Perl
scripts, but that's beside the point.)
The "right" way to do this is to change all the DNS zone files (some
6,000) of them to point MX records properly, and convince over 100,000
people to update their mail program configurations...assuming they
aren't running something like Eudora 5.2, which doesn't allow split
servers with different authentication.
IPTABLES TO THE RESCUE! In each of the 31 servers, put a set of
firewall rules to DNAT up to 200 IP addresses to the gateway server, let
the TCP communications on port 25 (and other well-known mail ports)
happen, and put a back-channel using another port for mail that needs to
go to that server for storage, future pick-up, forwarding, list
explosion, and autoresponder processing.
I can't get it to work.
-------------Netfilter rules-----------------
# forward mail requests to x; use absolute IP address.
mx11=10.1.2.99
SERVER_IPS="10.1.1.11 10.1.1.12 10.1.1.13 10.1.1.14 10.1.1.15"
for p in 25:26 465 587; do
for ip in $SERVER_IPS ; do
/sbin/iptables -t nat -A PREROUTING -i eth0 -d $ip \
-p tcp --dport $p -j DNAT --to-destination $mx11
done
done
/sbin/iptables -t filter -A FORWARD -i eth0 -o eth0 \
-p tcp -d $mx11 --dport $p \
-m state --state NEW -j ACCEPT
/sbin/iptables -t filter -A FORWARD -i eth0 -o eth0 \
-p tcp -d $mx11 --dport $p \
-m state --state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables -t filter -A FORWARD -i eth0 -o eth0 \
-p tcp -s $mx11 --sport $p \
-m state --state ESTABLISHED,RELATED -j ACCEPT
echo 1 >/proc/sys/net/ipv4/ip_forward
-------------End rules--------------------
Tracing through three sets of TCPDUMP outputs, here is what I saw:
Client send TCP packets SRC=192.168.2.10 (eth0) DST=10.1.1.11 (eth0)
QMbox sends TCP packets SRC=192.168.2.10 (eth0) DST=10.1.2.99 (eth0)
Gateway receives packet
Gateway replies SRC=10.1.2.99 (eth0) DST=192.168.2.10 (eth0) !!!
Client, totally confused by the whole thing, discards the packet it
doesn't know, because the source address isn't in the conntrack table
and that's that -- TCP is broken.
The "Host Forwarding" described in [Ziegler, p 277-8] implies that DNAT
would mangle the source address so that replies would come back to the
same server, instead of the circle I saw. This is astonishing based on
the netfilter documentation I found; I would expect the stuff that works
with two or more interfaces to work with one interface. Or is that a
stretch?
What am I missing here?
More importantly, how can I get the functionality I need without using
the link capability of xinetd (the QMail management software screws up
the control files on a distressingly regular basis) and without writing
a custom link program?
For grins and giggles, I tried to include SNAT, but because there are so
many input addresses I failed to come up with a suitable set of rules.
I know that I really should just throw out the proprietary product that
uses QMail, but to solve my mail problems within 15 days I don't think
that's an option. I need a suitable bandaid now, that doesn't call for
a huge hardware investment and that will be proof against proprietary
software defeating.
Open source. It works when you have it...
Stephen Satchell
Pattern-bald from tearing hair out.
next reply other threads:[~2005-10-12 22:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-12 22:02 Stephen Satchell [this message]
2005-10-13 0:19 ` DNAT problems using a single interface George Alexandru Dragoi
2005-10-13 21:46 ` Henrik Nordstrom
2005-10-13 21:42 ` Henrik Nordstrom
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=434D8802.40702@satchell.net \
--to=list@satchell.net \
--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.