How do you check if you're connected to a network switch?

1

Is there any way to tell if the computer you are currently working on is connected to a switch (edit: before it goes to a router and the internet)? Preferable on Linux, but I'm interested in answers for Mac and Windows as well.

Of course tracing the cable doesn't count.

Jason Axelson

Posted 2009-10-17T23:18:42.080

Reputation: 1 390

Is this just for curiosity's sake or are you trying to answer another question? – Stephen Jennings – 2009-10-17T23:51:01.187

Mostly for curiosities sake. I just recently learning how find a MAC address by IP (arp -a) and now I'm wondering if it can be applied to switches as well. – Jason Axelson – 2009-10-17T23:57:51.797

Answers

2

You could open Wireshark and look for any network activity. This will work on Linux, Windows and Mac.

sblair

Posted 2009-10-17T23:18:42.080

Reputation: 12 231

I may not have been clear enough in my original question so I've clarified it a bit. I've used Wireshark before and I'm not sure how it would help me see if I'm connected to a switch before the router (and eventually the internet at large). – Jason Axelson – 2009-10-17T23:42:19.240

1If you see traffic not from or to the computer you're running Wireshark on, then you're connected to a hub. If you don't, then you're either alone on your subnet, nobody else is sending data, or you're connected to a switch. – Stephen Jennings – 2009-10-17T23:46:47.360

Ah, in that case - if it's a managed switch - you could perhaps try to throw some SNMP at it (e.g., with net-snmp). However, this requires knowing the switch's IP address, so it's probably not very useful... However, if you know the router's IP, you could perhaps ping it with a time-to-live (hop-limit) of 1; if there's no reply then there may be a switch in the "middle". I've not tested this, so it may not work! – sblair – 2009-10-17T23:58:34.433

Correct me if I'm wrong, but I think that using Wireshark you wouldn't see any extra traffic if you are connected to a switch that is connected to a router and if you connect directly to a router. Is that correct? – Jason Axelson – 2009-10-17T23:59:22.967

You might see some "maintenance" messages sent from the switch, such as messages for the spanning tree protocol. But it would obviously depend on the switch. – sblair – 2009-10-18T00:17:38.123

0

On the command line

ip l

shows something like

2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
    link/ether 00:19:db:ba:76:37 brd ff:ff:ff:ff:ff:ff

where NO-CARRIER indicates detachment from the switch.

artistoex

Posted 2009-10-17T23:18:42.080

Reputation: 3 353