4

There has been a somewhat similar question asked before here and here but they aren't the answers I am looking for.

Details: There is a website that is supposed to be deployed inside the network (LAN) it will only be accessible by LAN users. Now to access that network, the clients of that website have to go to its IP Address in LAN (which is static, so DHCP Server always gives the same IP to server machine). This is good so far, but what I want, is that instead of IP address, is there any other way, where the user can actually type a domain name, and the router forwards all the requests to that specific domain name to the IP address in LAN?

  • Are there any routers out there that support Hostname mapping to LAN IPs? (exact model please)

  • Is there any other way if the router does not support hostname mapping to LAN IP?

Unfeasible solution: Setup Local DNS server which will have the hostname mapping to that LAN IP, but the problem is that it is a restaurant, so different clients will be using it, so it is unfeasible to add LOCAL DNS Server address to each client machine. mDNS is also out of the question because of the support issues on Android browsers etc...

4
  • 3
    And what would be the problem with having a local DNS server configured on the clients by the DHCP server on the router? Then all clients will use this local DNS server automatically, right? This is the default solution to handle something like this. If it's good enough for pretty much every enterprise in the world, I think it'd be good enough for a restaurant. Commented Jul 9, 2021 at 13:19
  • 2
    I would look into using DNSMasq which can be used on a pi or multiple other linux distros and I think would help you achieve which you stated running a dns server. Commented Jul 9, 2021 at 13:36
  • 1
    If the server and clients are within the same subnet and IP of the server is already static, simply assign a hostname to the static entry on the router and apply the change, as this is no different than accessing a router's WebUI via https://<hostname>.<localdomain>. Using OpenWrt as an example, the default hostname of the router is openwrt and the default local domain of the router is lan: https://openwrt.lan Commented Jul 11, 2021 at 13:37
  • A tiny minority of consumer routers integrate a DNS server. See superuser.com/questions/311877/…. Just switched from an ASUS ROG to a Linksys "Velop" and oof everything is mdns or bust now. Commented Apr 3, 2023 at 9:05

3 Answers 3

2

To my knowledge, it won't work through the "router". If a browser tries to determine the IP address for a website a request to resolve the domain name is sent to the DNS server, not to the router (unless the router also functions as a DNS server).

The only way I see is to set up the local DNS server. You have two options to do that:

  1. Set up some DNS server software manually (e.g. on the machine you use to run your Webserver anyway). You don't have to set up the DNS manually on each client, DCHP will do that for you.

  2. Use the DNS functionality on a router (DNSMasq) as NetworkKingPin suggested in his comment. End consumer routers with this feature let you map "hostnames" to IP addresses. But note: This is a DNS function, not a router function, this will be no different than just setting up your own DNS server.

Personally, I would suggest going with option 1. There are plenty of free and open-source DNS servers you can choose from. And it's really not that difficult to set it up - there a load of how-tos out on the internet for exactly your scenario. And you won't need to buy additional hardware (if your current router does not support DNSMasq).

Still, I'm curious to see if there is another solution out there as well (without the DNS server).

As specific product suggestions are out of scope on Superuser I won't name any specific devices but just search for something router and DNSMasq and you'll find plenty of options for various brands on the factory firmware or with an alternative firmware (Ubiquity, Linksys, Fritz!, AsusWRT, DD-WRT, etc.). If you have trouble finding one, just come back here and ask.

PS. I think you are thinking of the local HOST-IP mapping on each client, which has to be set up on each client manually. The address of the DNS server is provided via DHCP (unless it's configured manually).

1

Some routers allow the assigning of a name to a locally-defined device, to facilitate accessing that device. This is usually not a full DNS server, just a service that is offered by the router.

My router offers this service, the Orange Livebox. I just now tested it and it really works.

You will have to find your router. For example, the (costly) Linksys LRT214 Gigabit VPN Router has the DNS Local Database function.

A router based on the DD-WRT firmware can probably do the job, as can other Linux-based routers that have DNSMasq. See DNSMasq as DHCP server.

4
  • Does this still work if the DNS setting in the client is set to an external router? Commented Jul 9, 2021 at 15:03
  • 1
    No. it won't work in such a case, since the DNS request will not pass by the router. But in a restaurant with its own WiFi router, connecting to the hotspot will set the DNS server for that connection as your router. The user will need to manually modify the DNS server returned by the router, which makes it then his own problem. Commented Jul 9, 2021 at 15:13
  • @Albin You can add however many DNS servers to a network interface you want; the first should be the main router that's providing DHCP, with additional ones below it. The simplest way to do this would be to add the additional DNS servers to the router's LAN interface (two WAN DNS servers should be listed first, followed by the additional RFC1918 DNS IP) Commented Jul 11, 2021 at 13:41
  • So for 99% of use cases, the problem can be solved by using DNS, now I can either use a DNS service provided by the router or install DNS ServerSoftware on the actual Server which will be serving the website. Commented Jul 13, 2021 at 5:56
0

If this is a website, and you have access to client browser you can use browser's build in hostname IP mapping more here: https://serverfault.com/questions/710212/altering-hostname-ip-mapping-within-a-browser

You can make shortcut for chrome with added extra parameters and done.

On android systems https://stackoverflow.com/questions/29280796/run-google-chrome-with-flags-on-android

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.