• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 542
  • Last Modified:

route based on incoming interface

I have two modem connections to two isp's
I also have two ip's on one interface - eth0 and eth0:1 connected to a local network

What i need to figure out is how to establish routing so that traffic coming into eth0 goes out ppp0 and traffic coming into eth0:1 goes out ppp1 (as well as their returned packets)





                                                                                                       
0
xscousr
Asked:
xscousr
  • 2
  • 2
1 Solution
 
pablouruguayCommented:
Yes.   Set the default gateway for the router to point up PPP0
link, and use iptables SNAT to set all packets to have source address ppp1
0
 
pablouruguayCommented:
you have a solution for brabard i recommend to read it

http://www.experts-exchange.com/Networking/Linux_Networking/Q_21064680.html
0
 
xscousrAuthor Commented:
squid won't solve the issue.

Not only do i have http traffic coming in i also have two sendmail servers running, each masqing and using it's isp's mailserver as a smart host, one on each eth. With this each incoming needs to go out vi it's assigned ppp connection so that it will be coming from within the isp's block and be accepted by their mail server.

so
                25
 ------->| eth0    | --------->ppp0 ---------> Internet
              | 80      |
              |           |
              |  26     |
 ------->| eth0:1 | --------->ppp1 ---------> Internet
                 8080  
0
 
de2ZotjesCommented:
You need "advanced routing":
http://www.lartc.org/howto/lartc.rpdb.html

You will have to use iptables to set a mark on the packets based on the incomfing interface.

Then you create 2 extra routing tables (one for each mark)

Last you setup the main routng tables to jump to the proper table based on the mark set by iptables.

Rough guide to the commands:
iptables -t mangle -A PREROUTING -i eth0 -j MARK --set-mark net0
(same for eth1, you can refine by not setting the mark for packets destined to the local nets (-d ! lnet)

ip route add default via ip-ppp0 dev ppp0 table side0
ip route add default via ip-ppp1 dev ppp1 table side1

ip rule add fwmark net0 table side0
ip rule add fwmark net1 table side1

I did not test this solution, but it looks sane and should work.
0
 
xscousrAuthor Commented:
thanks de2Zotjes
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now