Skip to content

ESP8266 WiFi Client does not honor DHCP host-name option setting when using DHCP #5695

Closed
@dachshund-digital

Description

@dachshund-digital

Basic Infos

  • This issue complies with the issue POLICY doc.
  • [ x I have read the documentation at readthedocs and the issue is not addressed there.
  • I have tested that the issue is present in current master branch (aka latest git).
  • I have searched the issue tracker for a similar issue.
  • If there is a stack dump, I have decoded it.
  • I have filled out all fields below.

Platform

  • Hardware: ModeMCU v3 LoLin Wemos.cc ESP8266
  • Core Version: ESP8266 WiFi 2.5.0-beta3
  • Development Env: Arduino IDE
  • Operating System: Windows 10

Settings in IDE

  • Module: Nodemcu
  • Flash Mode: other
  • Flash Size: 4MB
  • lwip Variant: v2
  • Reset Method: nodemcu
  • Flash Frequency: 40Mhz
  • CPU Frequency: 80Mhz
  • Upload Using: SERIAL
  • Upload Speed: 115200

Problem Description

Detailed problem description goes here.
DHCP ip address acquired by device as expected with WiFi configuration. However DHCP host-name option is not honored, the automatic host name is reported by the WiFi.hostname() call, not the name assigned in the DHCP reservation on DHCP server for said MAC address of device.


DHCP Reservation Example... Note the host-name option value of "Node01"

#--------------------
# NodeMCU...
#--------------------

host Node01 {
        hardware ethernet 68:C6:3A:D6:59:C7;
        fixed-address 192.168.1.50;
        option host-name "Node01";
}

#include <ESP8266WiFi.h>

CONST int   BAUDRATE = 115200;
CONST int   HALFSECOND = 500;
CONST char* DESCRIPTOR = "Dachshund Digital_optout_nomap";
CONST char* PASSPHRASE = "D@chshund Digit@1";

//
struct InformationStructure {
  //

  String    theMediaAccessControl;
  String    theNetwork;
  String    theKey;
  String    theId;
  IPAddress theIP;
  String    theName;
  int       theStrength;
};

void setup() {
  struct InformationStructure theInformation;

  Serial.begin(BAUDRATE);
  while (!Serial);
  //Serial.setDebugOutput(false);

  // WiFi Initialization...
  Serial.println("WiFi Initialization");

  WiFi.mode(WIFI_STA);
  WiFi.begin(DESCRIPTOR, PASSPHRASE);

  // WiFi Connection...
  Serial.print("WiFi Connection");
  
  while (WiFi.status() != WL_CONNECTED) {
    
    // WiFi Connection Wait...
    delay(HALFSECOND);
    Serial.print(".");
  }              
  
  //
  theInformation.theMediaAccessControl = WiFi.macAddress();
  theInformation.theName = WiFi.hostname();
              theInformation.theKey = WiFi.psk();
              theInformation.theId = WiFi.BSSIDstr();
              theInformation.theStrength = WiFi.RSSI();
              theInformation.theIP = WiFi.localIP();
              theInformation.theNetwork = WiFi.SSID();
              
              Serial.printf("NodeMCU (ESP8266) Web Server<br>Media Access Control %s\nHost Name %s\nKey \'%s'\\nBasic Service Set Id %s\nSignal Strength %d (dBm)\nIP Address %s\nNetwork \'%s\'\n",
                theInformation.theMediaAccessControl.c_str(), theInformation.theName.c_str(), theInformation.theKey.c_str(), theInformation.theId.c_str(), theInformation.theStrength, theInformation.theIP.toString().c_str(), theInformation.theNetwork.c_str());
              
// Host name is auto generated, DHCP option value appears to be ignored.  Host name from DHCP should be 'Node01' not ESP_D659C7.

}

void loop() {

}

Debug Messages

SDK:3.0.0-dev(c0f7b44)/Core:2.5.0-beta2=20499902/lwIP:STABLE-2_1_2_RELEASE/glue:1.0-4-gc434c6f/BearSSL:2398cc6
WiFi Initialization
scandone
WiFi Connectionscandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 2
cnt 

connected with xxx channel 2
dhcp client start...
ip:192.168.1.50,mask:255.255.255.0,gw:192.168.1.251
.NodeMCU (ESP8266) Web Server<br>Media Access Control 68:C6:3A:D6:59:C7
Host Name ESP_D659C7
Key 'xxx'\nBasic Service Set Id C8:D7:19:0F:4C:6F
Signal Strength -41 (dBm)
IP Address 192.168.1.50
Network 'Dachshund Digital_optout_nomap'
pm open,type:2 0

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions