Can a multihomed Linux machine implement a true Strong ES Model?
Specific Use Case
I have a system with five different interfaces, each connected to the same subnet, thus the same gateway to the Internet.
- I would like to listen on each interface separately on the same port, and ensure that packets always go out the same interface they came in, and ensure that packets trying to come in the "wrong" interface are discarded.
- I would like to be able to bind to each interface and make outgoing connections to Internet destinations that always originate from the same source IP I bound to. For example,
curl --interface interface_ip http://ipecho.net/plain
should always show the same IP address I bound to with--interface
. - Static routes may be problematic due to using DHCP on one of these interfaces.
RFC 1122
From RFC 1122 - Requirements for Internet Hosts - Communication Layers, Section 3.3.4.2 – Multihoming Requirements:
Internet host implementors have used two different conceptual models for multihoming, briefly summarized in the following discussion. This document takes no stand on which model is preferred; each seems to have a place. This ambivalence is reflected in the issues (A) and (B) being optional.
Strong ES Model
The Strong ES (End System, i.e., host) model emphasizes the host/gateway (ES/IS) distinction, and would therefore substitute MUST for MAY in issues (A) and (B) above. It tends to model a multihomed host as a set of logical hosts within the same physical host.
With respect to (A), proponents of the Strong ES model note that automatic Internet routing mechanisms could not route a datagram to a physical interface that did not correspond to the destination address.
Under the Strong ES model, the route computation for an outgoing datagram is the mapping:route(src IP addr, dest IP addr, TOS) -> gateway
Here the source address is included as a parameter in order to select a gateway that is directly reachable on the corresponding physical interface. Note that this model logically requires that in general there be at least one default gateway, and preferably multiple defaults, for each IP source address.
Weak ES Model
This view de-emphasizes the ES/IS distinction, and would therefore substitute MUST NOT for MAY in issues (A) and (B). This model may be the more natural one for hosts that wiretap gateway routing protocols, and is necessary for hosts that have embedded gateway functionality.
The Weak ES Model may cause the Redirect mechanism to fail. If a datagram is sent out a physical interface that does not correspond to the destination address, the first-hop gateway will not realize when it needs to send a Redirect. On the other hand, if the host has embedded gateway functionality, then it has routing information without listening to Redirects.
In the Weak ES model, the route computation for an outgoing datagram is the mapping:route(dest IP addr, TOS) -> gateway, interface
Linux is a Weak ES model by default, whereas FreeBSD and other Unix varieties act as Strong ES systems. Is there any way to make it behave more like a Strong ES system?
What sysctl
or compile-time config would need to be set to make it behave like a Strong ES by default, without adding specific routing rules for any new interface you add? I know we can do strict source-route filtering via net.ipv4.conf.default.rp_filter = 1
, but there seems to be much more to it than that. How can I do Source-Based Routing by default?