LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to add multiple gateways permanently in centos 6.2 (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-add-multiple-gateways-permanently-in-centos-6-2-a-4175430807/)

ssy 10-06-2012 03:11 AM

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

xenner 10-07-2012 09:38 PM

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.

ssy 10-14-2012 12:33 AM

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 (Post 4799842)
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.


mmheera 10-14-2012 08:21 AM

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!

xenner 10-23-2012 09:01 PM

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.


All times are GMT -5. The time now is 02:29 AM.