Linux Netfilter discussions
 help / color / mirror / Atom feed
From: Danny Rathjens <gmane@rathjens.org>
To: netfilter@lists.netfilter.org
Subject: Re: Newbie question about NAT and forwarding
Date: Wed, 06 Sep 2006 18:24:34 -0400	[thread overview]
Message-ID: <ednhr3$pjc$1@sea.gmane.org> (raw)
In-Reply-To: <20060906205232.GA23980@crowfix.com>

felix@crowfix.com wrote:
> I have a small network with a gateway machine which has two interfaces
> to the internet.  One is (yes!) ppp0, a dialup account, the other is a
> broadband connection.  Some of the network machines behind the gateway
> have real static addresses, some have 192.168.* or similar local net
> addresses.  The dialup account has static real addresses for those
> local net machines which need internet access, but the broadband
> connection gets its address dynamically from DHCP.  As much as it
> would be nice to ditch the dialup account altogether, that is not
> practical at the moment.
> 
> I would like all the local net machines to not be aware of there being
> multiple connections, to route all SMTP traffic, both in and out, thru
> the dialup account, and to route all other traffic thru the broadband
> connection.
> 
> I think I know how to route based on the protocol.  For SMTP, that is
> made easier by not needing to NAT anything.  But I need NAT for all
> other traffic using the broadband connection, right? since it has only
> a single synamically assigned DHCP address.  This is where I get
> confused.
> 
> What iptables commands would I used to route non-SMTP packets between,
> say, eth0 (local net, static real addresses) and eth1 (broadband DHCP)?
 
I just did something similar.
Just follow normal procedure for NAT of traffc using and us broadband as default route:
route add default gw $broadband_gateway

Then you just need to route the smtp traffic through your dial-up.

iptables -A PREROUTING -i eth0 -t mangle -p tcp --dport 25 -j MARK --set-mark 2
echo 202 mail >> /etc/iproute2/rt_tables
ip rule add fwmark 2 table mail
ip route add default via $dialup_gateway dev eth0 table mail
ip route flush cache



  reply	other threads:[~2006-09-06 22:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-06 20:52 Newbie question about NAT and forwarding felix
2006-09-06 22:24 ` Danny Rathjens [this message]
2006-09-06 22:59   ` felix
2006-09-06 23:52   ` Pascal Hambourg
2006-09-07  0:24     ` felix
2006-09-07  1:37       ` Pascal Hambourg
2006-09-07  2:43         ` felix
2006-09-07  9:20           ` Pascal Hambourg
2006-09-07 14:12             ` felix
2006-09-07 16:27     ` Danny Rathjens

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='ednhr3$pjc$1@sea.gmane.org' \
    --to=gmane@rathjens.org \
    --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