DHCP Server with Arduino v0.01

This library implements DHCP server you can run on Arduino. While there are several libraries mentioned in Arduino forums (most notably DHCP_Web_Server_12.pde, DHCP with DNS, and Nebster's DHCP server code from this Arduino forum thread), some used UDP libraries I could not use and some I simply could not get to work. The code is based on Nebster's DHCP code, but has been re-written and tested with the RedFly shield and various clients.

This library should be used when you have your Arduino running an ad-hoc (IBSS) network and want to assign IP addresses to other devices that connect to the same network. The usage is simple (v0.01 syntax; v0.03 added one more parameter):

#include <RedFly.h>
  uint8_t buf[590];
  byte serverIP[]  = { 192, 168, 2, 1 }; 
  buf_len = DHCPreply((RIP_MSG*)buf, buf_len, serverIP);

The library does not fully implements the spec as it only handles DHCP Request and DHCP Discover messages and returns DHCP NAK to DHCP Inform messages. It correctly assigns IP addresses to clients running Windows Vista, Ubuntu 11.04, and iOS 4 running on iPod. However, the library does not work for clients running iOS 2 on iPhone and Snow Leopard v10.6.8 on MacBook Pro. The library responds with a DHCP Discover message, but it doesn't seem to be recognized by the client and the DHCP Request message never follows. If you know how to fix this, send me an email.

The library is available here.

Leave a comment

what will you say?