Local subdomains and DNS

2

I have a following issue. I have in house server (old Dell desktop PC). I have about 9 devices I'm using to test my websites (written mainly in PHP and Python).

In the past, I was creating Nginx virtual hosts and was editing hosts file to point virtual subdomain to my main server, ex. dev.domain.com, dev.anotherdomain.net.

With lot of devices and websites it became really hard to manage it (+ I don't know how to edit hosts files on Android and iPad tablets).

I'm wondering (however my knowledge in that aspect is quite limited) if it's possible to set up DNS server (Bind9?) on my server and point its IP as the second NS in my internet connection? Would that work? If not, how do you usually manage that kind of stuff?

Regards, Kyriagos

Kyriagos

Posted 2012-08-21T18:43:34.840

Reputation: 23

Answers

3

I set up a local DNS server as a forwarding-only server, give it the address of your ISP's nameservers. Then add a local domain to it's config. Add the necessary forward and reverse records for each local name you want to use on the web-server.

Set all the PCs to use the local DNS server. (Ideally using DHCP)

Then when PCs ask for the address of foo.example.com (computer foo in your local domain example.com), your local DNS server knows it is authoritative for that domain and gives the answer itself.

For any other query, the local nameserver forwards the query to your ISP's DNS server (or whatever you configure as a more knowledgable DNS server).

RedGrittyBrick

Posted 2012-08-21T18:43:34.840

Reputation: 70 632

I've found interesting article on forwarding DNS server with bind. I have just one, small question: in my internet connection box, I have my modem-router (192.168.1.1) as my primary DNS server. Should I add my server IP as the second server or primary and add router IP as secondary DNS? Some of those devices need to work outside local network too. Sorry for silly questions, just trying to understand everything and learn that stuff. – Kyriagos – 2012-08-21T19:54:18.747

@Kyriagos: Clients are configured with a list of DNS servers. Normally only the first in the list is consulted. The others are only used if the first one is not available (turned off or inaccessible), all the listed DNS servers are expected to have exactly the same information available to them. The client does NOT consult a second DNS server just because the first one returns an answer such as "no such domain" for example. So make your DNS server the only one in the list. If you want secondaries you have to set up more local DNS servers which perform zone-transfers from the primary. – RedGrittyBrick – 2012-08-21T22:33:11.403

Thanks. Learned new stuff. Love to have my problems solved that way. I've set up local DNS server, everytihng is working perfectly. – Kyriagos – 2012-08-22T12:23:26.500