Assigning an IP Address Based on Switch Port

ciscodhcpethernetrouterswitch

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?

Best 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 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.