LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 11-11-2010, 01:42 PM   #1
slacky
Member
 
Registered: Feb 2004
Location: USA
Distribution: Debian
Posts: 174

Rep: Reputation: 16
Reversing Default gateway failover


I have a dual-homed Debian server running squid, but not acting as a router. Simplied network diagram is below - there are other local hops between the gateways and the Internet.

Code:
(eth0 @ 192.168.44.2) <--> (Gateway1 @ 192.168.44.1) <--> Internet
(eth1 @ 192.168.55.2) <--> (Gateway2 @ 192.168.55.1) <--> Internet
Using Gateway1 gives a very fast, but not always reliable route to the Internet. Using Gateway2 gives a slower, but more reliable route to the Internet. The server uses Gateway1 as the default gateway.

I have written a script that pings three hosts on the Internet, and if all three are down, switches the default gateway to Gateway2. This part seems to be easy, but I'd like know if there is a way of routing a ICMP/ping out eth0 to a host, with all other traffic to the host going out eth1, so I can determine if the Internet is reachable via Gateway1 again.

Thanks,
slacky
 
Old 11-11-2010, 01:52 PM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Why not just set up your routing table using metrics? Then the kernel's internal routing should handle it from there. Set a lower metric value to your preferred route.

That aside, you can use the -I option to ping to specify a local interface to use as the source for your packets.
 
Old 11-11-2010, 02:05 PM   #3
slacky
Member
 
Registered: Feb 2004
Location: USA
Distribution: Debian
Posts: 174

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by Matir View Post
Why not just set up your routing table using metrics? Then the kernel's internal routing should handle it from there. Set a lower metric value to your preferred route.
Thanks for your quick reply. I am unsure if this should work, the manpage for route says metric is "not used by recent kernels, but may be needed by routing daemons." If it does, does it require upstream routers to send ICMP unreachable messages back or anything?


Quote:
Originally Posted by Matir View Post
That aside, you can use the -I option to ping to specify a local interface to use as the source for your packets.
ping -Ieth1 www.google.com gives me the "Destination Host Unreachable"
 
  


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
Gateway/Router failover jetson21 Linux - Networking 14 04-01-2010 09:37 AM
normal default gateway reapperas with openvpn redirect-gateway jonnytabpni Linux - Networking 2 04-23-2009 02:11 PM
non-default route to static host through gateway for ppp failover testing jrscandora Linux - Networking 3 04-21-2009 02:20 AM
Default gateway dooda5555 Linux - Networking 1 06-17-2005 11:43 AM
default gateway avikosan Linux - Networking 3 12-09-2003 05:47 PM

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

All times are GMT -5. The time now is 11:57 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