Different static routes for green/blue network

We need to define different static routes for green and blue network in order to reach the same target network (over different VPN tunnels). A simple static route doesn’t solve this, because it tries to route all traffic through one single gateway. More details:

GREEN network:, IPFire’s green IP is
BLUE network: 192.168.17/24, IPFires’ blue IP is

In the green network, there is a gateway (IP: which routes to the network connected via VPN tunnel “A”.

In the blue network, there is another gateway (IP: which routes to the same target network as above, but uses a different VPN tunnel “B”.

The IPs of IPFire ( and act as default gateways for all other devices in the green/blue network.

The goal is:

Traffic from all devices on GREEN with target should be routed over
Traffic from all devices on BLUE with target should be routed over

How can I realize this in general?

Hi @baruch234.

Pufff, this is very complicated for me. Maybe, somebody can help better than me.

On the other hand, maybe this can help you (thank searching by Google):

Debian / Ubuntu Linux static routing for two interfaces:

Here is an updated config file named /etc/network/interfaces:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
	### static routing for eth0 that connects to the VLAN ###
        post-up route add -net netmask gw
        pre-down route del -net netmask gw

auto eth1
iface eth1 inet static
        ## default gateway for eth1 and the server ##
        # dns-* options are implemented by the resolvconf package, if installed
        dns-search nixcraft.in

You have to adapt it to your needs. I don´t now this can work in IPFire.

I just hope it helps you :+1:.


:thinking: I think maybe you can try

On hosts in GREEN network,
add static route to subnet via
On hosts in BLUE network,
add static route to subnet via

for example
ip route add via dev eth0

Let us know what the effect is.

Thanks a lot for your hints/references. I tried the following with IPFire:

ip route add dev green0 via

… this is accepted, but after entering

ip route add dev blue0 via

I received

RTNETLINK answers: File exists

so, this way, it is not possible to define two different static routes bound to different adapters. Meanwhile, I found a solution which does not 100% meet my needs, but is working:

[1] set one static route via GUI via dev green0 proto static

[2] set apropriate firewall rules to allow

  • outgoing traffic from GREEN to
  • outgoing traffic from BLUE source-natted over GREEN to

This allows all devices on GREEN & BLUE network to connect to But devices on both source networks will always use (share the bandwidth of) the same VPN tunnel.

For the single device that needs high bandwidth - explicit: should use both VPN tunnels simultaneously - I set static routes on the device itself, which has different network adapters in both networks GREEN & BLUE.

:thinking: Below I show how I understand my hint

Hi @tphz,
thanks for your reply. I understand. This way every device that is connected to both networks (GREEN & BLUE) is able to use both gateways simultaneously. The problem is, that this solution is not very flexible. We have devices, that:

  • connect only to one of both networks or to both networks
  • have single/multiple NICs in the network
  • are very simple and don’t allow static routes to be applied (e.g. power supply components)

So my initial idea was to apply the additional route only to IPFire as it acts as the central gatway. This would have offered the freedom not to reconfigure every device on the two networks individually.

We have one single device that absolutely needs (and is able) to use both gateways simultaneously/load balanced. For this device I realized just the porposal you made. This works fine.

As a conclusion, it seems to be impossible to set something like a conditional route to IPFire…