How to add a persistant route in linux?

In a windows system a switch -p is used make a static route persistant in the routing table. How can a route be made persistant in linux?
route add -net x.x.x.x /x gw x.x.x.x adds the route but gets automatically flushed from the table if the route is not used for sometime or the system is restarted.
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.

add that rule in

/etc/rc.local file

so when system will reboot, it will added automaticaly
Monis MontherSystem ArchitectCommented:
This issue has been resolved successfully a week a go , check this question

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Meru_ITAuthor Commented:
Thanks small student. My situation is a little different than that. I have a server on an ethernet network connected on eth0 and using the IP of my L3 switch as the default gateway. Now I need to connect to a particular host on the on internet through a USB CDMA modem such that any traffic from my server to this host takes the CDMA route through the virtual ppp0 interface and not the eth0 interface.
I need to add a static route 'route add -host x.x.x.x gw x.x.x.x' (the gateway IP should be the remote IP assigned dynamically by the CDMA service provider). This route needs to be persistant and should not be flushed from the server's routing table if the connection is idle or even if the server is restarted.

Hope I am clear about the requirement.

Thanks in advance
Monis MontherSystem ArchitectCommented:
Ok I assume the when you do it manually with route add it worked fine for you, its just that you want it persistent after reboots

Fosiual01 provided a good solution.

Just make sure that it will also work in case you disconnect the USB and connect it back again after a while (in theory it will) in case it will not there is another solution but it would be more complecated, just let me know how it goes

Meru_ITAuthor Commented:
Hi small_student, sorry for the delay in responding. On disconnecting the USB modem or in case the connection is inactive for a while, the route gets flushed from the routing table.

I have added the route in rc.local which only helps adding the route at boot time but not to make it persistent in the table.

Please help!
did u read that first link?

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
Meru_ITAuthor Commented:
Follow the link for the solution.

Create a route- file in /etc/sysconfig/network-scripts/ and add static route with syntax as -
x.x.x.x/x via x.x.x.x dev

In my case, I added a route-bond0 file, made it executable  with chmod 777 and added the static route in the file. Then restarted network service.

Thanks all.
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.