Set ethernet hostname

Hi,

I’m working on a simple web server which lets the user control a few LEDs plus change the arduino IP/subnet/mac etc.

I’d love to be able to give the arduino a hostname so users can navigate to (for example) arduinosetup.local rather than whatever the IP is set to at that time.

Is this possible on the arduino platform?

Thanks

I don't think there is any way to set the hostname using the official Arduino Ethernet library. There is a pull request to add this feature though:

So you could just download the Ethernet from the branch of that pull request to have that functionality:
https://github.com/shoop/Ethernet/archive/add-dhcp-hostname.zip
Various other solutions for doing this have been posted here on the forum over the years and can be found with a search.

If you only want the hostname and don't care about setting it to a custom value, this information might be useful to you:

SurferTim:
Why not use the default? It will be WIZnet followed by the last three octets of the mac address. If you use DEAD BEEF FEED as the mac, the host would be "WIZnetEFFEED".

There is a pull request to add this feature though:

That pull request sets the DHCP identifier. That’s not what OP was requesting.
OP tries to send requests to he’s Arduino using mDNS host names. You can use this library to let your Arduino answer mDNS requests and reserver a local host name for it. Keep in mind that this works only for clients that implement mDNS (Android for example doesn’t provide that feature by default).

How one can set DHCP name using Ethernet API? I cannot find setHostname() or similar.

I have found this older post on the same matter, also pull request 50 and pull request 5701 – not sure which one was actually merged.

How one can set DHCP name using Ethernet API? I cannot find setHostname() or similar.

No, the API doesn't allow that. The mentioned pull request would add such a feature to the Ethernet library but it wan't merged yet as far as I know.

The pull requests you mentioned are even older and were probably replaced by the one above.

I can understand that arduino.cc is cautious with the pull requests as it might pose a lot of problems in using the library for a functionality very seldom needed (other than for narcissistic reasons).