I have an overly complicated developer network setup with Ethernet, WLAN and VPN.

I can connect to certain server but I need to know which actual network device / router was used to make the connection. Depending on which network is used certain ports might be blocked and I have a suspicion the connection isn't going the way it should.

I use macOS but I'm fine terminal commands and have most of the gnu tools installed via MacPorts.

  • On Windows this is done with tracert <destination name or IP>. You'll be shown the address of every router along the route. Not sure what the equivalent is on MacOS. – Twisty Impersonator Nov 19 '18 at 10:59
  • Does macOS by chance have route -4 get <ip> / route -6 get <ip> (as in FreeBSD)? – grawity Nov 19 '18 at 11:30

You can use route get to find out which interface and gateway on the local computer is used according to the local routing rules. The -4 and -6 options as on BSD don't work, but the -n option for numerical output does work.

You can also use traceroute to find out the intermediate routers on the path (with the usual caveats when doing a traceroute).

Edit stands of course for the IP address you want to reach, it needn't be literally

  • 1
    Or in the case of an internal routing issue, substitute with the IP of your internal target host. – Twisty Impersonator Nov 19 '18 at 12:51
  • Thanks. route get gave me the output i needed and was able to fix the problem, – Martin Nov 19 '18 at 16:16
  • alternative to traceroute => mtr – Hannu Nov 19 '18 at 17:12

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.