2nd default gateway
Hi All,
I have Linux machine with 2 ethernet cards in different segments. Like 10.2.1.1 and 192.168.1.1 Do i need 2 default gateways in routing table? Please, give me an example when it may happen.
Zaphod
thanks in advance
Quoted 7 lines · Gery
Hi All,
I have Linux machine with 2 ethernet cards in different segments. Like 10.2.1.1 and 192.168.1.1
Do i need 2 default gateways in routing table? Please, give me an example when it may happen.
To my understanding no, that won't work since the default gw is a match anything solution. Thus if you put two default gws into your routing table the second one will never be looked at (if sorting stays the same).
HTH
Carsten
No, you cannot have two default gateways. Your default gateway is the interface and next hop address you use to get to any net you do not have a explicit routing table entry for. What you will do depends on your exact network layout. For instance, probably the most common case for having two networks in linux is when acting as a gateway for a local subnet. In that case you will have routes to two networks and one default gateway.
[root@localhost ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.100.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1 10.1.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 0.0.0.0 10.1.1.1 0.0.0.0 UG 0 0 0 eth0
[root@localhost ~]#
In this case, I am acting as the gateway for the 192.168.100.0/24 subnet. I also have the 10.1.1.0/24 subnet, which is my route to the larger world. My next hop to the rest of the world (in this case, my default gateway) is 10.1.1.1.
That is just one possible use case. Yours may differ. If we had more information about your particular case we may be able to help a little more.
-Philip
Quoted 14 lines · Gery
Hi All,
I have Linux machine with 2 ethernet cards in different segments. Like 10.2.1.1 and 192.168.1.1
Do i need 2 default gateways in routing table? Please, give me an example when it may happen.Zaphod
thanks in advance
--
To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html