How to find out which network device is used to reach a given server

1

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.

Martin

Posted 2018-11-19T10:24:12.360

Reputation: 305

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. – I say Reinstate Monica – 2018-11-19T10:59:02.953

Does macOS by chance have route -4 get <ip> / route -6 get <ip> (as in FreeBSD)? – user1686 – 2018-11-19T11:30:06.573

Answers

3

You can use route get 8.8.8.8 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 8.8.8.8 to find out the intermediate routers on the path (with the usual caveats when doing a traceroute).

Edit

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

dirkt

Posted 2018-11-19T10:24:12.360

Reputation: 11 627

1Or in the case of an internal routing issue, substitute 8.8.8.8 with the IP of your internal target host. – I say Reinstate Monica – 2018-11-19T12:51:46.473

Thanks. route get gave me the output i needed and was able to fix the problem, – Martin – 2018-11-19T16:16:45.250

alternative to traceroute => mtr – Hannu – 2018-11-19T17:12:41.767