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
LVL 1
CahitEyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin_J_ParkerCommented:
Just add to your route-eth0:
GATEDWAY0=217.20.117.1
0
CahitEyAuthor Commented:
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

0
Martin_J_ParkerCommented:
Have you restarted the eth0 ethernet since you changed the file?
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

CahitEyAuthor Commented:
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
0
Martin_J_ParkerCommented:
What version of CentOS is it?
0
CahitEyAuthor Commented:
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
0
Martin_J_ParkerCommented:
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.
0
CahitEyAuthor Commented:
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
0
Martin_J_ParkerCommented:
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?
0
CahitEyAuthor Commented:
nope :(
0
Martin_J_ParkerCommented:
Okay, whan you boot into runlevel 3 the scripts in /etc/rc3.d are run.
Scripts starting with an "S" are run at startup and any starting with "K" are run at shutdown.
They are run in order, so a script starting with S01 will runn before a script starting with S99
Most of the scripts are links to scripts in /etc/init.d

If you wanted to start a script right after S10 network was run, what you would create a script in /etc/init.d called something like "myscript",
make it executable with the command:
"chmod 775 /etc/init.d/myscript"
and then make a link to the /etc.rc3.d directory with the command:
"ln -s /etc/init.d/myscript /etc/rc3.d/S11myscript"

By calling it S11myscript you are forcing it to run after S10network.  You could probably get away with calling it S99myscript.

The script will be run automatically at startup with the command:
/etc/rc3.d/S11myscript start

If you boot to runlevel 2 rather than runlevel 3 you would need to make the same link to /etc/rc2.d rather than /etc/rc3.d - a lot of licensing programs create links to /etc/rc2.d, /etc/rc3.d, /etc/rc4.d and /etc/rc5.d to be sure that it will start whatever the runlevel.

Your "myscript" should look something like this:

#!/bin/sh -f
#
# Start default route
#
case "$1" in
'restart')
        echo "Restarting default route..."
        route add default gw 217.20.117.1
        ;;
'start')
        echo "Starting default route..."
        route add default gw 217.20.117.1
        ;;
'stop')
        ;;
*)
    echo "usage: $0 {start|stop|restart}"
        ;;
esac
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Martin_J_ParkerCommented:
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!
0
arnoldCommented:
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Distributions

From novice to tech pro — start learning today.