Go Down

Topic: Ethernet Hostname Issues (Read 302 times) previous topic - next topic


Hello.  I have searched up and down for the answer to this but I am not finding any answers to this problem.  What I am doing is I have an Arduino Mega with an attached Ethernet shield set up as a server, and a program on my PC I wrote in C# which makes a client connection to the Arduino.  I had set the Arduino to use a static IP and pointed the C# application to this IP - this works fine. 

The issue I am now facing is other people are now using the application I have developed and setting a static IP no longer works well - this requires more setup than I would like on the users end.  What I would like to do is have the Arduino use DHCP instead where it would register a hostname on the users local network/router and the c# application would just point to the hostname rather than a static IP.  This way when the IP changes the application picks up the new address and they do not have to go into the router and force a static IP/change code.

It's worth mentioning the people I am giving this to are not computer/software savvy.  Instructing them on how to change/set the IP in code/in the router is not an option here - or at least not a very good option...  I modified the C# code to take the pre-complied Arduino sketch and download it to the controller, so almost everything is automatic here.  They simply plug in the controller, install the application, run the setup and it "works".  This also allows me to push updates as needed. 

I modified my Arduino code to use DHCP.  When the controller starts up, I log into my router and can see the IP assigned as well as the default device name it was assigned when the program was compiled (WIZnetXXXXXX, where XXXXXX appears to be part of the mac address I gave the controller).  The problem is this doesn't appear to resolve to anything when I try to connect via the C# application (or just doing a ping test on my PC).  I am not really sure what I am missing - the router appears to know of the device but doesn't know of the hostname.  If I point the application to the IP the router assigned everything works. 

I feel like this should be simpler than it is turning out to be...

If this isn't going to work are you guys aware of a different approach I could take?  One that comes to mind is modifying the C# PC application to simply lookup the PC's gateway then search for the IP/port I am using on the network.  Ie, the lookup comes back with so try to connect to, if it fails, try ~.3::1234, etc until I find it.  That should work but it could take considerable time to find the address of the Arduino any time that address decides to change.


DHCP and DNS are not the same thing. DHCP manages assigning dynamic addresses to the Arduinos.

DNS manages the relationship between a domain name and an IP address.

Unless you (and all your users) are running a DNS server, use of domain names won't work.
The art of getting good answers lies in asking good questions.

Go Up