0

I have an Ubuntu Server 16.04 LTS running into a DELL R210 II server with 2 NICs. I want to set each NIC with a different network/gateway in order to provide redundant internet connection to the server. Follow my /etc/network/interfaces file:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto em1
iface em1 inet static
        address 192.168.0.10
        netmask 255.255.255.0
        gateway 192.168.0.1
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameserver 8.8.8.8 8.8.4.4

# The secundary network interface
auto em2
iface em2 inet static
        address 192.168.25.2
        netmask 255.255.255.0
        post-up ip route add 192.168.25.0/24 dev em2 src 192.168.25.2 table rt2
        post-up ip route add default via 192.168.25.1 dev em2 table rt2
        post-up ip rule add from 192.168.25.2/32 table rt2
        post-up ip rule add to 192.168.25.2/32 table rt2       

And this is my /etc/iproute2/rt_tables file:

#
# reserved values
#
255     local
254     main
253     default
0       unspec
#
# local
#
#1      inr.ruhep

1 rt2

I did this setup according to this reference: https://www.thomas-krenn.com/en/wiki/Two_Default_Gateways_on_One_System

If 192.168.0.1 is down I can ssh connect to the server through the gateway 192.168.25.1. If 192.168.25.1 is down I'm able to ssh connect the server by the gateway 192.168.0.1 as well.

My problem is that the server can't access the internet if the gateway 192.168.0.1 is down:

myuser@myserver:~$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
From 192.168.0.10 icmp_seq=1 Destination Host Unreachable
From 192.168.0.10 icmp_seq=2 Destination Host Unreachable
From 192.168.0.10 icmp_seq=3 Destination Host Unreachable
^C
--- 8.8.8.8 ping statistics ---
5 packets transmitted, 0 received, +3 errors, 100% packet loss, time 4014ms
pipe 3
myuser@myserver:~$ ping -I em2 8.8.8.8
PING 8.8.8.8 (8.8.8.8) from 192.168.25.2 em2: 56(84) bytes of data.
From 192.168.25.2 icmp_seq=1 Destination Host Unreachable
From 192.168.25.2 icmp_seq=2 Destination Host Unreachable
From 192.168.25.2 icmp_seq=3 Destination Host Unreachable
^C
myuser@myserver:~$ ping 192.168.25.1
PING 192.168.25.1 (192.168.25.1) 56(84) bytes of data.
64 bytes from 192.168.25.1: icmp_seq=1 ttl=64 time=2.44 ms
64 bytes from 192.168.25.1: icmp_seq=2 ttl=64 time=0.220 ms
64 bytes from 192.168.25.1: icmp_seq=3 ttl=64 time=0.195 ms
64 bytes from 192.168.25.1: icmp_seq=4 ttl=64 time=0.209 ms
^C
--- 192.168.25.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 2999ms
rtt min/avg/max/mdev = 0.195/0.768/2.448/0.969 ms

The output of the ifconfig is:

em1       Link encap:Ethernet  HWaddr XX:XX:XX:XX:XX:XX  
          inet addr:192.168.0.10  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::1a03:73ff:feeb:5370/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:64671928 errors:0 dropped:1 overruns:0 frame:0
          TX packets:9052331 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:96568794836 (96.5 GB)  TX bytes:909947279 (909.9 MB)

em2       Link encap:Ethernet  HWaddr XX:XX:XX:XX:XX:XX  
          inet addr:192.168.25.2  Bcast:192.168.25.255  Mask:255.255.255.0
          inet6 addr: fe80::1a03:73ff:feeb:5371/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8177 errors:0 dropped:2 overruns:0 frame:0
          TX packets:265 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2759155 (2.7 MB)  TX bytes:38231 (38.2 KB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:285531 errors:0 dropped:0 overruns:0 frame:0
          TX packets:285531 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:44372922 (44.3 MB)  TX bytes:44372922 (44.3 MB)

These are the results of the ip routes/rules:

myuser@myserver:~$ ip rule show

0:  from all lookup local 
32764:  from all to 192.168.25.2 lookup rt2 
32765:  from 192.168.25.2 lookup rt2 
32766:  from all lookup main 
32767:  from all lookup default 
myuser@myserver:~$ ip route show
default via 192.168.0.1 dev em1 onlink 
169.254.0.0/16 dev em2  scope link  metric 1000 
192.168.0.0/24 dev em1  proto kernel  scope link  src 192.168.0.10 
192.168.25.0/24 dev em2  proto kernel  scope link  src 192.168.25.2 

Any help is appreciated!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.