Adding static routes to the network

It may be desirable to add static routes for routing of specific subnets via specificgateways 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 lostafter an apply.

Rather, static routes should be placed in /etc/network/if-up.d/static-routes. Thisscript will be run when-ever an IP interface comes up. Theinterface that triggered the script is available via the IFACEenvironment variable.

For example:

#!/bin/bash

if [ “$IFACE” == “eth0” ]; then

sudo ip route add x.x.x.x via y.y.y.y

fi

if [ “$IFACE” == “eth1” ]; then

sudo ip route add x.x.x.x/24 dev eth1

fi

Ensure the script is executable:

sudo chmod +x /etc/network/if­up.d/static­routes

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 routein the Com.X routing table.