Link to home
Start Free TrialLog in
Avatar of bdhtechnology
bdhtechnology

asked on

setting up multiple gateways on a single subnet

I have a Debian based Linux router with 2 NICS using iptables that is working fine.  We recently installed a second Internet connection along with a separate consumer router for that connection.  Everything works fine as it is and the default gateway can be changed on a computer to use the other network connection if needed.

My question is if I can configure a virtual interface on the linux router so that I can access the router from the other network if need be.  For everything else it would stay with the default gateway currently in use.

The current /etc/network/interfaces file looks like this:
auto eth1
iface eth1 inet static
        address 10.233.0.1
        gateway 10.233.0.1
        netmask 255.255.255.0
        network 10.233.0.0
        broadcast 10.233.0.255

auto eth0
iface eth0 inet static
        address x.x.x.153
        gateway x.x.x.158
        netmask 255.255.255.248
        network x.x.x.152
        broadcast x.x.x.159

Open in new window


I am thinking of adding the following (10.233.0.254 is the other internet connection router):
auto eth1:0
iface eth1:0 inet static
        address 10.233.0.253
        gateway 10.233.0.254
        netmask 255.255.255.0

Open in new window

I am guessing that I will need to add some route information, and/or something to the iptables config to get it to work properly.  The current routing table is:
0.0.0.0         x.x.x.158       0.0.0.0         UG        0 0          0 eth0
10.233.0.0      0.0.0.0         255.255.255.0   U         0 0          0 eth1
x.x.x.152       0.0.0.0         255.255.255.248 U         0 0          0 eth0

Open in new window

I am not on site and therefore want to double check the configuration before I activate it and lose access to the network (if it is incorrect).

Any help would be appreciated!
Avatar of giltjr
giltjr
Flag of United States of America image

That will allow you to have a second IP address.  However a host can only have a single default gateway.

Right now your default gateway is x.x.x.158.
A reason why you aren't running pfsense?
http://www.tomschaefer.org/web/wordpress/?p=538
Avatar of eeRoot
eeRoot

Does the new router have a management interface that can be placed on an existing VLAN so that it is accessible, regardless of how internet traffic is being routed?
ASKER CERTIFIED SOLUTION
Avatar of bbao
bbao
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The key word is 'default'.

You can only use one default at a time, even if you an configure more.  To use each gateway simultaneously you need to use a load-balancing protocol between the routers, or use specific static routes at the clients.
Avatar of bdhtechnology

ASKER

I don't want to setup a second default gateway, it would more be just so that the server could respond to requests coming from the other network connection.  That way if the primary connection is down I can still login remotely and change the default gateway over.

The other router is just a consumer based D-link that we were using only as a wireless access point previously.  It doesn't have any VLAN options.  I was thinking about creating a new subnet for this other connection.  That would obviously be easier to route connections coming from the new subnet back to it, instead of through the default gateway.  I guess I was hoping to achieve a simple solution so that I could change the default gateway of all the computers that need to use the new Internet connection and be done when/if problems arise.

I suppose that instead of using the Dlink I could add a 3rd NIC to the server and put the new Internet connection into that.  That would obviously let the server respond so I could SSH to it and change the default gateway if I needed to.
The reason why I am not running pfsense is that I developed the script I am using from an old iptables web interface called fbuilder: http://www.innertek.com/Software/fbplus.shtml  It worked well enough in it's day, but was no longer updated and I found it easier to maintain the script on my own.  That and I am not familiar at all with FreeBSD :)
I am not familiar with RIP at all, though I am sure Debian/Linux would support it.  That option sounds like it may be a more complicated solution, however.
You would need to use a dynamic routing protocol, like RIP as suggested, to do this.  It's not complicated at all.
Based on your routing table "x.x.x.158" is your current default route.  This I am assuming is your current Internet connection.

Is the device x.x.x.158 at the same location as your Linux router?

What type of device is it?

Do you own it, or is it vendor supplied?

As some have implied, you need to be able to detect that the path from your Linux router to the Internet is down in order to take a different default route (a.k.a gateway).  This could be done using a dynamic routing protocol (RIP, RIPV2, OSPF) or using a simple script on the Linux router.

You could point the address of the 1st hop after x.x.x.158 every so often and if the pings stop working, change the default route to whatever you want.  Once the pings start to work you can change it back.
The reason I ask about pfsense is because load balancing/failover is more than just adding a second gateway.
I will check out RIP to see if I can adapt it to the current setup for now.  If not I will just add a 3rd NIC to the server so that it can accessed from the other Internet connection.