I'm looking for an affordable 5-port switch that can help me figure out the IP addresses corresponding to each port. I need to access this data via Python or command line. I've heard from someone that SNMP could be a solution, but I'm unsure which switch would support that and if it would actually meet my needs.
For a bit of context: I have two identical smart devices (let's refer to them as cameras for this example) positioned as left and right in my test area. Our software must differentiate between which camera is which. I want to avoid hardcoding their MAC addresses or relying on a complex pairing process. Ideally, it would be most straightforward for our technicians to simply plug the left camera into the leftmost port and the right camera into the right one.
11 Answers
Most managed switches should fulfill your needs; you'll want to focus on the MAC table for visibility. Just keep in mind that finding a 5-port switch with this capability might be a challenge, so larger models could be a better fit.
If you have SSH access to the switch, using the Ansible Python library could simplify your monitoring and management of the devices connected to each port.
It seems possible to do, but it might not be practical. Your strategy could tie you down to a specific type of switch and firmware. Instead, consider using MAC addresses, IPs, or hostnames for managing device registrations, which would provide more flexibility in the long run.
Cisco switches can be configured to assign DHCP based on the port where the request originates. The left camera can always get the same IP, ensuring consistency for your setup.
Correct! The main issue lies at Layer 7. You might want to label MAC addresses directly within your software based on the camera's detected MAC.
Consider assigning each port to a different VLAN and subnet. This way, the IP address would make it easier to identify which port a device is connected to, simplifying device identification in your application. Look for a managed switch that supports multiple VLANs.
Thanks for the suggestions everyone! Here's a bit more detail: I need to identify two identical smart cameras placed in specific positions and avoid hardcoding MAC addresses. I also want a straightforward setup for techs without complicating the UI too much.
How do you plan to detect these cameras—it could help clarify things.
To streamline your process, ensure your software can identify which MAC addresses to expect on each port. As these cameras will be on the same broadcast network, you should be good.
You might want to check out ARP tables or utilize Link Layer Discovery Protocol (LLDP) for this.
If you're using Unifi and have access to their controller, you might find it easier to manage device connections and settings that way.
Standard switches don’t track IP addresses, as they operate at the MAC address level. To achieve what you want, consider using a Layer 3 switch or querying the upstream Layer 3 device for the MAC address and checking the switch for what port it’s on. Just a heads up, this may be overcomplicating the situation—what exactly are you trying to accomplish?
That’s a solid point. It sounds a bit off-kilter as a strategy.
Thanks for the insight! I've added more context to my original post.
Using hostnames and DHCP reservations could be a smarter approach to differentiate the IPs, especially if you plan on changing the devices frequently without having to reassign everything manually.

Absolutely, remember that switches primarily deal with L2, so IP tracking requires some additional steps.