1

I have a server with 2 nics (interfaces) running ubuntu 14.10

I need to connect each nic to a different router (each being a gateway to different internet connections from different ISPs.

I also need the server to respond to requests from the same nic the request arrived from Requests from the server (update system etc) can go through either nic (load balance?)

So far whatever way i try it always comes back as only one nic works as any request from the other nic (aapparently) gets the response sent on the first and so the requester doesn't get the answer

Everytime i restart seems a different nic works and that doesn't work for me

Here's what i want

--[ISP1]-----------------|   |        |
     |-----------------{NIC1]|        |
                             | server |
     |-----------------[NIC2]|        |
--[ISP2]-----------------|   |        |

And here's my routing settings

route -n
Destino         Roteador        MáscaraGen.    Opções Métrica Ref   Uso Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    1      0        0 em1
0.0.0.0         192.168.0.1     0.0.0.0         UG    2      0        0 em2
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 em2
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 em1

netstat -rn
Destino         Roteador        MáscaraGen.    Opções   MSS Janela  irtt Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 em1
0.0.0.0         192.168.0.1     0.0.0.0         UG        0 0          0 em2
192.168.0.0     0.0.0.0         255.255.255.0   U         0 0          0 em2
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 em1

after following @PedroPerez instructions i get:

route -n
Destino         Roteador        MáscaraGen.    Opções Métrica Ref   Uso Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 em1
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 em2
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 em1

netstat -rn
Destino         Roteador        MáscaraGen.    Opções   MSS Janela  irtt Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 em1
192.168.0.0     0.0.0.0         255.255.255.0   U         0 0          0 em2
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 em1

ip route show
default via 192.168.1.1 dev em1
192.168.0.0/24 dev em2  proto kernel  scope link  src 192.168.0.123
192.168.1.0/24 dev em1  proto kernel  scope link  src 192.168.1.123

ip route show table NOS
default via 192.168.1.1 dev em1
192.168.1.0/24 dev em1  scope link  src 192.168.1.123

ip route show table Vodafone
default via 192.168.0.1 dev em2
192.168.0.0/24 dev em2  scope link  src 192.168.0.123

Still only one address responds from outside

537mfb
  • 167

1 Answers1

1

The answer your after is routing tables. At the moment you have two interfaces sharing the same routing table with two default routes (with different metric), but what you want is a completely separated second routing table for your second interface.

Either that or doing source NAT to all the traffic coming in from outside, which is a very bad idea anyway.

Routing tables in Linux

Check this tutorial, especially the part on how to setup split access which is what you're after.

Pedro Perez
  • 6,844