Link to home
Start Free TrialLog in
Avatar of rawandnet
rawandnet

asked on

add pemananet static route under RHEL5

Hi guys,
I have two network interfaces
Eth0 10.1.0.202 255.255.0.0 gw 10.1.0.1
Eth1 192.168.1.22 255.255.255.0 gw 192.168.1.1
Default internet route is 10.1.0.1

I want to add a permanent route for eth1 192.168.1.122 to be forwarded to 192.168.1.1
I did some search they say open file /etc/sysconfig/network-scripts/route-eth0 and add static route there example:
192.168.1.0/24 via 192.168.1.1

But I don’t have that file under that directory, I am using RHEL5, where is that file?

ASKER CERTIFIED SOLUTION
Avatar of Kerem ERSOY
Kerem ERSOY

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
Avatar of Kerem ERSOY
Kerem ERSOY

As I told you above it is not a normal practice to assign a gateway for any address located in the local network of an interface. I really suspect that your problem is not with the routing but the assignment of the address 192.168.1.122 to the 192.168.1.1 interface.

Cheers,
K.
 
Avatar of rawandnet

ASKER

OK, I know what you mean, but mean while, just for the same of learning, i did wwhat you said after restarting network service i got following error

Bringing up interface eth1:  RTNETLINK answers: Invalid argument

i did following:
#vi route-eth1
GATEWAY0=192.168.1.1
NETMASK0=255.255.255.0
ADDRESS0=192.168.1.122


SOLUTION
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
that is true under command line this will create the route, but it wan't stay after restarting network services. I even created a file under /etc/sysconfig/network-scripts, named route-eth1 and added your line (ip route add 192.168.1.0 via 192.168.1.1), but i got error
(Bringing up interface eth1:  Error: an inet prefix is expected rather than "ip") how can i make that route permanent?
Ok under the file you created the syntax should be

192.168.1.0/24 via 192.168.1.1

This should be the only line under your file

Restart network and try

/etc/init.d/network restart

thanks for your comment, it solved what I needed