# Multiple gateways, one NIC?

## The_Great_Sephiroth

I have a client with two separate Internet connections. I have DHCP setup to offer two gateways, but how do I do this on Linux systems? One NIC, two gateways. I assume one will be default and the other not default, but how do I do this? I have one Debian system and two Gentoo systems that need this setup.

----------

## szatox

What is the purpose of those 2 connections (And 2 gateways) on a single NIC?

It is possible to set both as default, but it would result in changing the active connection every few seconds and the resulting link would be very unstable.

However, if you add metric, you can have a failover. You could also try some sort of IP based load balancing, configuring routes to different zones/IP pools via separate gateways.

Also, how did you set the DHCP? Don't they compete to get the client?

----------

## gordonb3

Use option 121 (classless static routes) to set both static and default routes. Option 3 (default route) is ignored by linux dhcp client. Problem is that option 121 does not allow setting a metric value to prioritize gateways, but your dhcp client may in fact add this based on the order in which these are given. The only way to know is to try.

To set up some kind of load balance you can divide traffic between the two gateways by using a netmask of 128 (i.e 0.0.0.0/128 and 128.0.0.0/128) and add the redundancy in the gateways themselves.

----------

## UberLord

This kind of decision is best made at a router.

Take a 3 port router for example (such as the EdgeRouter LITE which I use at home)

  *  Port 1 - LAN

  *  Port 2 - ISP1

  *  Port 3 - ISP2

Configre DHCP to set the default route on clients to an IP on the LAN interface.

Then which ISP is chosen by the router and the client's blissfully don't care.

----------

