dns set up using bind9 behind a router
I used to have a server running Ubuntu 17.04 server with static IP, I have a nameserver config on that machine following some instructions on a page on the internet.
Now I do not want to spend money on the server and want to set up the nameserver on my personal machine at home which saves me monthly expenses on the server and it is a lot faster than the configuration I had in the previous one. Now I want to point the domain to this new IP. As the IP address often change, I have created an application which will check my updated public IP and update the DNS provider with the latest IP. I have already done the port forwarding for SSH and the port 80 for Web Server.
But I have some questions below.
What are the problems I may arise? what IP address should I use on the named.conf.local file and the named.conf.options, etc? Is there a documentation or a guide available to set this up.
I do not want to use No-IP or other tools.
Thanks in advance.
32 Answers
I don't think it will work for you.
If example.com wants to use ns1.example.com as one of its nameservers of record (for others to use for lookups to find etc) then the registrar for the domain (godaddy, google, network solutions, whoever) needs to add what are called "glue records" so that a domain can reference itself. With an IP that changes on a fairly regular basis, this won't work.
Even if you had say a linode or other VPS, you couldn't run a master from your home connection in a secure way - domain transfers are typically locked down by what IP is allowed to pull a copy - so you'd have to update your DNS config in order to update your records.
What would work is what you said you don't want to do - use noip or some other dynamic dns service. You could do that, and then set up CNAME records for your "real" domain that point to your noip hostname which would be kept in synch with your IP address.
Personally, between power issues, extra heat, extra noise, etc. I moved my server from my home to a linode.com account 12 years ago and haven't looked back, and that is what I'd recommend that you do as well...
1It's possible. Somewhat. But it's not recommended.
I do it, and it's painful.
First of all, I have a No-IP record, for the public IP. Let's call this foo.no-ip.com.
The NS of example.com points to foo.no-ip.com, and a second (external) Slave NS, that is simply replicating the master. Slave DNS is often included for free from the registrar.
Bind9 is set up as authorative DNS server for example.com, and port 53 TCP and UDP is allowed trough to Bind. Normally DNS uses only UDP, but for zone transfer to the slave NS, TCP is used.
The zone file is rather standard:
$TTL 60
;
$ORIGIN example.com.
example.com. IN SOA foo.no-ip.com. admin.example.com. ( 2017012101 ; serial 1h ; refresh 1h ; retry 1h ; expire 1m ; default_ttl )
@ IN NS foo.no-ip.com
@ IN NS slave-ns.example.org
@ 600 IN A 127.0.0.1I wouldn't really recommend hosting DNS at home. Go with a provider that gives you Dynamic DNS updates, for instance I believe google does this. Then you can use the nsupdate tool to dynamically manipulate your NS records.
DNS is great stuff, but it's at times rather fragile too.
It's technically possible to do it with glue records as well, but they are prone to errors when IP changes, so that's not recommended if you're on a changing address.
If you want to go with glue records, add a record in your zone file with some name, e.g. ns 600 IN A 1.2.3.4 pointing to your public IP. Specify ns.example.com as NS, and create a glue record at your registrar. How this is done differs from vendor to vendor. Whenever you update your external IP, you have to update the glue record.