So this is one of my amazing learning of the day. I have been using coredns dns server at home home network to which all devices connect, beside just caching and speeding up opening website faster on home network. I also host my website from home. which while navigating I wanted to domain name should resolve to my local host ip that is serving the website. So here is the solution I figured out and it works.
In the above corefile , I am using hosts plugin of CoreDNS, that allows me to mimi the systems /etc/hosts file even within configuration. I have defined self-hosted.drydns.com pointing to local server IP address which is hosting my website. And for other websites it is forwared to cloudeflare dns server.
When I am at home network. (domain name resolve directly in a single hop.)
In the above output of nslookup 192.168.0.75 is my CoreDNS Server I have setup in my router.
And take a look below when I am outside , connected to a public wifi or via phone hotspot.
Now nslookup the same domain name I got it resolved to a external ip of the server. 220.127.116.11 is cloudfare DNS server ip.
Another thing I want to caution you, if you use dynamic ip like noip.com or drydns.com like me, then if it expires you will not notice it at your local network as your DNS server is directing your domain name example self-hosted.drydns.com to a local ip on your network.
Known Issue with host plugin: https://github.com/coredns/coredns/issues/2564#issue-411061483
Other Blogs & Pages
Animation & VFX SitesA MUST READ for Ani/VFX Artists
awakened by thoughts,