Since I started my home networking project, various applications have been deployed in the local network. For a very long time, I have relied on IP addresses and ports to access different apps. However, as the number of applications increase, assigning domain names becomes a more attractive option. In order to resolve the domain names, one way is to add entries in hosts files of each machine. However, it’s time consuming to edit all machines whenever modifications are required. A central domain name server (DNS) addresses this issue. This post introduces how to configure DNS in a local home network and how to use domain names for different applications.
The table below listed details of the hosts/applications that will be used.
|192.168.1.102||web.homelab.net||Web server hosting application|
|192.168.1.102||gitlab.homelab.net||Gitlab application (running in docker container, at port 7001)|
|192.168.1.102||wiki.homelab.net||MediaWiki application (running in docker container, at port 7002)|
As you can see from the table, multiple applications may share the same physical server, which is particularly common for home networking projects. Nginx can help deal with the issue. But as the first step, we only need to establish the correspondence between IP addresses and domain names. I followed the tutorial by DigitalOcean  to setup the DNS server. BIND is used as name server software, which can be easily installed using software packages tools like
yum. To setup BIND, create or modify the following corresponding files:
The following commands can be used to check the syntax:
After making sure everything is correct, start/restart BIND service.
In the last section, I mentioned multiple applications can share the same IP address, distinguished by ports. Nginx can help get rid of ports when accessing the applications. Using the Nginx configuration below, Gitlab application and MediaWiki application are assigned with corresponding domain names.
If you run into any firewall or SELinux issues, you can check my earlier post for solutions.
As a last step, we need to setup clients like desktop PCs, or mobile devices. Simply change the DNS server from automatic to manual and enter the DNS server address
192.168.1.101. I tried all different mainstream operating systems including Windows, Linux, Mac OS, iOS, Android without having any difficulties. Now test and enjoy your private web applications in your client browser!