Search code examples
dnssubdomain

Bypass subdomain limit by hosting own DNS server


The following is more theoretical than practical, I want to test if I have understood the DNS system.

I'm currently renting a domain, lets call it example.com, from a provider. I also own a server with a static ip. Using the webinterface of my domain provider, I created an A-Record for my domain to point to my server. Now everyone pinging example.com will find that A-Record (that should distribute itself to serveral more DNS servers) and thus ping my server. Now I want a subdomain, which points to a different ip address. My provider on the other hand won't let me create subdomains. I can simply host an own DNS server at example.com, where I can add (arbitraryly) many records for any domain that is a subdomain to example.com (so not only subdomain.example.com but also subdomain.subdomain.example.com). Now, if someone pings subdomain.example.com the following will happen:

  • They go to their favourite DNS server, which has an entry for example.com by now (due to distribution, see above)
  • Since there is no entry for subdomain.example.com, the will send an DNS request on udp port 53 to the A-Record ip behind example.com (my server)
  • My server will reply with the correct ip of subdomain.example.com
  • They send their ping to the correct ip

Is my understanding correct?


Solution

  • It's not far off, but there are more subtle things under the hood. If you want to host your example.com zone yourself, then you need to have your parent (.com) have NS records that point to your nameserver on your static IP. You would need to register that within your parent through your registrar that you bought the DNS registration with.

    .com would need to host:

    example.com. NS myns.example.com
    myns.example.com. A YOURIP
    

    And in your zone running on your machine, you would need something like:

    example.com. SOA ....
    example.com. NS myns.example.com
    myns.example.com. A YOURIP
    subdomain.example.com A SUBDOMINIP
    

    If "subdomain" (your wording) is actually supposed to be in another zone enirely, then you need to use NS/A records to point to its DNS server (which can be the same).

    You might go look for a good tutorial about how the DNS works in general. It will take you a lot further.