Routing emails through non-gateway... how?

Lennart Sorensen lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Fri Jul 17 14:11:12 UTC 2009


On Fri, Jul 17, 2009 at 03:56:48AM -0400, William Park wrote:
> If my default gateway is on eth0, how do I route all email through
> another interface, say eth1 or ppp0 ?
> 
> Any pointer or keywords would be appreciated.

Look up using iptables to mangle the smtp packets so that ip rules can
use an alternate routing table for the mangled packets.

So look up ip rule, ip route table and iptables -t mangle

Example:
# Setup routing table
/sbin/ip route add table 80 default via 10.128.0.252 dev eth0

# Add rule
/sbin/ip rule add from all fwmark 8 table 80

# Add firewall mangling rule
/sbin/iptables -t mangle -A OUTPUT -p tcp --dport 80 -d \! 10.0.0.0/8 -j MARK --set-mark 8

This makes all outbound port 80 traffic not going to the local 10.*
network go through 10.128.0.252 rather than the normal gateway.

-- 
Len Sorensen
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list