Link to home
Start Free TrialLog in
Avatar of CahitEy
CahitEy

asked on

centos different subnets problem

Hello i have 2 centos machines but i have a problem with this both machine

my machines has different subnets with their gateway i mean machines ip addresses
188.72.xxx.188
188.72.xxx.189

and my gateway is :

217.20.xxx.1

so i have added this lines to route-eth0 :

ADDRESS0=217.20.117.1
NETMASK0=255.255.255.255

so i do not need to write
route add -net 217.20.117.1 netmask 255.255.255.255 dev eth0
but i still need to write :
route add default gw 217.20.117.1
manually how could i do this automagically
only there is a triick if i write it to network scripts it is loading before route-eth0 so it returns me unknown host or unreachable machine

Thank you
Avatar of Martin_J_Parker
Martin_J_Parker
Flag of United Kingdom of Great Britain and Northern Ireland image

Just add to your route-eth0:
GATEDWAY0=217.20.117.1
Avatar of CahitEy
CahitEy

ASKER

nope i have tryed not workd my netstat -rn must look like this (as seen on code file )

and i have not seen only the last line automagicaly


Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
217.20.117.1    0.0.0.0         255.255.255.255 UH        0 0          0 eth0
188.72.xxx.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0
0.0.0.0         217.20.117.1    0.0.0.0         UG        0 0          0 eth0

Open in new window

Have you restarted the eth0 ethernet since you changed the file?
Avatar of CahitEy

ASKER

yes exactly :) if i add the line as :
GATEWAY0=217.20.117.1

then my netstat table seems like
217.20.117.1    217.20.117.1         255.255.255.255 UH        0 0  

and my service network restart is returning unknown gateway :) unfortunately i have to route gateway at the end of all operations
What version of CentOS is it?
Avatar of CahitEy

ASKER

5.4 latest version also i have tryed for 4.8 and ubuntu that is only working correctly and automagically on fedora 12 all the other linux versions needs to make it manually
On RedHat Enterprise Linux 5.3 (which is meant to be the same base code as CentOS 5.3) my default route is set in /etc/sysconfig/network, which contains the following 4 lines:

NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=myhostname.mydomain.com
GATEWAY=10.1.1.1

so it might be worth seeing if setting the gateway in that file does the trick for you.
Avatar of CahitEy

ASKER

i have tryed this also
it is ignoring this on all linux dists exept  fedora 12 so fedora is working like a charm just when i set it on network adapter settings
Hmmm - one of those should work - you could put a script in /etc/rc3.d so it sets the route at startup (a bit of a kludge but effective) but that doesn't explain why the other files aren't affecting things.
Do you know about how the /etc/rc?.d directories work?
Avatar of CahitEy

ASKER

nope :(
ASKER CERTIFIED SOLUTION
Avatar of Martin_J_Parker
Martin_J_Parker
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
By the way, S10myscript would run before S10network because it comes first alphabetically - that's why I chose S11myscript.  

You may need to add the path to the route command into the script as I'm not 100% sure what the PATH will be set to at that point!
Avatar of arnold
You need to add a default gateway for each segment.
using the metric you can adjust the weight through.

Why/how does your eth0 interface have two separate segments that are completely different from the default gateway segment?
217.20.117.1 is no where near the 188..x.x.x/24 network.

The description in your question is missing some detail.
you can use the route add directive as martin_J_par posted.  The problem is that the traffic might not find itself back or the 188.x.x.x Ip will not be the source of the packets sent from your system.