Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

How to keep a DNS name active

Aussie Susan

Advanced Member level 4
Joined
Jan 5, 2015
Messages
1,190
Helped
365
Reputation
730
Reaction score
362
Trophy points
83
Activity points
12,894
I have an ESP32 (ESP-IDF V4.1 framework) device that sets it DNS name before being allocated a IP address. The DHCP server is set up to deliver a specific address to this device. at this stage but I may want to make this fully dynamic in the future.
Shortly after starting the device I can 'ping' it from another computer on the LAN using the given name. However after some time (not sure how much but at least 30 minutes???) I can't ping the device name; but I can by IP address.
Again after some time (the next day???) I can ping the device by name again.
I'm not sure if this is a problem in my device (the way it sets the name, requests an IP address etc.) or the router that acts as the DHCP and DNS servers.
I've tried asking on the ESP32 ESP-IDF forum but no response after a number of days so I'm trying here in case this is NOT a fault in my device programming.
Is there some parameter that sets how long the DNS name is 'remembered' and how can I set this to make it longer?
Why is the name forgotten and then 'remembered' again? (This shows my ignorance of the detailed technical aspects of this.)
Susan
 

ads-ee

Super Moderator
Staff member
Joined
Sep 10, 2013
Messages
7,652
Helped
1,774
Reputation
3,554
Reaction score
1,722
Trophy points
1,393
Location
USA
Activity points
57,812
Maybe this will help http://techgenix.com/10-ways-troubleshoot-dns-resolution-issues/

Not sure if this will be pertinent if you are using a linux system to access the ESP32 but it explains how windows handles name resolution on the local network https://stevessmarthomeguide.com/name-resolution-and-dns-on-home-networks/

Routers don't have an actual DNS server inside them, they normally pass any DNS requests to an internet DNS server that you specify in the router, otherwise the name resolution has to be by some other method, broadcast being the method used by windows, which causes other network devices to return their assigned IP address. It may be that you need to support something like WINS or whatever other method that now exists on your ESP32.

I'm not a network guru this is just stuff I've had to pick up over the years dealing with my own home network and talking with our IT people at work.
 

betwixt

Super Moderator
Staff member
Joined
Jul 4, 2009
Messages
14,365
Helped
4,726
Reputation
9,467
Reaction score
4,495
Trophy points
1,393
Location
Aberdyfi, West Wales, UK
Activity points
122,584
Perhaps an alternative solution if your router supports it is to use MAC binding. In other words identify the ESP32 by it's MAC address and have a fixed IP bound to it. I have a fairly large array of ESP32s running here with a Draytek router and they are all allocated fixed addresses as they 'log in'. To avoid problems of my public IP address changing, I use DDNS to make it appear static.

Brian.
 

ads-ee

Super Moderator
Staff member
Joined
Sep 10, 2013
Messages
7,652
Helped
1,774
Reputation
3,554
Reaction score
1,722
Trophy points
1,393
Location
USA
Activity points
57,812
Brian, why does it matter if your public IP address changes, that won't affect the local LAN IP addresses the DHCP issues? Or are your ESP32s on a WAN or connected to the internet themselves?

Took a look at the Draytek and interestingly enough it actually seems to have a built in DNS on the LAN side, so I'm assuming you can create domains on your LAN (nice), that is probably why those routers are at least $100 USD more than most of the home routers you find. They seem to have a lot of business features on even their "connected home" line.
 

Aussie Susan

Advanced Member level 4
Joined
Jan 5, 2015
Messages
1,190
Helped
365
Reputation
730
Reaction score
362
Trophy points
83
Activity points
12,894
I think my setup must be a bit like Brian's in that my broadband modem also contains the DHCP and DNS servers so that I can set up my own 10.x.x.x network for my house. (I also use a public DNS service run my the suppliers of my NAS to get access to various internal servers when I'm outside as my actual public IP changes every time my modem needs to re-connect.)
Therefore my question is all about the internal operation on my LAN.
I do use MAC binding to ensure the IP address stays the same for now but, as I said, I'd like to enable the DHCP server to allocate a dynamic IP address in the future.
The issue seems to be that the DNS server times out on its ability to translate the name to the IP address and then something re-triggers the connection.
Therefore my question is around wether that (assumed) timeout is due to a setting in the DNS server or something in my device that refreshes the linkage (???is this actually DHCP lease time related?????).
Susan
 

betwixt

Super Moderator
Staff member
Joined
Jul 4, 2009
Messages
14,365
Helped
4,726
Reputation
9,467
Reaction score
4,495
Trophy points
1,393
Location
Aberdyfi, West Wales, UK
Activity points
122,584
It looks like the default ESP32 lease time is 2 hours, which could be your problem. Take a look at:
and scroll down to the function: uint32 wifi_softap_get_dhcps_lease_time(void); which suggests 2 days is the maximum but I'm not sure if this only relevant to DHCP within the ESP32 itself.

I checked the user manual of my router and it limits the lease time to one day but has the option to release an IP if it hasn't been used for a configurable number of seconds. This is to stop the number of addresses being used up by lots of short term temporary connections. If your router has something similar it might be worth disabling it to maximize the lease period.

I'm not sure if there is a method to bind to a device name rather than MAC, perhaps someone with greater networking knowledge can advise.

Brian.
 

Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top