# Multiple static routes - any way to reference external file?



## urbanriot (Nov 3, 2010)

I have a site whereby I need to add a long list of static routes to the routing table on a proxy server, due to various corporate rules, and I'm wondering if there's an easier way than using the static_routes command and listing thisroute1, thisroute2, anotherroute1, etc.

I have about 30 of these to do and I'd be much happier if I could reference this in an external file... or there's a better way to do this?

Thank you!


----------



## SirDice (Nov 3, 2010)

If you have that many static routes you should look into using a routing protocol like OSPF.


----------



## phoenix (Nov 3, 2010)

You could always just stick the routing commands into a shell script, and run that script via /etc/rc.local (although, I believe rc.local support will be going away in a future version).  Or even just write the commands directly into rc.local.

Or, you could edit /etc/rc.d/routing and have it call your shell script in the "Setup static routes" section.

Or, ideally, you could extend /etc/rc.d/routing to support an external routes file using somethinglike *static_routes_file*, and add all the needed glue to make it work as part of the normal RC structure.  Then submit that to the freebsd-rc mailing list for review.


----------



## DutchDaemon (Nov 3, 2010)

If /etc/rc.local goes away, there's always the trusted *@reboot* time in cron  

Just put your 'route add' commands in a shell script and let it run from either /etc/rc.local or cron. KISS (the principle, not the action).


----------



## urbanriot (Nov 4, 2010)

It's funny how a person can focus on discovering the best way to do something that they completely ignore the simplist method that'll work, like a shell script. Duh. 

Thanks gents.


----------

