Linux – Multiple default gateways on the same interface

gatewayiplinuxnetworking

Is it valid to have multiple default gateways associated with the same interface. I thought that didn't make sense, but I'm seeing this on my laptop

$ route
Kernel IP routing table                                                                                                              
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.1.0.0        *               255.255.248.0   U     1      0        0 eth0
default         10.1.1.1        0.0.0.0         UG    0      0        0 eth0
default         10.1.1.1        0.0.0.0         UG    202    0        0 eth0

The reason I ask is that in an embedded system we're developing for, we need to get the default gateway associated with a particular interface. Is this just a display issue where it's showing the same default gateway twice? Or does having multiple default gateways on 1 interface mean something that I should have to take into account.

Best Answer

It's not really valid to have multiple default gateways on the same machine let alone on a single interface. Sure there's some tiny edge cases where it might help but I've never come across any that jump to mind. You generally have a default then statics to anything outside that.