/etc/interfaces file for multiple gateways, same network? (linux)
Solution 1:
Sure, something like this may work
auto eth0
iface eth0 inet static
address 10.1.248.11
netmask 255.255.255.0
up ip route add default via 10.1.248.1 dev eth0 metric 100
up ip route add default via 10.1.248.3 dev eth0 metric 200
Solution 2:
Yep. Add your ip route add
lines to a script called (for example) /usr/local/sbin/routes
and then add the following to the interfaces file, alongside the normal directives for eth0:
up /usr/local/sbin/routes
If you need to, you can add a similar pre-down
directive, too, pointing to a different script, or invoking the script with an argument that deletes the routes, instead. (up
and pre-down
are invoked after the interface is brought up and before it is taken down, repsectively)