It may be desirable to add static routes for routing of specific subnets via specific
gateways or over specific interfaces.
Applying networking changes from the Com.X GUI over-writes the
/etc/network/interfaces file. Any changes made to this file may be lost
after an apply.
Rather, static routes should be placed in /etc/network/if-up.d/static-routes. This
script will be run when-ever an IP interface comes up. The
interface that triggered the script is available via the IFACE
if [ “$IFACE” == “eth0” ]; then
sudo ip route add x.x.x.x via y.y.y.y
if [ “$IFACE” == “eth1” ]; then
sudo ip route add x.x.x.x/24 dev eth1
Ensure the script is executable:
sudo chmod +x /etc/network/ifup.d/staticroutes
Restart the interface or alternatively the Com.X:
sudo ifdown eth && sudo ifup eth
|Note: It is not recommended to have more than one default route
in the Com.X routing table.