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: 
> 
> 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?
> 
> 
> 

You can use a Cisco switch and an IOS that supports [DHCP Server Port-Based Address Allocation](http://www.cisco.com/en/US/docs/switches/lan/catalyst2960/software/release/12.2_55_se/configuration/guide/swdhcp82.html#wp1320905) on your switch; you also must issue DHCP from your switch. Assume that you have got `Fa0/1` and `Fa0/2` in Vlan120.

```
ip dhcp use subscriber-id client-id
ip dhcp subscriber-id interface-name
ip dhcp excluded-address 192.0.2.1 192.0.2.10
!
ip dhcp pool VLAN120
   network 192.0.2.0 255.255.255.0
   default-router 192.0.2.1
   dns-server 192.0.2.5
   reserved-only
   address 192.0.2.101 client-id "Fa0/1" ascii
   address 192.0.2.102 client-id "Fa0/2" ascii

```

This configuration reserves addresses for fa0/1 and fa0/2. The same address will always be assigned to those ports.
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.