Troubleshoot Linux Traffic Leaving Through the Wrong Interface
Before you begin
- Applies to:Linux hosts with multiple network interfaces or routes. The worked examples use IPv4.
- Where to start:Open a shell on the affected host. If the application uses a separate network namespace, check routing from that namespace.
- What you need:Have the intended destination IP, source IP, and interface from the network design. Replace the sample addresses with the approved values for your environment.
Guide tools
Troubleshooting Steps
Record the exact failed connection
Start hereCapture the destination address, protocol, port, and expected source interface. If only hostname traffic fails, first compare the application’s resolved address. A route to the wrong IP does not explain DNS selection.
Inspect the kernel's selected route
Read dev, via, and src where present. A route lookup shows the kernel’s choice for the supplied conditions and does not send traffic. Repeat with the source explicitly set when the application binds one.
What you should see · The route shows the expected output interface and source address. A directly connected route may have no gateway.
If you see something else · If the interface or source differs, go to Step 3 to check the matching rule and table. If both match, go to Step 4 and repeat the check in the application’s network context if it differs.
ip -4 route get 192.0.2.25ip -4 route get 192.0.2.25 from 198.51.100.10Inspect routing rules and tables
Review the matching rules in priority order and compare candidate routes in the relevant tables. A more specific prefix can beat a default route. Source rules can steer traffic into a different table. Metrics should be compared within the context of the selected table and matching prefix.
ip -4 address showip -4 rule showip -4 route show table allCompare with the application context
Check whether the application binds a different address or uses a network namespace, VRF, or a marked route. If outbound selection is correct but the connection still fails, have the network owner check return routing and firewall decisions. Compare the known-good flow and actual endpoints.
Fix the persistent configuration through its owner
Determine which manager owns the interface, such as Netplan or NetworkManager. Change only the incorrect route or rule through that manager in an approved window. Keep the prior profile and a tested recovery path. A manual route change can disappear when the interface reconnects.
Verify management and application paths
VerifyRepeat the precise route lookup and test the original service. Check that the management path still works and confirm persistence after an approved reconnect or restart. Restore the recorded profile if the updated route affects unrelated traffic.
Decide What to Do Next
| Finding | Next action |
|---|---|
| Unexpected table | Identify the matching rule and its source selector. |
| Expected outbound route but failing connection | Correlate return traffic and application logs. |
References
Your feedback keeps these production procedures accurate and battle-tested.