The code I'm working on manipulates routing tables on three different platforms: Linux, Windows and Solaris. Each of them has a different behavior for different scenarios. Here I attempt to document those differences.
First some definitions:
- Interface A device which can directly reach a subnet via ARP or other protocols. An example is
- Direct route A route which indicates which Interface to use to reach a directly connected subnet.
- Gateway route A route which indicates a gateway to use to reach a subnet which is connected via a router.
- Default route A special case of a Gateway route in which the destination subnet is all possible addresses.
- Host route A special case of any of either a Direct route or a Gateway route in which the destination is a single machine.
- Multicast route A special case of a Direct route in which the destination subnet is the multicast address space,
184.108.40.206/8or a subset thereof.
Note that example route entries in this table is based on the format emitted from Linux's
|Linux 2.6||Windows 2003||Solaris 10|
|The interface chosen to access a gateway via a route is determined by traversing the route table, not hardcoded into the route entry.|
|A Gateway route which is also a Host route can be added where the destination is an address that exists in a subnet of another Direct route.|
For instance, the route
|A Direct route which is also a Host route can be added where the destination is an address that exists in a subnet of another Direct route.|
For instance, the route
|Direct routes can be deleted.||yes||yes3||yes|
|Route priority can be programmatically controlled.||yes||yes||no4|
|When an interface is administratively taken down, do the associated Direct route entries disappear?||yes||yes||yes|
|When an interface is administratively taken down, and associated Direct route entries disappear, do they return when the interface is brought up again?||yes||yes||yes|
|When an interface is administratively taken down, do the associated Gateway route entries disappear?||yes||yes||yes|
|When an interface is administratively taken down, and associated Gateway route entries disappear, do they return when the interface is brought up again?||no||yes||no|
|When an interface is administratively down, is it an error to add a route that references that interface?||yes||yes||yes|
|When an interface is unplugged, do the associated route entries disappear?||no||yes||no|
|When an interface is unplugged, and associated route entries disappear, do they return when the interface is plugged in again?||N/A||yes||N/A|
|When an interface is unplugged, is it an error to add a route that references that interface?||no||yes5||no|
|When an interface is unplugged, and associated route entries do not disappear, will an alternate route be chosen because the interface is unplugged?||no||N/A||no|
|If two interfaces are connected to the same subnet, will ARPrespond on either interface for an address on one of the interfaces?||yes||no||no|
|Can routes be modified for all attributes including priority? An answer of no means they must be destroyed and recreated to modify attributes.||no||yes||no|
|Does the operating system create Multicast routes by default?||no||yes||no|
|Can multicast routes be deleted?||yes||yes3||yes|
|If Multicast routes do not exist, do multicast packets exit the machine? To where?||yes6||no||no|
|Can two routes be created with the same destination and priority, but a different interface?||no||yes||yes7|
|Can a Gateway route be specified with an interface, where that interface does not have a Direct route for the gateway in the Gateway route?||no8||yes9||no8|
|When you remove a Direct route which is required by a Gateway route to reach the gateway, does the Gateway route disappear?||no||no||no|
|If you specify a Gateway route with a gateway that is not reachable via a Direct route, is this allowed?||no||yes10||no|
1 This configuration is possible if the route entry is set for this behavior. The route entry can also be configured for a specific interface.
2 When a ping is performed on the destination address, it is sent to the gateway, not via the direct route; this is what should be expected by following the rules in reading a route table. However, the gateway in my test was a Linux 2.6 machine, and it rejected the ping with an ICMP of "unreachable." This means such a configuration is possible, but useless.
3 One cannot directly delete a default route or other "protected" routes, but there is a way to fool Windows into deleting it. I found this fascinating discussion
4 The metric attribute cannot be set for a route in Solaris.
5 The error that's returned is
ERROR_INVALID_PARAMETER. That doesn't differentiate this condition from other problems.
6 It appears to choose the first available interface.
7 This question is partly irrelevant in Solaris; the priority or metric cannot be set for a route. However, you can create two routes with the same destination but different interfaces.
8 It works even if the Direct route is on another interface, but it must exist.
9 You can set the route, but it doesn't do anything.
10 This strange behavior is apparently allowed; the source address that's used is the address on the interface that is preferred for the Default gateway.