Just a shot in the dark here, but I thought I'd ask in case anyone has some ideas:

I've got a testing scenario where some (GUI-less/embedded) IPv6 devices are going to be temporarily plugged into the ports of a managed Ethernet switch, and a control program (running on a separate Linux PC, also connected to the switch) will detect when one of these devices appears on the LAN, and automatically run a test to make sure the device is working correctly.

There will typically be a dozen or so of these devices connected at once (so we can run tests in parallel), and devices will be connected and disconnected on a regular basis by people who don't necessarily know anything about networking; they only know how to plug in an Ethernet cable, then (some hours later) look at the PC's screen to see if the test passed or not.

The issue at hand how to indicate to the testing person when a particular device has failed a test. One option is for the error log/message to include the device's MAC address (derived from its link-local IPv6 address), and that might be sufficient in a pinch, but it would be much nicer if the testing program could also say something like "The device connected to port #5 isn't working right, have a look at that one". That way the tester can just follow the ethernet cable to faulty device, rather than having to figure out what each device's MAC address is until he/she finds the matching one.

I don't think that it's possible for the Linux computer to tell which switch port a particular device is connected to (let me know if I'm wrong about that). But assuming that's the case, the next best thing would be if I could program the switch to do MAC address translations, e.g. so that any device that is plugged in to port #n always appears (to the Linux computer) as if it has MAC address foo:bar:baz:n, and therefore shows up as IPv6 address fe80::2foo:bar:baz:n. If the switch did MAC address translation like that, then the control software could determine which port the device was connected to simply by looking at the last section of the fake MAC address.

So my question is, is this behavior something that any managed Ethernet switches support? If so, what is this feature called (so I can find a switch that does it)? If not, is there a better approach to this problem that I should be looking at instead?

  • To be a hundred percent sure of the ipv6 address -> mac address translation, query it from the ipv6 neighbour table (ip -6 neigh show fe80::2foo:bar:baz:n). – Koos van den Hout Mar 9 '12 at 10:28
  • @Koos are there actual known cases where the translation might not follow the prescribed pattern, or is your suggestion more of a on-general-principles kind of thing? – Jeremy Friesner Mar 10 '12 at 0:31
  • It's the on-general-principles kind of thing, the link-local address in ipv6 is indeed always derived from the interface identifier (mac address in case of ethernet). – Koos van den Hout Apr 18 '12 at 10:52

I've never heard of a switch that can translate a MAC address. What most good managed switches will let you do, however, is query the bridge table via SNMP: dot1dBridge.dot1dTpFdbTable in the standard Bridge MIB looks like the way to go. You'll need to convert the MAC address to decimal and append it to the MIB prefix, and it'll spit out the port it learned it on. There's some added trickery if you need to deal with VLANs.

http://wiki.xdroop.com/space/snmp/Switching+Tables has an example.

| improve this answer | |
  • Indeed, every decent managed switch will let you query this via SNMP. – devicenull Mar 9 '12 at 1:54
  • Indeed, a switch needs to have this table (mac -> port) somewhere to function as a switch, and you need snmp access to dot1dTpFdbPort (mac -> interface) and dot1dBasePortIfIndex (interfacenumber -> name). – Koos van den Hout Mar 9 '12 at 10:26
  • Indeed, I think this is way to go. For the record, I found a non-SNMP way to get this same information also. On my NetGear GS724T switch, at least, I can telnet to port 60000 of the switch and enter the following sequence of commands: "admin", (enter admin password), "enable", (press return to input empty enable-password), "show mac-addr-table", and the switch prints out the MAC address table in response. Good enough for me :) – Jeremy Friesner Mar 10 '12 at 0:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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