Results 1 to 2 of 2

Thread: Trying to route via two default gateways

  1. #1

    Trying to route via two default gateways

    Hello all,

    I have a Linux box (running slackware with 2.4.26 kernel - iptables v1.2.10) with one LAN interface which is connected to two DSL routers (using two differnet ISPs).

    Setup:
    Linux box ethernet interface on 10.0.1.1 (255.255.0.0)
    RouterA on 10.0.1.254 (255.255.0.0), uses one ISP
    RouterB on 10.0.1.252 (255.255.0.0), uses another ISP

    Both of the DSL routers port forward 80/tcp and 22/tcp to 10.0.1.1.

    10.0.1.1 normally has its default gateway set to RouterA (10.0.1.254), but when testing is required via RouterB (10.0.1.252) I need to manually change the routing table to use it as the default gateway - what I would idealy like is for the box itself to re-route traffic via the correct gateway/router itself, depending on where the request originated from.

    The idea being if I then ssh to RouterA the data travels via RouterA (so the first ISP), but if I were to then ssh to RouterB the data travels via the second ISP.

    Hopefully I've made some sense : ) I'm trying to think of the bests ways to accomplish this. I know iptables has some fancy options for re-writing data on-the-fly (particularly noticed the --gw flag and SNAT/DNAT), or thought that adding another NIC and have eth0 data use a default gateway of RouterA and eth1 use a default gateway of RouterB, but not sure how I would go about trying to set that up either :/

    Does anyone have any suggestions or examples on how I could best achieve this?

    All the best,
    BP

  2. #2

    Trying to route via two default gateways

    Hi

    You are right that with DNAT/SNAT it is quite possible to route the data from a particular IP to a particular Gateway.

    Also it can be done through IP Route utility freely distributed with linux.
    what you do is create tables of gateway. basically routing tables and specify there that if source is this ip or destined traffic is of particular type it should follow a particular table.

    hope i am not too confusing.
    try http://iproute.org

    regards,

Similar Threads

  1. Need help on two default gateways
    By JosephV in forum Windows - General Topics
    Replies: 8
    Last Post: 05-14-2008, 12:44 PM
  2. Using two Lan card , how to route
    By ehdlim in forum Linux - General Topics
    Replies: 1
    Last Post: 01-22-2007, 03:56 PM
  3. Trace Route
    By GDR in forum Windows - General Topics
    Replies: 1
    Last Post: 01-14-2007, 05:26 AM
  4. redhat default passwords for the default inbuilt users
    By kaushalsp in forum Linux - Software, Applications & Programming
    Replies: 1
    Last Post: 12-31-2004, 04:49 AM
  5. static route
    By aliko in forum Linux - Hardware, Networking & Security
    Replies: 2
    Last Post: 05-30-2002, 01:16 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •