9

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?

  • 1
    You could do something like a VLAN per port, and assign a /30 or /31 to each VLAN, but are you sure you need to use IPs to identify devices? Does the application you use to read name the devices in some way? My gut feeling is there must be a better way to accomplish this. – Ron Trunk Jan 9 '15 at 21:21
  • I only interested in the physical location of the unit, each individual controller has no meaningful identity. If controller, for example, burns out - I want to be able to replace it with a brand new one, without having to go into devices settings and configure static IP or location. – THX-1138 Jan 9 '15 at 21:56
12

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.

  • 1
    There's also option-82 for an external DHCP server, but that's a lot more work and more a "server" question. – Ricky Beam Jan 10 '15 at 0:09
2

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.

-1

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.

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.