QUERY · ISSUE
ESP32: dhcp_hostname is read-only on non-WLAN interfaces
docs
Hi there!
On a network.WLAN interface, I can set .config(dhcp_hostname='galactica'). However, on a LAN interface, I cannot:
>>> import network
>>> l = network.LAN()
>>> l.config('dhcp_hostname')
'espressif'
>>> l.config(dhcp_hostname='galactica')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: unknown config param
I was trying to do this on an Olimex ESP32-POE board, i.e. phy_type=network.PHY_LAN8720, but as far as I understand, the exact interface doesn’t matter since this config option will simply be passed to the ESP32’s DHCP client.
Would be cool if I could set a hostname also for a wired board! Thanks in advance for looking into this.
CANDIDATE · ISSUE
Unable to set hostname on esp32 for LAN DHCP request
bug
I am trying to set the hostname for DHCP requests on a ESP32 with µP 1.21.0. I am trying it in all kinds of ways I can imagine:
import network
import machine
network.hostname("name1")
# setup network
lan = network.LAN(mdc=machine.Pin(23),mdio=machine.Pin(18),power=machine.Pin(16),id=0,phy_addr=1,phy_type=network.PHY_LAN8720)
network.hostname("name1")
lan.config(hostname="name2", dhcp_hostname="name3")
lan.active(1)
network.hostname("name1")
lan.config(hostname="name2", dhcp_hostname="name3")
lan.connect()
network.hostname("name1")
lan.config(hostname="name2", dhcp_hostname="name3")
But nothing of this seems to have any effect and tcpdump still sees this:
09:11:50.884258 IP (tos 0x0, ttl 255, id 24, offset 0, flags [none], proto UDP (17), length 336)
0.0.0.0.68 > 255.255.255.255.67: [udp sum ok] BOOTP/DHCP, Request from ec:62:60:a2:7f:0f, length 308, xid 0x11b7830c, Flags [none] (0x0000)
Client-Ethernet-Address ec:62:60:a2:7f:0f
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message (53), length 1: Discover
MSZ (57), length 2: 1500
Hostname (12), length 9: "espressif"
Parameter-Request (55), length 4:
Subnet-Mask (1), Default-Gateway (3), BR (28), Domain-Name-Server (6)
Client-ID (61), length 7: ether ec:62:60:a2:7f:0f
END (255), length 0
PAD (0), length 0, occurs 34
How can I change the hostname for LAN DHCP requests?