LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-11-2016, 08:20 PM   #16
jnihil
Member
 
Registered: Dec 2012
Location: inside the matrix
Distribution: Debian, Xubuntu, Gentoo, Antergos
Posts: 90

Rep: Reputation: 27

I'd responded to you thinking you were using a couple of dial-up modems. Editing my post.

Yes, if you are connected to a DSL router via Ethernet, then the link state would be the same.
It might be useful if you explain to us exactly what your setup is, rather than us guessing what you are using.

You had initially written:
Quote:
I have two network adapters connecting to different isp's.
and now you are telling us you are using a DSL router?
Quote:
...ethernet cable that leads to the adsl router

Last edited by jnihil; 07-11-2016 at 08:27 PM.
 
Old 07-11-2016, 09:31 PM   #17
Ulysses_
Senior Member
 
Registered: Jul 2009
Posts: 1,303

Original Poster
Rep: Reputation: 57
No, I am using 2 adsl routers, one from each isp. Would rather not mess with these routers, better to mess with the PC's routing functionality.
 
Old 07-11-2016, 09:54 PM   #18
jnihil
Member
 
Registered: Dec 2012
Location: inside the matrix
Distribution: Debian, Xubuntu, Gentoo, Antergos
Posts: 90

Rep: Reputation: 27
Right.
So write yourself a script which runs in a loop, testing connectivity of remote resources (such as 8.8.8.8), and modifies the default route depending on the connectivity.
That shouldn't be so hard. The information you require is already in this thread.
 
Old 07-12-2016, 04:08 AM   #19
Ulysses_
Senior Member
 
Registered: Jul 2009
Posts: 1,303

Original Poster
Rep: Reputation: 57
That gc_timeout setting above seems to do just what I want automatically according to the docs. But what should the routing table look like for this to work?
 
Old 07-12-2016, 06:05 PM   #20
Ulysses_
Senior Member
 
Registered: Jul 2009
Posts: 1,303

Original Poster
Rep: Reputation: 57
Made a script in the end. The way to switch the default route is like this:

To switch to eth1:
ip route change default via 192.168.1.1 dev eth1

To switch back to eth0:
ip route change default via 192.168.0.1 dev eth0

So this script is quite robust, no matter which isp fails it will do the right thing to get back online.

Code:
#!/bin/sh

PINGTARGET=8.8.8.8
PINGINTERVAL=3
PINGWAITFORRESPONSE=3

while [ 1 ]
do
   echo Waiting for ping to fail
   while [ 1 ] 
   do
      ping -c 1 -W $PINGWAITFORRESPONSE $PINGTARGET >/dev/null 2>/dev/null || break
      sleep $PINGINTERVAL
   done

   echo Switching to eth1
   ip route change default via 192.168.1.1 dev eth1 2>/dev/null

   echo Waiting for ping to fail
   while [ 1 ] 
   do
      ping -c 1 -W $PINGWAITFORRESPONSE $PINGTARGET >/dev/null 2>/dev/null || break
      sleep $PINGINTERVAL
   done

   echo Switching to eth0
   ip route change default via 192.168.0.1 dev eth0 2> /dev/null

   sleep 1
done
 
Old 07-12-2016, 06:10 PM   #21
Ulysses_
Senior Member
 
Registered: Jul 2009
Posts: 1,303

Original Poster
Rep: Reputation: 57
It would be nice if it switched back to eth0 when this isp is back online as this isp is faster. But how can a script test this without disrupting your connectivity while using a browser?

Last edited by Ulysses_; 07-12-2016 at 06:12 PM.
 
Old 07-12-2016, 06:49 PM   #22
jnihil
Member
 
Registered: Dec 2012
Location: inside the matrix
Distribution: Debian, Xubuntu, Gentoo, Antergos
Posts: 90

Rep: Reputation: 27
You could setup a static route for 8.8.8.8/32 pointed to eth0 and 8.8.4.4/32 for eth1.
Then you can ping 8.8.8.8 for ISP1 test, and 8.8.4.4 for ISP2, regardless of where the default route is pointing at the time.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Network Bridge Blocking Switch/Internet Access almcneill Linux - Networking 3 08-31-2011 06:46 PM
Ubuntu 8.04 in mixed Mac & Windows network Internet access but no access to network. traveller7 Linux - Networking 1 01-10-2009 07:53 PM
Network and P2P with Marvell Yukon adapters (or internet slows down) fraz Linux - Hardware 0 05-24-2005 02:43 PM
Automatically switch to different wireless network? m_a_b Linux - Wireless Networking 0 10-07-2004 09:12 AM
Easy access to the Internet drabkin Linux - Newbie 10 11-26-2002 08:03 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 12:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration