Why can't I get the hostname of an ip on an LAN network?

DominusDRR

Member
Joined
Nov 19, 2021
Messages
10
Programming Experience
5-10
Hi.
I have an application made in C# and Android.

The application tries to get the hostname of an IP as follows:
Search for HostName by IP address:
private string GetHostName(string ipAddress)
{
   try
   {
      IPHostEntry entry = Dns.GetHostEntry(ipAddress);
      if (entry != null)
      {
       return entry.HostName;
      }
   }
   catch (SocketException)
   {
      return "";
   }

   return "";
}


It worked very well until now in a home network, it did not return the name of some computers connected to the network.

To rule out that it is a problem with my application, I used a software that allows scanning all the IP addresses of a lan network and in the same way, it cannot obtain the name of the devices, only their IP address and MAC address:

1639487338841.png



So I think it may be a router configuration problem.


Any comments or suggestions are welcome.
 
Are you running a DNS server on your home network? If you are using router, does the router do both DHCP and DNS, or just DHCP?
 
Hi

Thanks for write.

DHCP is working, since it (router) assigns an IP to the connected devices.

The problem is that the internet service provider owns the router and we cannot access the router to check those settings.
 
Anyway, what you need is a DNS server that maps IP addresses to names.
 
Hi

Thanks for write.

DHCP is working, since it (router) assigns an IP to the connected devices.

The problem is that the internet service provider owns the router and we cannot access the router to check those settings.
I will try using the MAC address and the HostName to put it aside.
 
Back
Top Bottom