Resolving Domain Name to Private IP AND Public IP Simultaneously [closed]

Background

(Skip if not interested)

I have a dev server running in my local network. I can reach it easily by private IP (192.168.2.4). I have my firewall ports open on the server for :80 so I can reach my website. So far no problems at all.

I then added a domain name to the flow along with a DynDNS URL and IP updater. I changed the details in my domain NS to forward to my DynDNS url and mask which works. Afterwards, I went into my ISP router config page and gave internet access to the server (through the router) as well as NAT for port 80 to my private IP. Again, great success. I can reach this page while on a network that is public and outside my local network.

Problem

Obviously, when resolving my domain name in my local network it resolves to my routers public IP address and just spins forever.

Here is what I would like to accomplish

(but have no idea how)

When going to my domain name, I want the resolution to have my public router IP when outside my network and the private IP when inside.

How I Invision This Implemented

I need to add a DNS server daemon in my server via dnsmasq and then change my router settings to use this server's private IP as my primary and secondary DNS server (in the router settings). I know I need to open the DNS ports in my firewall on the DNS server (which is also my web server).

I know when I leave my network, I am now resolving DNS requests via ISP (data conn) or ISP of the user's network I am connected to (rather than my DNS server which says the address is a private one). So would this solve my desire of public outside the network and private inside?

This is where I get totally lost...

Now that my local devices are looking to my DNS server to resolve things, where on earth do I get a daily listing of top level domains??? Or do I add the primary/secondary DNS servers that I replaced in my router from my ISP, to my DNS servers resolution stack?


Solution 1:

[...] the private IP when inside.

You could just add this host to your hosts file. If this is needed on more than one client, just generate a zone with that name on your DNS server. This would be a Split-Brain oder Split-Horizon Setup, then.