having router DNS resolving to internal IP address

2

1

I recently asked this elsewhere and was directed to ask here.

Recently I have been working on a project which is hosting a web server. This is a simple temperature monitoring device that is logging a few temperatures and has a simple website to display information.

What I wish to do is assign this device a url that will resolve to its internal IP to make it a little more simple to connect to and see this information for the local network. This will be viewed from phones, tablets and laptops.

After doing as much research as I can with my limited networking knowledge, I need to turn to somewhere that has more knowledge than I (I hope I am posting in the right spot. Please forgive me if not)

The server is running on a Raspberry Pi zero W running Raspian (which is based off Debian)

My Router is a NetGear Nighthawk R8500 running the standard NetGear firmware. DNS settings are provided by my ISP.

I have not been able to find any information regarding what I am trying to do on the NetGear website and am not a member of their forums (although I may need to, will see how this question goes).

My questions are as follows:

Is there a name for what I am trying to do?

Can my router do this functionality without using custom firmware?

If not, what custom firmware would you recommend to do such a job?

Modifying the Hosts file is not an option as I wouldn't want to configure each device that I need to connect.

All help is greatly appreciated. Thanks for your time!

Kaden

Posted 2019-06-11T18:24:49.857

Reputation: 23

Answers

0

Overview

If I am not misreading your question, it sounds as if you wish to access the web server for your device by a name, rather than by an IP address.

If this is the case, then you simply need to set up a DNS server on your local network. This server would:

  • Map the name of your choosing to the device's IP address (or wherever the web server lives).

  • Forward all other DNS requests (e.g. for general browsing) to your ISP.

After setting up this DNS server, you would then want to configure your router to use that local server for DNS requests, rather than sending requests to your ISP directly.

Devices connected to the router (e.g. phones, tablets and laptops) could then connect to the web server in question with the given name you've chosen, without modifying any hosts file.

Questions

Is there a name for what I am trying to do?

The term I have seen most frequently used is "local DNS".

Can my router do this functionality without using custom firmware?

You shouldn't need custom firmware to do what I am describing.

The exception to this rule might be if you wanted the router itself to act as your local DNS server. This isn't typically possible with stock, consumer-grade firmware.


Notes

Netgear DNS Server Settings

The DNS server IP address settings you need should be located under Advanced → Setup → Internet Setup → Domain Name Server (DNS) Address in the standard Netgear Genie interface. Click the Use These DNS Servers radio button and enter the IP address for your local DNS server (it's okay to enter the same address in both fields):

ex. Netgear DNS Server Settings

Netgear DNS Server Settings - Screenshot

In the example above, 1.2.3.4 would be replaced with the local IP address of your DNS server. If you don't see these settings, you router may be in Access Point (AP) mode, which you will have to discontinue using if you wish to proceed with the solution I outline. Make sure to Apply any changes you make.

DNS Server Hardware

Any computer on your network can serve as your local DNS server. The only thing to remember is that it needs to be on 24/7 to allow both access to your project (via its name) and the internet at large. You can choose to use your Pi for this, but a separate computer would work as well (and may provide slightly better performance).

DNS Server Software

BIND is one option and the one I would personally recommend. Another option that seems to be popular is Dnsmasq. Both are available for *NIX style OSes, including the Raspberry Pi if you choose to run your DNS server on that device.

Regarding BIND in particular, it is also extremely well-supported on Windows. Zytrax also has a good online reference if you need more information about DNS and BIND generally.

In any case, there should be plenty of guides available on Google on how to set up the DNS server software of your choice on your preferred platform, assuming that you don't pick a smaller project.


BIND Local Domain Examples

While there are additional steps you would need to take overall, below are some extremely simple examples of how BIND might be configured to serve a local domain called e.g. http://temp.monitor/:

ex. named.conf

# Anything with a hash (#) is a comment.

# Where do we find our zone files?
# Zones files hold our domain/IP mapping information.

options {
    directory "/path/to/some/zones";
    allow-transfer { none; };

# Tack down the edges a bit regarding security.

# allow-recursion {192.168.1.0/24;}; // change IPs as required

    allow-recursion {"localnets";};

# The option below forwards non-local domains to outside DNS servers.
# This means we can still use the internet.
# This is where you might put your ISP's DNS server addresses.
# The (working) IPs below are for Google's free 3rd-party DNS services. 

    forwarders { 8.8.8.8; 8.8.4.4; };

};

# Our local domain (i.e. the desired URL for your project).

zone "temp.monitor" IN {
    type master;
    file "temp.zone";
    allow-transfer { none; };
};

# Entries below the following line may be included 
# in a different file, depending on your platform.

# ------------------------------------------------ 

# This section requires a correct "secret".
# This section will likely be copied from your rndc.conf file (generated separately).

# Adjust as needed. This is just an example secret.
key "rndc-key" {
   algorithm hmac-md5;
   secret "2diZ8TosQlmJc15Nw3+ISh==";
};

# Allow our local DNS server to use rndc
controls {
    inet 127.0.0.1 port 953
        allow { 127.0.0.1; } keys { "rndc-key"; };
};

# End of named.conf

ex. temp.zone

; Zone file for our "temp.monitor" zone.
; Enables use of e.g. http://temp.monitor/.
; Anything with a semi-colon is a comment.

; "weatherwizard.temp.monitor" below is an email address.
; The first . substitutes for the normal @ symbol.
; This doesn't have to be a real/active address.

$TTL 3600               ; Time-To-Live, in seconds
@   IN SOA  ns.temp.monitor.    weatherwizard.temp.monitor. (
        2019061401  ; serial, often based on the date
        10800       ; Refresh period
        3600        ; Retry interval
        604800      ; Expire time
        86400 )     ; Negative caching TTL

@      NS   ns.temp.monitor.

ns                  IN A        10.0.0.1       ; This entry is necessary - Use the IP of the BIND server

temp.monitor.       IN A        10.0.0.1       ; A Record for the temperature server - we're assuming its on the same server as BIND
cool                IN A        10.0.0.1       ; A Record for a sub-domain on the same machine e.g. http://cool.temp.monitor.

Anaksunaman

Posted 2019-06-11T18:24:49.857

Reputation: 9 278

1Such a great answer. As you alluded to I did want the router itself to act as the DNS server. The reasoning was that NetGear routers have some sort of inbuilt DNS already (so you can setup the router by visiting routersetup.net or whatever the actual URL is) but it seems this isn't exposed for configuration. I have accepted your answer as it has answered all my questions as best as possible, thankyou for your time! – Kaden – 2019-06-22T02:48:15.353

Glad you found it helpful. No, Netgear routers aren't bad for running small sites generally, but they don't expose any DNS functionality, unfortunately (which would honestly be a rather nice). – Anaksunaman – 2019-06-22T02:59:11.510