Device name with EthernetNetIf

18 Jan 2012

I'm using EthernetNetIf in my project and setting it up with DHCP. That all works but the problem I am having is that each time I reset I get a different IP address and it takes me a while to work out what that is. I really want to assign a hostname or devicename to the MBED so that I can just use that to find the device on my network with DNS.

Can anyone help me with that, I cant see how that works!


19 Jan 2012

Would this be something to do with hostname?

20 Jan 2012

Do you mean:


Then reboot MBED and open the DHCP server's config, you should see an entry named Mbed1234.

Now you can assign it a fixed IP.

Theo (nl)

20 Jan 2012

Well I thought I should use:


But the compiler complains:

"class "EthernetNetIf" has no member "setHostname"" in file "/main.cpp", Line: 441, Col: 8

20 Jan 2012

You can do fixed IP using

eth = EthernetNetIf( ip, netmask, gateway, dns );

I haven't seen how to do the hostname thing using the standard EthernetNetIf. However have a look at NetServicesMod instead. This version allows you to specify the name in the constructor in a similar way to the code above for passing the fixed IP details

20 Jan 2012

Not looking to give it a static IP but I'll have a look at the netservices mod for the hostname. Thanks

22 Jan 2012

There should be a switch in your router where you can enable that the device will get permanently the same IP address via DHCP.