0

I tried accessing a webpage in a server within the local network with the hostname of the device followed by its folder path and the name of the file (it is a basic PHP-file). In the first system it worked as expected.

But when I tried the same in the second system, connected in the same local network, I couldn't access it with the hostname, but I could access the page with the IP address of the server.

The second system's DNS was configured on the router, which is the DNS for my local network.

Is there any additional configurations that I need to do for accessing the server with its hostname?

2 Answers 2

1

A (home/small office) router's DNS functionality is usually limited to forwarding any DNS requests that arrive to it from the local side to the Internet Service Provider's DNS servers, and passing any responses back to the client that made the request.

There are no guarantees that a router could always act as a fully-featured DNS server for the local network. Some routers might be able to do that, most aren't.

Even so, a DNS service isn't plug-and-play: classically, the administrator of a DNS server would have to edit the appropriate DNS zone files on the DNS server to add DNS records for the hosts that should be accessible by name. The modern addition of dynamic DNS updates allows a host to register itself by name, or the host can tell a DDNS-aware DHCP server to do it on the host's behalf.

(Since a home/small office router usually also has a built-in DHCP server, it might be able to do this as a single integrated package.)

But an unsecured dynamically-updateable DNS service is asking for trouble, so such functionality is not likely to be enabled by default. Secure dynamic DNS updates would need either some rules defining which host can do what, or some form of authentication. As a result, this cannot be done automatically.

There are other services developed for hostname resolution that don't need explicit configuring.

  • Multicast DNS (mDNS) is a relatively new solution, implemented by Apple Bonjour, open-source Avahi packages in Linux and in a very limited sense (network printer discovery only) by Windows 10.

  • Link-Local Multicast Name Resolution (LLMNR) is another name resolution protocol that requires no explicit configuration and allows systems in the local network to find each other by name. It is implemented in Windows Vista and above, and in Linux by systemd-resolved.

If none of these services are available (or the system whose name you would need to resolve isn't compatible), then the traditional fall-back in small networks is to add the name and IP address of the host(s) you wish to be resolvable by name to /etc/hosts. Of course, you'll need to do this on every host in the local network and keep the hosts files in sync to make it truly useful.

(Fun fact: in the early days of the internet, before DNS was developed, there used to be a single, centrally-managed master hosts file for the whole internet. The fact that maintaining the hosts file became unworkable was one of the main reasons of the development of DNS.)

0

You can add this hostname in /etc/hosts file. Or you can create own DNS server and point all client machines to this server.

hosts file should look like:

#IP hostname
127.0.0.1 localhost
192.168.1.1 router

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .