Start server on IP assigned by DNS

Hi all,

all the references and tutorials here start a server on an fixes IP. What I'd love (I need to do) is

I am able to tokenize the Ethernet.localIP() string after receiveng DHCP answer. Where I fail is creating the global variables IP and server on top of the program first, and filling them with data later inside the setup() routine.

Any help?

Ask DNS for IP (like https://www.arduino.cc/en/Tutorial/DhcpAddressPrinter )

DNS and DHCP are not the same thing!
Usually a device gets it's IP by DHCP. A client requesting a service is asking the DNS server for the IP of that specific service.

I am able to tokenize the Ethernet.localIP() string after receiveng DHCP answer. Where I fail is creating the global variables IP and server on top of the program first, and filling them with data later inside the setup() routine.

I don't see why this should help but I may misinterpret you. Post your code, maybe that shows what you mean.

where in the sketch do you see the EthernetServer using the IP?

pylon:
DNS and DHCP are not the same thing!
Usually a device gets it's IP by DHCP. A client requesting a service is asking the DNS server for the IP of that specific service.

I don't see why this should help but I may misinterpret you. Post your code, maybe that shows what you mean.

Good point, of course they are not. My mistake, writing a post in a hurry was not a good idea. I was talking about DHCP.

Good point, of course they are not. My mistake, writing a post in a hurry was not a good idea. I was talking about DHCP.

And what's the problem if you got the IP by DHCP? You don't have to set the IP again if you start a server. I still don't see the problem. But you still didn't post your code, maybe that would have enlightened me.

Juraj:
where in the sketch do you see the EthernetServer using the IP?

Oh my! I just read the comment and anticipated, that the IP has been used. It simply didn't come to my mind, that the server listens on port 80 and there is no connection to its the IP.

Thank you. How elementary! The case is solved :wink: