Question: Short:  

I want DHCP server to assign a preconfigured IP address based on a port (on a switch, ideally) a device is connected to.

Long: 

My situation:  

I am building an automated indoor farm (for growing tomatoes). The farm is composed of many (12 for now, but will grow to hundreds) identical 7"x7" rooms. Each room will have an Ethernet port, and into this port an environment control system will be plugged in. Note that each room needs to be controlled individually.

Rooms are arranged in rows of 12, so I was thinking I will have a switch per row, and connect these switches to a router.

I could program each environmental controller with a static IP, so that I can associate a controller to a particular room on the server, but I think it would be easier if I could assign an IP address to each room, which would also make controllers interchangeable and hot swap-able with no need for manual configuration.

InB4: I am also considering using ZigBee network for this application, but I may need to transmit diagnostic images, and with hundreds of units ZigBee may be inadequate.

**Question:** is it possible to assign a preconfigured IP address based on a port a device is connected to? What devices do I need for this?

Answer: 
I was able to do what you wanted using Cisco IOS DHCP and option 82 snooping. I may not be using the right terms. But, basically I needed to assign IP addresses to kitchen printers based on the station in the kitchen they were at. If one of these printers died during a dinner shift, the store manager would need to be able to put a new printer configured with DHCP in and have it be configured with the same address as the printer removed. I also needed all 8 printers to be in the same broadcast domain and I could not use helper to send to a windows 2012 server as the store needed to continue to work even if my wan went down.

I did this with the following command on each switch port:
`ip dhcp snooping vlan 3 information option format-type circuit-id override string broil` (or whatever is relevant to you)

Use an ASCII to hex converter and convert your string to hex

Then on the DHCP server be it a switch or a router set up a DHCP class. For my broil above it is this

```
ip dhcp class broil
   relay agent information
      relay-information hex 010562726f696c*

```

it is `010 <number of characters in your string so 5 since broil is 5 characters><whatever your string converts to>`

Here is how my pool is set up.

```
ip dhcp pool Kitchen
 network 10.102.1.0 255.255.255.0   
 default-router 10.102.1.1
 lease infinite
 class broil
 address range 10.102.1.160 10.102.1.160

```

And finally in order to make this address available to another device should the one in that switch port fail, I set up a kron job to issue `clear ip dhcp bind *` every 5 minutes.

I believe for ALL of this to work I needed the following additional commands on my ios switch that is my dhcp server

```
ip dhcp relay information trust-all ip dhcp subscriber-id
interface-name

ip dhcp snooping vlan 3 (our vlan of course) ip dhcp snooping
information option allow-untrusted ip dhcp snooping

```

and on any port linking your DHCP server switch to any other switches that may be used for this (along with that switches uplink to your DHCP server switch)

```
ip dhcp snooping trust

```

Thats basically it. Works like a charm and FINALLY allowed us to get off of IP to serial printing which was a train wreck.
If you want "hot swappable," the device names will have to be independent of their location. You'll need to keep track of device MAC addresses on a chart with an easy corresponding Minion name like "Bob." Then configure the device with that name or description "Bob." This way when network monitoring reports issues only the description or name matters to check the chart. You just have to keep track on the chart where you put the devices.

Switches are more concerned with physical addresses than ip addresses. However, each floor could use its own vlan with its own dhcp server. Then you can create a named vlan for each floor like "grow\_rooms\_1-12" with /28 subnet mask. You can also give each port a description like "to grow room 1." These are great management aids if you are watching your network via command line.

You can also alter size of rooms to improve efficiency of lighting, humidity, and temperature which could also reduce monitoring devices.