0

How does iproute2 select the source IP address for an outgoing connection when there are multiple interfaces, and there is a routing policy with a "from" rule?

Here is what I understand to happen without policy based routing:

  • An application initiates a connection to address A.B.C.D.
  • The system looks at the routing table to find the route to A.B.C.D.
    • When A.B.C.D is part of a connected network, the source address will be the address of the interface to that network.
    • When there is a route to the destination, the source address will be the address of the interface identified by the route.
    • When there is no specific route, the source address will be the address of the interface identified in the default route.

But what happens if I have a policy rule that specifies a specific routing table based on the source IP address (eg: ip rule add from M.N.O.P lookup mnop_table)?

There is no source IP address for a new connection. Thus the default routing table has to be used. Therefore,

  • the source IP address will be from the interface specified in the default route of the default routing table.
  • alas, the "from" rule has no impact on new connections.

Is this correct?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.