I'm able to obtain outbound IP/port list using

netstat -atn | tr -s ' '| cut -f5 -d ' ' | grep -v ''

My system has multiple IPs over two physical interfaces:


Is there a way to specify which interface traffic (including "nested" configs such as "em:2") is going out over?

Before downvoting, please provide me with an opportunity to help clarify my submission.

  • Look at ip route and ip addr - this should be enough information to figure it out, usually one of your two IFs for local traffic, and the other one for everything else. If you have difficult routing tables for some reason, ip route get a.b.c.d will tell you the interface. – dirkt Jun 28 '17 at 14:38
  • Could you clarify what you mean with ip route get a.b.c.d? What input does a.b.c.d. represent? – a coder Jun 28 '17 at 14:53
  • Also will ip route show virtual interfaces like em1:2 or is it only going to list the physical cards? I'm only seeing em1 and em2 but I am unsure if it's taking into account the virtual interfaces. – a coder Jun 28 '17 at 15:00
  • a.b.c.d is the IP address for which you want to find the IF. Virtual interfaces are just the old kernel way of assigning multiple IPv4 addresses to an IF, that's why the newer ip addr doesn't show them. – dirkt Jun 28 '17 at 15:56
  • Thanks, the ip route get a.b.c.d command shows the interface (along with interface IP address). Helps debug a network issue I'm having. If you'll add that as an answer I'll hook you up. – a coder Jun 28 '17 at 17:17

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.