LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-06-2012, 04:11 AM   #1
ssy
LQ Newbie
 
Registered: Oct 2012
Posts: 2

Rep: Reputation: Disabled
how to add multiple gateways permanently in centos 6.2


I have 2 ISPs having router-IPs 172.16.1.10 & 172.16.1.253.
Server's present route is 172.16.1.10, when it goes off server should switch automatically to second one ie 172.16.1.253

Plz. guide me to add both gateways in centos
 
Old 10-07-2012, 10:38 PM   #2
xenner
Member
 
Registered: Jul 2009
Location: Brisbane
Distribution: RHEL 6.5
Posts: 39

Rep: Reputation: 0
One potential method

How many NIC's do you have?

If there's a single nic, I'm not sure that you can do it... Well, not without scripting up a constant icmp check to the 172.16.1.10 address, and if it fails, then have the script change a file for you.

The absolute easiest way to do it (Without setting any strange routes), I would:
cp /etc/sysconfig/network /etc/sysconfig/network.orig
vi /etc/sysconfig/network ---> Change the default gateway in here

When the gateway fails, then you can have a script to switch the two files over for you and restart the network service:
ie.

mv /etc/sysconfig/network /etc/sysconfig/network.orig1
mv /etc/sysconfig/network.orig /etc/sysconfig/network
mv /etc/sysconfig/network.orig1 /etc/sysconfig/network.orig
service network restart

The above assumes that you haven't set up your gateways in /etc/sysconfig/network-scripts/ifcfg-eth0
It also assumes you haven't set any routes for info.

Don't forget to test it before it's implemented.

Hope that helps somewhat.
 
Old 10-14-2012, 01:33 AM   #3
ssy
LQ Newbie
 
Registered: Oct 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
multiple gateway in centos 6.2

Thanx for reply.

In have a single NIC, and one gateway is already defined in \etc\sysconfig\network\ifcfg-eth0 and no default gateway in \etc\sysconfig\network. still can I use your given commands

to add multiple defult gateways.

Plz. Help me.
Thanx
ssy






Quote:
Originally Posted by xenner View Post
How many NIC's do you have?

If there's a single nic, I'm not sure that you can do it... Well, not without scripting up a constant icmp check to the 172.16.1.10 address, and if it fails, then have the script change a file for you.

The absolute easiest way to do it (Without setting any strange routes), I would:
cp /etc/sysconfig/network /etc/sysconfig/network.orig
vi /etc/sysconfig/network ---> Change the default gateway in here

When the gateway fails, then you can have a script to switch the two files over for you and restart the network service:
ie.

mv /etc/sysconfig/network /etc/sysconfig/network.orig1
mv /etc/sysconfig/network.orig /etc/sysconfig/network
mv /etc/sysconfig/network.orig1 /etc/sysconfig/network.orig
service network restart

The above assumes that you haven't set up your gateways in /etc/sysconfig/network-scripts/ifcfg-eth0
It also assumes you haven't set any routes for info.

Don't forget to test it before it's implemented.

Hope that helps somewhat.
 
Old 10-14-2012, 09:21 AM   #4
mmheera
Member
 
Registered: Oct 2012
Location: Germany
Distribution: Ubuntu, Debian, Fedora,Windows 7
Posts: 107

Rep: Reputation: 11
You may check this:

http://code.google.com/p/wanfailoverscript/

or

http://joel.amw.co.id/w/failover-scr...y-in-linux.txt

But this assumes you have two external interface connected to the ISP.

Thanks!
 
Old 10-23-2012, 10:01 PM   #5
xenner
Member
 
Registered: Jul 2009
Location: Brisbane
Distribution: RHEL 6.5
Posts: 39

Rep: Reputation: 0
You can use the same commands, just change it to the ifcfg-eth0 instead of the 'networks' file.

And as I mentioned, you can do it with magical routes, as mmheera has suggested.

Good luck.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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] CentOS 6.2: Multiple gateways, NIC Problems, Cannot ping all network machines. K4M5Y5 Linux - Networking 3 04-16-2012 09:26 AM
Add multiple IPv6 on Centos LowKey88 Linux - Server 1 08-12-2009 06:20 AM
how can i add multiple gateways cristian1983 Linux - Networking 1 02-27-2007 10:58 AM
Red Hat 7.3 and multiple gateways on multiple interfaces bluefmc Linux - Networking 2 11-19-2004 06:01 PM
multiple ips, multiple gateways, one interface drpixel Linux - Networking 6 12-04-2002 01:56 AM


All times are GMT -5. The time now is 08:41 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration