[En-Nut-Discussion] Problem with DHCP

Hugo Simon hugo.simon at gmx.de
Thu Dec 8 18:22:40 CET 2005


>   Since my network has no DHCP server, I´m running the DHCP server
>from Tftpd by Ph. Jounin. I can see in the log window that the board
>does requests an address ( Rcvd DHCP Rqst Msg for IP 0.0.0.0, MAC
>00:50:C2:4B:50:03 (07/12 16:16:44.093) ), but the device doesn´t get
>any address from the pool, instead, it uses the last configured
>address.

I don't exactly see why your routine isn't working correctly, but I think
you think too complicated. I did it this way:

  /* first try it completely from EEPROM/DHCP */
  if (NutDhcpIfConfig("eth0", 0, 20000))
  {
    /* oops, maybe we didn't have a configured MAC, so try a default one */
    if (NutDhcpIfConfig("eth0", mac, 20000))
    {
      /* again oops, looks like there is something wrong with the
configuration
         so use default settings */
      DEBUG_PRINTF_P(PSTR(" DHCP failed, using default settings\n"));
      NutNetIfConfig2("eth0", mac, ip_addr, ip_mask, ip_gate);
    }
  }

NutDhcpIfConfig already loads the settings from EEPROM if there is any. If
there is a configured IP in confnet.cdn_cip_addr other than 0.0.0.0 it uses
this one, otherwise it tries DHCP. If that fails too, it returns an error.
In that case a default config is used.

If you like I have some web based configuration routines where the user can
configure the network settings via browser. If you are interested contact me
personally.

Hope it helps.
Bye
Thorsten





More information about the En-Nut-Discussion mailing list