1

Similar (but different) question: Assign an IP address based on switch port

I regularly need to test our hardware products. Usually that consists of having ~50 devices sitting on a bench for some time from 1 day to 14 days. Often we have a wifi connection to the device, so we use this comms channel to manage testing. Each time I do this testing I have to do some kind of bringup (e.g. onboarding onto the wifi network) to be able to talk to each device and manage the testing. This can be cumbersome and time consuming.

Would a router allow me to set the host IP on each port to a pre-determined IP? This would allow me to plug a device into a port and know how to address it without any additional bringup.

I know that switches have a lot more functionality than they used to - is a switch potentially a cheaper option?

3
  • Welcome. You could consider 64 ports of switch, each configured as an access port on a different VLAN with DHCP on a trunk with DHCP per VLAN with short leases. port 1 = VLAN 1 = 10.0.1.X/24. Would that solve it? – jonathanjo Sep 28 '18 at 13:02
  • Can you tell us a little more about the devices you're testing? Do they have any kind of console interface? Do they have serial numbers, perhaps with a barcode label? – jonathanjo Sep 28 '18 at 17:03
  • Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you can provide and accept your own answer. – Ron Maupin Dec 25 '18 at 9:32
1

There are a few approaches.

Likely the cheapest approach is to get a basic "smart switch" that supports VLANs and put each port on a seperate VLAN. Then run a "trunk" carrying all the VLANS back to a Linux box (even a raspberry pi will do if the traffic is not heavy) which can act as a router and DHCP server for all the VLANs. You may need to hack up a DHCP server though to make it ignore the normal lease mechanics and immediately assign the relavent IP for each VLAN.

If you don't want to go through the hassle of doing that then the port-based DHCP features mentioned in answers to the other question are probablly the easiest option, but you will likely need to spend quite a bit more on a switch to get those features.

4
  • Should be able to use a standard DHCP server of any kind with a small lease and a small range (ie, only one address per VLAN). Might need to have an unusually large number of secondary addresses on the testing host or router (ie, one per VLAN). – jonathanjo Sep 28 '18 at 15:52
  • My concern with the leases would be can you make the lease short enough that it doesn't cause problems for someone switching devices while long enough that it doesn't cause other problems (how well do clients handle very short leases....). I don't think 50 odd VLAN interfaces each with it's own IP will be a problem for Linux though you probablly want to write a script to generate the config. – Peter Green Sep 28 '18 at 15:59
  • ...quite agree. I understand the poster is the manufacturer of the devices, so hopefully they can ensure they behave well with short leases; I was imagining 1 minute or so; or somehow explicitly cancel the lease on the DHCP server. For this kind of automated testing I wrote a simple "idiot DHCP server" which is very much along the lines of your suggestion; probably off-topic here. – jonathanjo Sep 28 '18 at 16:10
  • With a dedicated DHCP setup like this, it might be useful to configure a very short lease time (a few minutes or so, depending on the swap cycle) and a pool with only a single IP address, so that any device connected always gets the same IP. – Zac67 Sep 29 '18 at 7:33

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.