By default, the packets of default connection will use eth0 to go out/in.
The default gateway in the routing table is eth0’s gw ip.
When another interface said eth1 is up, I want to add another default gateway for eth1.
Is that possible in android?
Since I cannot add another default gateway for eth1 because there already exists eth0’s.
Thanks for your help.
A default gateway is only one, it’s the default. You can have several interfaces each one with a different gateway, but only one default (your system cannot choose).
Imagine this:
You should have at least 3 routes (usually automatic):
So you see, you don’t need more than one default gateway. What you might want is a gateway for a specific route. Imagine that you have the network
192.168.2.0that can only be reached by using gateway at192.168.1.1. With the above configuration, your machine would try to use the default gateway192.168.0.1. You could use something like:This way you’ll have a 2 gateways, but only 1 is the default. This second one is only used for 192.168.2.0 network.