LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 06-07-2010, 12:36 PM   #1
zaeem
Member
 
Registered: Jan 2010
Posts: 125

Rep: Reputation: 15
multiple interfaces with different default gateways issue


Dear All,

I have installed CentOS 5.5 64 bit on servers. Server have two NICs so I got following IP address information for each NIC.

eth0
IP Address: 192.168.0.12
Subnet Mask: 255.255.255.0
Default Gateway: 192.168.0.1


eth1
IP Address: 192.168.0.13
Subnet Mask: 255.255.255.0
Default Gateway: 192.168.0.2

When I assign IP addresses to both NICs from Graphical interface and execute "route -n" command then it only shows 192.168.0.1. Whereas I have defined separate default gateways for both NICs. How to fix that?

Furthermore eth1 IP address is public and accessible over internet whereas eth0 is private on. How can I configure centos in this way.

I'll really appreciate prompt response in this regard.

Regards,
Shirazi
 
Old 06-07-2010, 04:09 PM   #2
jefro
Moderator
 
Registered: Mar 2008
Posts: 22,001

Rep: Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629
Remove the first gateway address.
 
Old 06-07-2010, 06:37 PM   #3
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
You can't have different default gateways while using the same subnet. It is nonsense to say that one of your cards is connected to the internet. The IP address of 192.168.0.13 can NOT be public, it is an address reserved for internal use.

I guess you have a router between the internet and said eth1. Since both cards are on the same subnet you have the gateways on the same subnet as well.

So point your default gateway to 192.168.0.2 as I assume that one is the router going to the internet.

For all other addresses which you want to go thru 192.168.0.1 you must set up a specific route:
Code:
route add -net 192.168.22.0/24 gw 192.168.0.1 dev eth0
jlinkels
 
Old 06-07-2010, 10:27 PM   #4
zaeem
Member
 
Registered: Jan 2010
Posts: 125

Original Poster
Rep: Reputation: 15
Dear jlinkels,

Thanks for the help. I know the public IP Address 192.168.0.13 can't be public because it is reserved for internal use. I just mentioned dummy IP Addresses here.

Coming back to point, let me give more detail that in our lab we have two routers (cisco 6713(A), cisco 6713(B)). So NIC one has cable coming from router A and other NIC is getting cable from router B.

I believe this might be of some help to you provide suggestion/solution.

Once again I am expecting quick response

Regards,
Shirazi
 
Old 06-08-2010, 09:39 AM   #5
SuperJediWombat!
Member
 
Registered: Apr 2009
Location: Perth, Australia
Distribution: Ubuntu/CentOS
Posts: 208

Rep: Reputation: 51
Quote:
Originally Posted by zaeem View Post
Once again I am expecting quick response
This does not make us want to help you. Try rereading the above posts.
 
Old 06-08-2010, 09:44 AM   #6
zaeem
Member
 
Registered: Jan 2010
Posts: 125

Original Poster
Rep: Reputation: 15
Dear SuperJediWombat,

I am sorry if you don't like my following sentence. Actually I meant to say that as you guys response to my queries very fast so I was expecting same positive and helpful reply from you guys.

I hope it clarifies and you will help me in this matter.

Regards,

Shirazi
 
Old 06-08-2010, 09:49 AM   #7
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hi,

First of all there are two basic thing you need to understand (and apply) when you post on LQ, patience and politeness. Sad to say you are not showing either. This will only result in users not being very willing to help you. We are all volunteers here who are helping out other Linux users on our free time. If you need 'urgent' help, then get paid assistance.

That being said, jlinkels already put you on track, that you have to base your routing on device level if you want to separate traffic or put your NICs in a different subnet.

Kind regards,

Eric
 
Old 06-08-2010, 10:23 AM   #8
SuperJediWombat!
Member
 
Registered: Apr 2009
Location: Perth, Australia
Distribution: Ubuntu/CentOS
Posts: 208

Rep: Reputation: 51
If you do not understand jlinkels advice, please post the (unedited) output of the following commands:
Code:
ifconfig
ip route
iptables-save
cat /proc/sys/net/ipv4/ip_forward
 
Old 06-08-2010, 11:11 AM   #9
zaeem
Member
 
Registered: Jan 2010
Posts: 125

Original Poster
Rep: Reputation: 15
Dear SuperJediWombat,

I am really very grateful for help and assistance. Below are output of commands.

========================ifconfig=================
# ifconfig
eth0 Link encap:Ethernet HWaddr 00:30:48:FB:F2:38
inet addr:58.27.179.130 Bcast:58.27.179.159 Mask:255.255.255.224
inet6 addr: fe80::230:48ff:fefb:f238/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:67640 errors:0 dropped:0 overruns:0 frame:0
TX packets:84754 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:43154378 (41.1 MiB) TX bytes:102919148 (98.1 MiB)
Memory:fc100000-fc120000

eth1 Link encap:Ethernet HWaddr 00:30:48:FB:F2:39
inet addr:58.27.179.162 Bcast:58.27.179.191 Mask:255.255.255.224
inet6 addr: fe80::230:48ff:fefb:f239/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:155198 errors:0 dropped:0 overruns:0 frame:0
TX packets:74520 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:195847379 (186.7 MiB) TX bytes:4900106 (4.6 MiB)
Memory:fc200000-fc220000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:30173 errors:0 dropped:0 overruns:0 frame:0
TX packets:30173 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:36135917 (34.4 MiB) TX bytes:36135917 (34.4 MiB)

============================ip route=============================

# ip route
58.27.179.160/27 dev eth1 proto kernel scope link src 58.27.179.162
58.27.179.128/27 dev eth0 proto kernel scope link src 58.27.179.130
169.254.0.0/16 dev eth1 scope link
default via 58.27.179.161 dev eth1


===========================iptables-save===============
no output



===============================================================
==========cat /proc/sys/net/ipv4/ip_forward=============


# cat /proc/sys/net/ipv4/ip_forward
0
 
Old 06-09-2010, 08:46 AM   #10
SuperJediWombat!
Member
 
Registered: Apr 2009
Location: Perth, Australia
Distribution: Ubuntu/CentOS
Posts: 208

Rep: Reputation: 51
I am not exactly clear on what the problem is, or what you are trying to accomplish. Can you please try to summarise the problem in a few sentences please?

It looks like you have two interfaces, in seperate subnets, both with public IP ranges, there is no issue with your routing table right now, you can only have one default gateway set at a time as was mentioned earlier.
 
Old 06-09-2010, 02:11 PM   #11
zaeem
Member
 
Registered: Jan 2010
Posts: 125

Original Poster
Rep: Reputation: 15
Dear SuperJediWombat,

Let me summarize what I want to do. I have two servers having CentOS 5.5 installed. Both server has two NICs. The assignment of IP addresses is as follows (I will be mentioning dummy IPs due to security concerns).

Server 1:
NIC 1
IP Address: 192.168.0.12
Subnet Mask: 255.255.255.224
Default Gateway: 192.168.0.1


NIC 2
IP Address: 192.168.0.60
Subnet Mask: 255.255.255.224
Default Gateway: 192.168.0.161


Server 2:
NIC 1
IP Address: 192.168.0.13
Subnet Mask: 255.255.255.224
Default Gateway: 192.168.0.1


NIC 2
IP Address: 192.168.0.61
Subnet Mask: 255.255.255.224
Default Gateway: 192.168.0.161

Now I can access both servers through NIC 1 IP address (ssh 192.168.0.13) but when I try to access server using NIC 2 IP address as ssh 192.168.0.61 or ssh 192.168.0.60 then it says connection timed out. When I execute route -n it shows default gateway of NIC 2 (192.168.0.161). Now I want to know how can I access servers using NIC 2 IP addresses. Am I required to add some static routes? If yes then please refer me to some tutorial or tell me commands to do that.

I hope now it will be much easier for you to understand my issue and help me to resolve the issue.

Regards,
Shirazi
 
Old 06-09-2010, 02:34 PM   #12
nimnull22
Senior Member
 
Registered: Jul 2009
Distribution: OpenSuse 11.1, Fedora 14, Ubuntu 12.04/12.10, FreeBSD 9.0
Posts: 1,571

Rep: Reputation: 92
You CAN NOT assign IP from the same subnetwork to a different interfaces on the same box. Internal router wont work.
Server 1 should has:
NIC 1
IP Address: 192.168.1.xxx
Subnet Mask: 255.255.255.xxx
Default Gateway: 192.168.1.1


NIC 2
IP Address: 192.168.5.xxx
Subnet Mask: 255.255.255.xxx
Default Gateway: 192.168.5.1
 
Old 06-09-2010, 06:41 PM   #13
SuperJediWombat!
Member
 
Registered: Apr 2009
Location: Perth, Australia
Distribution: Ubuntu/CentOS
Posts: 208

Rep: Reputation: 51
@nimnull22: Note the separate subnets

@zaeem: YOU CANNOT HAVE TWO DEFAULT GATEWAYS!!!


Why are both of your (real) networks in a public IP range? Are these servers in a datacentre?
 
Old 06-11-2010, 09:09 AM   #14
zaeem
Member
 
Registered: Jan 2010
Posts: 125

Original Poster
Rep: Reputation: 15
Dear SuperJediWombat,

Yes servers are in data centre. BTW, route -n command picks data from which file. Can you please give me a hint of that file. I will be thankful.
 
Old 06-11-2010, 12:45 PM   #15
juan10dan
Member
 
Registered: Jun 2010
Posts: 31

Rep: Reputation: 1
You really have to remember what SuperJediWombat! said:
YOU CANNOT HAVE TWO DEFAULT GATEWAYS!!!

That way you understand that there are some things that you can't do with simple routing.

Simply routing (route command or GUI) only route packets based on destination ip.

If you want to route a packet based on another stuff, you can not do it with simple routing.

For example if you want your packet to get routed based on source ip, there's something called source routing using iproute2 (I think). So put clear what factor is the base of your routing and there you can google it of post it here again.
 
  


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
Multiple interfaces to different gateways PacketWhacker Linux - Networking 2 04-15-2009 03:44 PM
Multiple eth interfaces, gateways, SuSE 10 b1f30 Linux - Networking 6 07-11-2008 05:20 PM
multiple default gateways jireson Linux - Networking 3 02-04-2006 01:24 AM
Red Hat 7.3 and multiple gateways on multiple interfaces bluefmc Linux - Networking 2 11-19-2004 05:01 PM
Multiple Interfaces Seperate Gateways? byersjlpa Linux - Networking 10 01-09-2003 03:47 PM

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

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