add static route under linux

I needed to add a static route on our Asterisk CentOS Linux box to force traffic out the second router to our voice service provider.

Here are three ways;

1.  Note; does not survive a re-boot

root@pbx~]# ip route add via

2.  Add the route to rc.local

root@pbx ~]# nano /etc/rc.local

3.  Add it to route-eth0, I think this the best way but you will need to restart the the network with /etc/init.d/network restart

root@pbx ~]#nano /etc/sysconfig/network-scripts/route-eth0