Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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?
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.
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.
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.
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.
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.
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.
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.
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?
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.