# [solved] Failover internet setup not properly routing

## maiku

The machine can ping any IP address in the internal networks 10.1.1.0/24 and 192.168.2.0/2 but anything outside cannot be reached.

/etc/conf.d/net *Quote:*   

> modules=( "iproute2" )
> 
> config_eth0=( "10.1.1.34/24" )
> 
> config_eth1=( "192.168.2.77/24" )

 /etc/init.d/multinet *Quote:*   

> depend() {
> 
>         after net
> 
> }
> ...

 In the kernel config: *Quote:*   

> CONFIG_IP_ADVANCED_ROUTER=y
> 
> CONFIG_IP_MULTIPLE_TABLES=y
> 
> CONFIG_IP_ROUTE_MULTIPATH=y

 /etc/iproute2/rt_tables *Quote:*   

> #
> 
> # reserved values
> 
> #
> ...

  *Quote:*   

> failovertest linux # ping -c2 192.168.2.102
> 
> PING 192.168.2.102 (192.168.2.102) 56(84) bytes of data.
> 
> 64 bytes from 192.168.2.102: icmp_seq=1 ttl=250 time=1.03 ms
> ...

  *Quote:*   

> failovertest linux # ping -c2 10.1.1.101
> 
> PING 10.1.1.101 (10.1.1.101) 56(84) bytes of data.
> 
> 64 bytes from 10.1.1.101: icmp_seq=1 ttl=64 time=92.4 ms
> ...

  *Quote:*   

> failovertest linux # ping -c2 74.125.127.100
> 
> connect: Network is unreachable

 

Also, when I run this command manually I get an error: *Quote:*   

> failovertest linux # ip route add default scope global nexthop via 10.1.1.1 dev eth0 weight 1 nexthop via 192.168.2.1 dev eth2 weight 3
> 
> RTNETLINK answers: No such process

 

Resources:

http://www.gentoo-wiki.info/Dual_internet_connections

----------

## maiku

Ah. I set the interface wrong. This system has eth0 and eth1.

Now the problem I'm having is that when I bring one network down it still tries to reach that network for some reason. This doesn't make it a good 'failover' connection.

----------

## aricart

Just throwing this out there, since I don't know too much about the subject . . .

Perhaps you can set a cronjob, or use one of the many "watch" services to reset the default gateway when one or the other interfaces go down?

Obviously you know how to use ip route commands, so fill in the rest  :Smile: 

----------

## maiku

Actually I'm not so good. Everything I got was from all of my google searches.  But I did find a script from http://blog.taragana.com/index.php/archive/how-to-load-balancing-failover-with-dual-multi-wan-adsl-cable-connections-on-linux/ .  I modified it a little bit so it pings the ISP's gateway instead of an outside IP.  It pretty much does what you said.  The only problem is I may have to run it with hup in /etc/conf.d/local.start. *Quote:*   

> #!/bin/bash
> 
> #Copyright Angsuman Chakraborty, Taragana. Permission is granted for personal, non-commercial use.
> 
> #The script may not be re-distributed in any form without written permission from Angsuman Chakraborty ( angsuman@taragana.com ).
> ...

 It seems to work pretty well so far.  Just not sure how I'm going to start the script at this point.  Wish I was better at writing init scripts.

----------

