Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5888
  • Last Modified:

Set two default gateway?

I have 3 Linux boxes.Let me first define the specs:
1.pc A with kernel > 2.4, ext eth-->adsl connection,int eth -->
2.pc B with kernel > 2.4, ext eth-->adsl connection,int eth -->
3.pc C with kernel 2.0.x, eth-->, gw-->

I'm hosting a download service on pc C. Currently, any incoming packets from pc A are forwarded to pc C so that users can download via connection on pc A. I have another ppp connection on pc B.  I want to configure the connection on pc B as a backup line to pc A. How do I make it in such a way that users can download from both connections on pc A and pc B? I've found out that users can only download from connection on pc B if I swith the default gateway of pc C to refer to pc B. Is it possible to have two default gateways on pc C, so that download from both connections could happen at the same time? Or are there any other ways to solve this? Please advice.
1 Solution

i.g. you cannot do it, simply ...
Have seen a question here where it has been discussed, not shure if the solution works (no link either).

What you want to do is usually done by a load balancer infront of the servers.
There're several load balabcing software available:
Load ballancing usually menad 2 connections to the same ISP and requires support at both ends.

Having a backup default gateway is easy, just set it upas a static route with a higher metric that the primary.

details vary from distro to distro, but in RH7.1 all you do is mangle


to add

eth0 net gw metric192.168.8.1  0
eth0 net gw metric192.168.8.2  5

(going from memory, YMMV). The box __should___ use .2 if .1 becomes unresponsive. Alternativley add B as a backup gateway to A, the changeover will then be transparent yo C.
viansooAuthor Commented:
what do u mean by 'mangle' the /etc/sysconfig/static-routes. is it equivalent to 'vi' the static-routes. after adding the 2 lines into the file, do i need to restart the pc?
vi, emacs, I'm not getting into that holy war ;-)

Restart the PC? What do you think this is, Windos?

ifdown eth0
ifup eth0

should be enough. actually,
/etc/sysconfig/network-scripts/ifup-routes eth0
should do the trick.

/etc/init.d/network restart
works too.

(sorry, being LINUX I feel obliged to point out several ways to skin the same cat)
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Post your closing recommendations!  No comment means you don't care.

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now