That breaks if there's any NAT between the client and the gateway. Consider this technique:
Note the use of a fake UDP connection (no actual packets sent) to coerce the OS to expose the source interface and IP selected for the route to the Ignition Gateway.