Linux Netfilter discussions
 help / color / mirror / Atom feed
From: Taylor Grant <gtaylor@riverviewtech.net>
To: Greg Cope <gregcope@gmail.com>
Cc: netfilter@lists.netfilter.org
Subject: Re: How to make a mutli-homed host use one IP for a NAT'ed host
Date: Thu, 21 Apr 2005 02:17:55 -0500	[thread overview]
Message-ID: <426753A3.7030800@riverviewtech.net> (raw)
In-Reply-To: <c0e9781f0504202352240208e4@mail.gmail.com>

Greg, if I understand you correctly you have a system that is multi homed with one of it's IP addresses being port forwarded to a DMZ server?  What happens is that your DMZ server replies back to your router / firewall which then in turn send the traffic out it's default route with a source IP of something other than what you want your SMTP traffic to use?  If this is the case you need to so a few tings to get your traffic to go out the interface that you want with the IP that you want.

For starters you will need to use IPTables to mark the traffic that is coming in to your router / firewall from the DMZ mail server.
Second you will need to create a new routeing table for this traffic via something like the following:

iptables -t nat -A OUTPUT -s $DMZ_Server_IP -p tcp --sport 25 -j MARK --set-mark $SMTP_Mark
ip route add table $IPRoute2_SMTP_Table dev $DEV_of_SMTP_network_interface_or_alias src $IP_of_DEV_of_SMTP_network_interface_or_alias
ip route add table $IPRoute2_SMTP_Table default via $Default_INet_Gateway
ip rule add fwmark $SMTP_Mark table $IPRoute2_SMTP_Table

Where:
$DMZ_Server_IP is the internal LAN ip of your SMTP server in the DMZ.
$SMTP_Mark is the value you want to use to mark the packets that need to use the alternant route.
$IPRoute2_SMTP_Table is the name as it appears in /etc/iproute2/rt_tables or the number of the table that you want to use.
$DEV_of_SMTP_network_interface_or_alias is the device name or alias of your network interface that you want all SMTP traffic to use.
$IP_of_DEV_of_SMTP_network_interface_or_alias is the IP address of the device name or alias of your network interface that you want all SMTP traffic to use.
$Default_INet_Gateway is the IP address of your internet gateway.

This should cause any SMPT traffic (source port 25 from the SMTP server) to go out a different interface / alias and thus use a different source IP when the traffic is sent out to the world.  If you have any questions or need more help let me know and I'll see what I can do.


Greg Cope wrote:
> Hi All,
> 
> I have a mutli-homed router/firewall.
> 
> One IP address is the default router gateway address
> 
> Three other (virtual) IP's are for applications (one of which is SMTP).
> 
> My mailserver is on a NAT'ed DMZ.
> 
> However when it sends mail the router uses the default gateway address
> as opposed to the SMTP IP address.
> 
> This upsets reverse DNS lookups as it now appears to come from the
> router as opposed to the mail IP (that has the correct reverse IP
> address lookup).
> 
> Any ideas?
> 
> Greg


  reply	other threads:[~2005-04-21  7:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-21  6:52 How to make a mutli-homed host use one IP for a NAT'ed host Greg Cope
2005-04-21  7:17 ` Taylor Grant [this message]
     [not found]   ` <c0e9781f05042102544437b319@mail.gmail.com>
2005-04-21 14:18     ` Greg Cope
2005-04-21 14:53       ` Taylor Grant
2005-04-21 15:12         ` Greg Cope
2005-04-21 18:13           ` Taylor, Grant
2005-04-21 19:07             ` Greg Cope
2005-04-21 19:21               ` 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=426753A3.7030800@riverviewtech.net \
    --to=gtaylor@riverviewtech.net \
    --cc=gregcope@gmail.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