Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hostname not set for DISCOVER packets - DHCP client hostname not present on some routers #8247

Closed
5 of 6 tasks
ilium007 opened this issue Jul 27, 2021 · 14 comments
Closed
5 of 6 tasks

Comments

@ilium007
Copy link

Basic Infos

  • This issue complies with the issue POLICY doc.
  • 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: [other]
  • Core Version: [3.0.2]
  • Development Env: [Platformio]
  • Operating System: [MacOS]

Settings in IDE

  • Module: [Generic ESP8266 Module]
  • Flash Mode: [other]
  • Flash Size: [4MB]
  • lwip Variant: [v1.4]
  • Reset Method: [nodemcu]
  • Flash Frequency: [40Mhz]
  • CPU Frequency: [80Mhz]
  • Upload Using: [OTA]
  • Upload Speed: [115200|other] (serial upload only)

Problem Description

The hostname is not being set in the DISCOVER packet sent by the ESP8266. Some routers (Mikrotik definitely) reject the DHCP 'Option 12 - hostname' field in the REQUEST packet if it has not been sent in the DISCOVER packet previously.

This same issue has been fixed for the ESP32 in this commit: espressif/esp-lwip@13665c1

MCVE Sketch

N/A

Debug Messages

N/A

Detailed explanation and packet captures in this ESPHome issue: esphome/issues#2069 (comment)

@d-a-v
Copy link
Collaborator

d-a-v commented Jul 27, 2021

duplicate #8247 #8223 and d-a-v/esp82xx-nonos-linklayer#50 by @1e1

This will be addressed soon

@d-a-v d-a-v closed this as completed Jul 27, 2021
@1e1
Copy link

1e1 commented Jul 27, 2021

@ilium007 I've tested the fix on a Mikrotik router with a custom script like here:
https://forum.mikrotik.com/viewtopic.php?t=119469

@ilium007
Copy link
Author

Issue #8223 references "OPTION: 61 ( 7) Client-identifier" This issue I have raised is about OPTION 12 Hostname.

@ilium007
Copy link
Author

ilium007 commented Jul 27, 2021

@ilium007 I've tested the fix on a Mikrotik router with a custom script like here:
https://forum.mikrotik.com/viewtopic.php?t=119469

Edit: @1e1 I had been using the script from this thread to register the static DNS name but the issue I have is the missing hostname from the DISCOVER packet, the hostame is not available so this line doesn't work:

:local hostname [/ip dhcp-server lease get [:pick [find mac-address=$leaseActMAC and server=$leaseServerName] 0] value-name=host-name]

Yes, the scripts creates a static DNS entry in the form of a-b-c-d.domain but this is of no use to me.

@d-a-v
Copy link
Collaborator

d-a-v commented Jul 27, 2021

Different option, reopening

@d-a-v d-a-v reopened this Jul 27, 2021
@d-a-v d-a-v added this to the 3.1 milestone Jul 27, 2021
@1e1
Copy link

1e1 commented Jul 27, 2021

@d-a-v @ilium007
It fixes the hostname so ;)
=> https://github.com/d-a-v/esp82xx-nonos-linklayer/pull/50/files#diff-710fdb9ab0a46e9cdc5204551f23701152eba187976cd0f68950398ec334b2b8R41

What I get is what you see below (OPTION 12 & OPTION 51):

  TIME: 2021-07-24 17:54:36.163
    IP: 0.0.0.0 (b4:e6:2d:ZZ:ZZ:ZZ) > 255.255.255.255 (ff:ff:ff:ff:ff:ff)
    OP: 1 (BOOTPREQUEST)
 HTYPE: 1 (Ethernet)
  HLEN: 6
  HOPS: 0
   XID: b8c8ZZZZ
  SECS: 0
 FLAGS: 0
CIADDR: 0.0.0.0
YIADDR: 0.0.0.0
SIADDR: 0.0.0.0
GIADDR: 0.0.0.0
CHADDR: b4:e6:2d:ZZ:ZZ:ZZ:00:00:00:00:00:00:00:00:00:00
 SNAME: .
 FNAME: .
OPTION:  53 (  1) DHCP message type         1 (DHCPDISCOVER)
OPTION:  57 (  2) Maximum DHCP message size 1500
OPTION:  12 (  7) Host name                 myTestHostname
OPTION:  61 (  7) Client-identifier         01:b4:e6:2d:ZZ:ZZ:ZZ
OPTION:  55 (  5) Parameter Request List      1 (Subnet mask)
					      3 (Routers)
					     28 (Broadcast address)
					      6 (DNS server)
					     42 (NTP servers)

@d-a-v
Copy link
Collaborator

d-a-v commented Jul 27, 2021

So it is not duplicate but is adressed by the same fix right ?

@1e1
Copy link

1e1 commented Jul 27, 2021

Yes, I opened another PR for the Client Identifier, this one is for Hostname.
The function was here but it was never called, I have just made a side-fix.

@ilium007
Copy link
Author

I had noticed client identifier as well as hostname is missing from the Mikrotik DHCP lease table. It would be good to have both included in the DHCP DISCOVER and REQUEST packets.

@1e1
Copy link

1e1 commented Jul 30, 2021

@ilium007 it's merging d-a-v/esp82xx-nonos-linklayer#51
Then there is to update the submodule version here.

d-a-v added a commit to d-a-v/esp82xx-nonos-linklayer that referenced this issue Sep 25, 2021
d-a-v added a commit to d-a-v/Arduino that referenced this issue Sep 25, 2021
@d-a-v
Copy link
Collaborator

d-a-v commented Sep 25, 2021

@ilium007 and @1e1 Can you try the unofficial alpha release v0.0.2 (https://d-a-v.github.io/esp8266/Arduino/) ?

@1e1
Copy link

1e1 commented Oct 19, 2021

Hi @d-a-v
It seems OK on my side.

@ilium007
Copy link
Author

I'll need to reinstate a different router to test

@mcspr
Copy link
Collaborator

mcspr commented Jan 11, 2022

closing via #8319

@mcspr mcspr closed this as completed Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants