LinuxQuestions.org
Help answer threads with 0 replies.
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 02-22-2017, 02:30 PM   #1
kajkoz
LQ Newbie
 
Registered: Feb 2008
Posts: 8

Rep: Reputation: 2
Two gateways


How to setup linux network with 2 gateways for the same network.
For example
Network 192.168.1.0/24 and ip address of linux is 192.168.1.10. Actual gateway is 192.168.1.1 I would like to add 192.168.1.200 as a second gateway with metric 100 or so.
 
Old 02-23-2017, 08:32 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,278

Rep: Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897
Quote:
Originally Posted by kajkoz View Post
How to setup linux network with 2 gateways for the same network.
For example Network 192.168.1.0/24 and ip address of linux is 192.168.1.10. Actual gateway is 192.168.1.1 I would like to add 192.168.1.200 as a second gateway with metric 100 or so.
Read the "Question Guidelines" link in my posting signature...you don't say what version/distro of Linux you're using,but the biggest question here is WHY you even want/need to do this.

One route to a network is all you need...anything else in the 192.168.1.x network will know where to go. What are you actually trying to accomplish by doing this?
 
Old 02-23-2017, 11:42 AM   #3
kajkoz
LQ Newbie
 
Registered: Feb 2008
Posts: 8

Original Poster
Rep: Reputation: 2
I do have a Centos 6.8.
The reason is to build the more reliable network. If one of a gw is down the other is active and vice versa. Thorough these gateway host can communicate with other network(s). Both gw's are set to routing between networks.
 
Old 02-23-2017, 12:00 PM   #4
r3sistance
Senior Member
 
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375

Rep: Reputation: 217Reputation: 217Reputation: 217
What you are asking for appears a bit pointless, it seems to me you are trying to remove a single point of failure but you'll still have a single point of failure since you still only have one cable.

I think what you are looking for actually lays down a different avenue of either nic-bonding or nic-teaming. This will make multiple ports act as one, then you can split them between two different switches which go to two different routers with active-standby configuration at all points. If you are looking for network redundancy then this will give it to you.

Last edited by r3sistance; 02-23-2017 at 12:02 PM.
 
1 members found this post helpful.
Old 02-23-2017, 12:52 PM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,278

Rep: Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897
Quote:
Originally Posted by kajkoz View Post
I do have a Centos 6.8.
The reason is to build the more reliable network. If one of a gw is down the other is active and vice versa. Thorough these gateway host can communicate with other network(s). Both gw's are set to routing between networks.
There is no 'routing between networks' here...you have ONE NETWORK, period. You cannot have two default gateways.

If you want a more reliable network, then you should investigate channel bonding, but even that is only for the server itself. As said, if you have ONE network, it's pointless unless you have multiple routers/switches behind the scenes, so that THEY are reliable too. Having two routes to the same network buys you nothing.
 
1 members found this post helpful.
Old 02-23-2017, 08:20 PM   #6
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,809

Rep: Reputation: 3604Reputation: 3604Reputation: 3604Reputation: 3604Reputation: 3604Reputation: 3604Reputation: 3604Reputation: 3604Reputation: 3604Reputation: 3604Reputation: 3604
I get the feeling you want to use some sort of failover and not exactly a second gateway maybe.?
 
Old 02-24-2017, 09:05 AM   #7
kajkoz
LQ Newbie
 
Registered: Feb 2008
Posts: 8

Original Poster
Rep: Reputation: 2
Thank you @jefro. It should be a same sort of failover. All previous responds are helpless. I do not asked if it is right or not, I do asked how to do it. I am not looking for judging I am looking for solution. So how to do it. If it is possible on windows why not on Linux. Do i have to use a route2? If yes, how.
So again. How to setup 2 gateways on centos 6.8 box? If somebody now, please respond. If not keep your judgment to yourself.
 
2 members found this post helpful.
Old 02-24-2017, 10:30 AM   #8
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,278

Rep: Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897
Quote:
Originally Posted by kajkoz View Post
Thank you @jefro. It should be a same sort of failover. All previous responds are helpless. I do not asked if it is right or not, I do asked how to do it. I am not looking for judging I am looking for solution. So how to do it. If it is possible on windows why not on Linux. Do i have to use a route2? If yes, how.
So again. How to setup 2 gateways on centos 6.8 box? If somebody now, please respond. If not keep your judgment to yourself.
How about you keep your snotty comments to yourself??

AGAIN, you *CAN* do this on Linux, but as on Windows, WHAT YOU ARE TRYING TO DO HAS NO POINT...IT DOES NOT HELP YOU...IT DOES NOT MAKE THINGS MORE RELIABLE. If you don't understand this, then please get one of your network/systems administrators to explain why this isn't of any use at all. If you want network reliability, you put a second NIC into your system, have it running to a different switch (so you have TWO physical paths out), and enable channel bonding. THAT gives you reliability. You can do channel bonding using virtual interfaces on one NIC, but it WILL NOT be more reliable; you can do channel bonding to the same network with two NIC's...but it is STILL not more reliable, since you've still got single points of failure in multiple places, and you appear to not understand that.

Want to add a second route to the same network? Look at the "route add" command. Have fun.
 
Old 02-24-2017, 10:33 AM   #9
r3sistance
Senior Member
 
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375

Rep: Reputation: 217Reputation: 217Reputation: 217
The only ways to have multiple gateways is to either have multiple networks or to use static routes, neither of these will help in the case of a gateway failure, please see the earlier responses by both myself and TB0ne because these have the answer you're actually looking for. If you don't think it does then you need to give us more information.

Last edited by r3sistance; 02-24-2017 at 10:35 AM.
 
1 members found this post helpful.
Old 02-24-2017, 11:04 AM   #10
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1693Reputation: 1693Reputation: 1693Reputation: 1693Reputation: 1693Reputation: 1693Reputation: 1693Reputation: 1693Reputation: 1693Reputation: 1693Reputation: 1693
For what it is worth - the process of creating a HA route is a responsibility of your router(s). In a general cisco way this requires setting up 2 routers with HSRP and a floating IP address. This is called high availability and is typically not a function of the client.
 
Old 02-24-2017, 12:11 PM   #11
kajkoz
LQ Newbie
 
Registered: Feb 2008
Posts: 8

Original Poster
Rep: Reputation: 2
TB0ne. Why you are so angry? I just asked a question.
This is the situation
4 networks
1. 192.168.1.0/24
2. 192.168.10.0/24
3. 10.10.10.1/24
4. 172.16.0.1/24
Two routers in network 1, R1=192.168.1.1 and R2=192.168.1.2

Routing from network 1 to network 2 and 3 and 4

Windows host from network 1 default gw is 192.168.1.1 metric 10 and second as 192.168.1.2 metric 100
Linux host from network 1 default gw is 192.168.1.1
Reboot router R1 or make some changes ... Windows host pickup router R2, Linux - must change manually. Is that clear?

Last edited by kajkoz; 02-24-2017 at 12:13 PM.
 
Old 02-24-2017, 12:25 PM   #12
dijetlo
Senior Member
 
Registered: Jan 2009
Location: RHELtopia....
Distribution: Solaris 11.2/Slackware/RHEL/
Posts: 1,491
Blog Entries: 2

Rep: Reputation: Disabled
Ignore: Nothing worth looking at here... the answer is two posts down

Last edited by dijetlo; 02-24-2017 at 01:43 PM. Reason: Makes the page shorter
 
Old 02-24-2017, 12:32 PM   #13
kajkoz
LQ Newbie
 
Registered: Feb 2008
Posts: 8

Original Poster
Rep: Reputation: 2
OK. thank you.
 
Old 02-24-2017, 12:46 PM   #14
dijetlo
Senior Member
 
Registered: Jan 2009
Location: RHELtopia....
Distribution: Solaris 11.2/Slackware/RHEL/
Posts: 1,491
Blog Entries: 2

Rep: Reputation: Disabled
CORRECTION:
Quote:

ADD
bash-4.3# route add -net 192.168.3.0 netmask 255.255.255.0 gw 192.168.0.254 dev eth0

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.0.1 0.0.0.0 UG 303 0 0 wlan0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
192.168.0.0 0.0.0.0 255.255.255.0 U 303 0 0 wlan0
192.168.3.0 192.168.0.254 255.255.255.0 UG 0 0 0 eth0

-----------------

DELETE
route del -net 192.168.3.0 gw 192.168.0.254 netmask 255.255.255.0 dev eth0

Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.0.1 0.0.0.0 UG 303 0 0 wlan0
loopback * 255.0.0.0 U 0 0 0 lo
192.168.0.0 * 255.255.255.0 U 303 0 0 wlan0
Will add the route to the kernel routing table and create your gateway
Mia Culpa

The Manual for the save !!!

Last edited by dijetlo; 02-24-2017 at 01:41 PM. Reason: Remediated Ignorance
 
Old 02-24-2017, 01:00 PM   #15
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,278

Rep: Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897Reputation: 7897
Quote:
Originally Posted by kajkoz View Post
TB0ne. Why you are so angry? I just asked a question.
You were rude and snotty, that's why. Saying things like:
"All previous responds are helpless. I do not asked if it is right or not, I do asked how to do it. I am not looking for judging I am looking for solution. So how to do it."
...and...
"If somebody now, please respond. If not keep your judgment to yourself."

You were rude, period. You came here asking for suggestions/knowledge/guidance with a problem you don't know how to solve, and you're asking a bunch of people who DO KNOW, and you're getting told it's a bad idea, and won't do anything to help you with your actual goal. You also get told what exactly TO DO to accomplish things, but you ignore that. Don't want people to be upset with you? Then don't be rude and ungrateful. Because in the real world, saying things like you said above would get you ignored (at best).
Quote:
This is the situation
4 networks
1. 192.168.1.0/24
2. 192.168.10.0/24
3. 10.10.10.1/24
4. 172.16.0.1/24

Two routers in network 1, R1=192.168.1.1 and R2=192.168.1.2 Routing from network 1 to network 2 and 3 and 4

Windows host from network 1 default gw is 192.168.1.1 metric 10 and second as 192.168.1.2 metric 100
Linux host from network 1 default gw is 192.168.1.1

Reboot router R1 or make some changes ... Windows host pickup router R2, Linux - must change manually. Is that clear?
...and if you had bothered to actually tell us these things from your first post, we wouldn't have had to guess, would we? You still have also not told us if you're using one NIC or two.

And from what you posted, it's clear you don't have much understanding of what you're doing. You can only ever have ONE DEFAULT GATEWAY, period, on any operating system, ever. That's why it's a 'default' gateway. AGAIN, as you've been told several times now, you need to use channel bonding. Your Linux system will then have ONE IP ADDRESS that is shared between the two NIC's. One network goes down, and it doesn't matter...things keep going. You can set the second route, as you were told, using "route add" (as dijetlo told you, since you didn't look further), but it will not give you reliability/failover in what you're looking for.

AGAIN: what you are doing is much like saying "I'm going to put a second gas tank in my car!! That way, it'll NEVER BREAK DOWN". Pointless...you still have one engine, one transmission, etc. Because you duplicate ONE part doesn't give you anything.
 
  


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
Two gateways? MarcusWebb1966 Linux - Networking 11 07-12-2011 06:16 AM
Two gateways? candyman123 Linux - Networking 1 09-08-2005 01:36 PM
Gateways Esmo2000 Linux - Networking 1 01-03-2005 03:49 PM
2 Gateways Equis Linux - Networking 1 11-15-2003 04:58 AM
2 Gateways def1014 Linux - Networking 3 10-24-2002 06:21 PM

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

All times are GMT -5. The time now is 10:50 AM.

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