LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 01-06-2016, 07:15 AM   #1
teddy.phg
LQ Newbie
 
Registered: Jan 2016
Posts: 2

Rep: Reputation: Disabled
Question 2 NICs with different gateway


Dear All,

I am running centOS 5.6 with 2 NICs,

I need to set gateway for each NIC..

Eth0: 10.100.100.1 gateway: 10.100.100.101
Eth1: 10.100.100.2 gateway: 10.100.100.102

so packages come from Eth0 will be routed to 10.100.100.101
so does packages come from Eth1 will be routed to 10.100.100.2

any body please help?

many thanks in advance

Teddy
 
Old 01-06-2016, 09:36 AM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,347

Rep: Reputation: Disabled
That's not how routing works. NICs don't have gateways; routing tables do, and you usually have exactly one of those.

I don't blame you for thinking gateways are somehow tied to NICs, though, because that's how many configuration tools present the parameters. But if you specify two "default gateways" (note how it doesn't really make sense to talk about having more than one "default" of anything), you end up with either:
  • a system that uses one gateway and simply ignores the other, which is no help at all, or
  • a system that tries to round-robin load balance across the gateways, which usually won't work.
For outbound traffic on a multihomed system (one with more than one NIC) from a process that isn't bound to a specific IP address, the gateway is selected first, based on the information in the routing table. Then a source address is chosen, based on which NIC the packet has to go through in order to reach that gateway.

It is possible to bind a process to a specific IP, but that won't actually affect the choice of gateway. To do that, you need to implement what is known as "policy routing", where you have more than one routing table using different gateways, and traffic is routed using the various tables based on some specific criteria, like the source address.

Does that sound like what you want to accomplish?
 
Old 01-06-2016, 04:46 PM   #3
Doug G
Member
 
Registered: Jul 2013
Posts: 749

Rep: Reputation: Disabled
You can set up custom routing tables using iproute2 and give each nic a different default gateway. I've done so on CentOS 6, but only with the two nics on two different subnets.

I followed a process similar to the one described here: https://www.thomas-krenn.com/en/wiki..._on_One_System
 
Old 01-06-2016, 05:07 PM   #4
teddy.phg
LQ Newbie
 
Registered: Jan 2016
Posts: 2

Original Poster
Rep: Reputation: Disabled
Dear All,

noted with thanks..

Regards
Tedd
 
  


Reply



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
2 default gateway for 2 NICs each 5883 Linux - Networking 9 01-17-2012 07:23 AM
[SOLVED] Squid with 2 NICs... set gateway vonedaddy Linux - Server 7 11-11-2010 01:48 AM
Linux Gateway with 3 NICs pin_bk Linux - Networking 16 03-27-2005 09:57 AM
can't get nics working, on gateway evilchild Slackware 3 03-28-2004 07:18 PM
How do I connect dual nics in firewall to the gateway? scoobadiver Linux - Newbie 3 01-12-2004 05:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:48 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