I have set up Ubuntu 14.04 server on a machine and configured /etc/network/interfaces with two gateways. The default one is em1 which is fine, but I need traffic to a specific IP address on the internet to be sent via the other gateway. The following command works from the command line:
sudo route add -net XXX.XXX.XXX.XXX netmask 255.255.255.255 gw 172.16.0.1
but adding it to /etc/network/interfaces does not work on reboot:
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto em1 iface em1 inet static address 10.0.2.251 netmask 255.255.255.0 gateway 10.0.2.1 dns-nameservers 126.96.36.199 188.8.131.52 auto em1:0 iface em1:0 inet static address 172.16.1.6 netmask 255.255.0.0 gateway 172.16.0.1 dns-nameservers 184.108.40.206 220.127.116.11 post-up route add -net XXX.XXX.XXX.XXX netmask 255.255.255.255 gw 172.16.0.1
Can anyone help?