My embedded hardware running Ubuntu 16.04LTS has two NICs, eth0 and eth1. In production, eth0 is connected and should use 192.168.0.1 as the gateway for addresses outside the /24 subnet. For diagnostics or field upgrades, I want to be able to connect eth1 to my Windows PC and use Windows 10 Internet Connection Sharing, which by default provides a gateway of 192.168.137.1.
Because there is no wifi and I'm trying to keep it simple, I've uninstalled the Ubuntu NetworkManager and I'm just using /etc/network/interfaces.
The modest goal is for whichever interface is active to set the gateway, and a bonus would be able to set one as a higher priority with a metric command, but I could live without that. I was hoping to be able to avoid setting the routing table with specific commands.
The /etc/network/interfaces file of my dreams looks like this:
auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 192.168.0.2 netmask 255.255.255.0 gateway 192.168.0.1 metric 100 dns-nameservers 18.104.22.168 auto eth1 iface eth1 inet static address 192.168.137.2 netmask 255.255.255.0 gateway 192.168.137.1 metric 50 dns-nameservers 22.214.171.124
plus whatever is needed to make it actually work, since it doesn't currently meet expectations. At the moment it works fine when eth0 is plugged in but when only eth1 is connected, it can see the local subnet but it does not route anything through the gateway.
I feel like this is not very complicated, and yet I can't seem to find a simple solution in similar postings