Gentoo Archives: gentoo-server

From: Xavier Neys <neysx@g.o>
To: gentoo-server@l.g.o
Subject: Re: [gentoo-server] how to route outgoing emails through a specific network card or ip
Date: Thu, 17 May 2007 12:31:38
Message-Id: 464C4A75.7090200@gentoo.org
In Reply to: [gentoo-server] how to route outgoing emails through a specific network card or ip by widyachacra
1 widyachacra wrote:
2 > we have two internet links. one is a leased line other one is an ADSL
3 > broadband line. now i need to route our outgoing emails through the ADSL
4 > broadband line. how can i do that?
5 >
6 > we're using Qmail.
7 >
8 > how to route outgoing emails through a specific network card or IP ADDRESS?
9 >
10 > Please help me.
11
12 I had the same issue when I had to force my mail to use my ADSL connection
13 instead of my cable connection which is my default route because my cable IP
14 was blacklisted.
15
16 I solved it by marking packets to port 25 and then routing them via my adsl route.
17 I used the following script on my router where eth2 connects to my LAN on
18 10.0.0.0.
19 192.168.1.1 is my adsl router on eth0 and eth1 is my cable modem.
20
21 ...
22 # Force mail to be sent via ADSL because @home is blacklisted
23 iptables -v -t mangle -A PREROUTING -i eth2 -p tcp --dport 25 \
24 -j MARK --set-mark 2
25 ...
26
27 ## ROUTING ##
28
29 # Define adsl routing table used by packets MARK'ed with 0x02
30 ip rule add fwmark 2 table adsl
31 ip route add 10.0.0.0/24 dev eth2 table adsl
32 ip route add 127.0.0.0/8 dev lo table adsl
33 ip route add default via 192.168.1.1 dev eth0 table adsl
34
35 # Define cable routing table used by packets MARK'ed with 0x01
36 ip rule add fwmark 1 table cable
37 ip route add 10.0.0.0/24 dev eth2 table cable
38 ip route add 127.0.0.0/8 dev lo table cable
39 ip route add default via 82.73.126.1 dev eth1 table cable
40
41
42 Hope this helps,
43 --
44 / Xavier Neys
45 \_ Gentoo Documentation Project
46 /
47 /\ http://www.gentoo.org/doc/en/

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies

Subject Author
Re: [gentoo-server] how to route outgoing emails through a specific network card or ip Alex Efros <powerman@××××××××××××××××××.com>