All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pascal Hambourg <pascal.mail@plouf.fr.eu.org>
To: netfilter@lists.netfilter.org
Subject: Re: Newbie question about NAT and forwarding
Date: Thu, 07 Sep 2006 01:52:34 +0200	[thread overview]
Message-ID: <44FF5F42.4050605@plouf.fr.eu.org> (raw)
In-Reply-To: <ednhr3$pjc$1@sea.gmane.org>

Hello,

Danny Rathjens a écrit :
> felix@crowfix.com wrote:
[...]
>> What iptables commands would I used to route non-SMTP packets between,
>> say, eth0 (local net, static real addresses) and eth1 (broadband DHCP)?
> 
> Just follow normal procedure for NAT of traffc using and us broadband as 
> default route:
> route add default gw $broadband_gateway

And for NAT :
iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE

MASQUERADE is because eth1's address is dynamic. Else SNAT could be used 
instead.

> 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
                                            ^^^^^^^^
"dev ppp0" would be better IMHO.

If source address validation is enabled, don't forget to disable it on 
the non-default interface :

sysctl -w net/ipv4/conf/ppp0/rp_filter=0

If net/ipv4/conf/default/rp_filter=1, you'll have to do this every time 
after ppp0 is created. If net/ipv4/conf/default/rp_filter=0 before ppp0 
is created, net/ipv4/conf/ppp0/rp_filter will be automatically set to 0.

One remark : if there is SMTP traffic from a local host with a private 
address, this  traffic will be routed via ppp0 but must be NATed with 
any public address routed on the dialup link. If it is not NATed, it 
will go out with its original private source address and that's not good.

Note to Felix : you don't need to define and use a table name in 
/etc/iproute2/rt_tables. It just makes routes and routing rules more 
readable. You can use a table number in the range 1-252 instead.


  parent reply	other threads:[~2006-09-06 23:52 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
2006-09-06 22:59   ` felix
2006-09-06 23:52   ` Pascal Hambourg [this message]
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=44FF5F42.4050605@plouf.fr.eu.org \
    --to=pascal.mail@plouf.fr.eu.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 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.