Just A Service

Setup a DNS Server

At Home

When the ISP (Internet Service Provider) of your choice (as Claro or Tigo in Colombia) installs the internet service at your home, they install a router, this router has multiple services inside as DHCP (Dynamic Host Configuration Protocol) and DNS (Domain Name System).

Contents

    Concepts

    DHCP 

    it allows to setup automatically all the computers inside of your network, that means, everytime a new computer, laptop, tablet, smartphone, camera, etc is connected (by cable or using wifi), the router is able to assign an unique ip direction to each device and allows the communication of all devices inside and outside of the network using ip addresses.

    DNS 

    allows to resolve the IP addresses to human readable directions, i.e in case we want to connect to google, instead of using 172.217.28.100, we write www.google.com in the web browser, so the DNS translate from www.google.com to 172.217.28.100. You can imagine that DNS works as a directory with pairs of names and ip addresses.

    There are multiple DNS Servers around the world, even your ISP could have one of them. Some popular companies also have their own DNS Servers such as Google, Cloudflare etc.  

    Advantages of using a Local DNS Server

    There are a couple of advantages of using a Local DNS Server inside of your network. the next are a couple of them.

    Block Ads

    I believe this is one of the most important benefits. Say goodbye to ads and trackers, this makes the experience of browsing on the internet cleaner, faster and securer.

    Parental Control

    Similar to block ads, you can add in the blacklist adult sites and other sites you can consider inadequate for your children.

    Selection of the external DNS Servers

    you are free to select the wan DNS server that you prefer, and no those selected by your ISP. This could improve the speed of the internet responses.

    Local names for your devices

    you will be able to give names to your local devices, this is really useful in case you have a web server for development, or in case you want to use some other network tools inside of your network such as ssh, remote desktop and others.  

    Disadvantages of using a Local DNS Server

    maintenance

    you must have to ensure everything works correctly, and in case of some problem you will have to face it alone or ask the experts on the internet. This is the price of the control of your network.

    server failures

    In case the DNS server goes offline, you will perceive you don’t have internet (some OS take this into account and automatically change DNS server for the router or some external DNS).

    Tools to setup a DNS Server

    If you are reading this section it is because you are interested in continuing with the setup of the DNS server at home. The next are the requirements to set up a DNS Server. 

    Hardware

    You can use some computer for this setup, but take in account that as a server you need to have this computer online all the time, so easily you can use your own personal computer, but it’s recommended to have an additional hardware for this objective. 

    possible hardware options:

    • your current pc or laptop
    • an old laptop
    • a raspberry pi.
    • a NAS
    • a full enterprise server.

    In theory some hardware that supports an operative system, where you can customize and install a DNS application should be enough. As a personal recommendation an old pc or raspberry pi should be enough.

    Software

    Depending on the OS (operative system) of your preference, there are different tools, but it is common in these environments to use linux (the most popular OS for servers), for this reason I will talk only of 2 programs here, because I’ve already got some experience using them, but take in account that there are a lot of other options.

    DNSmasq

    This is a very common and simple tool to use, it is widely supported in multiple linux distributions and the installation is very straightforward (depends on your linux distribution). At the beginning you need to invest some time setting up the configuration files and in case you want to use it as an adblocker, you need to maintain the blacklist for yourself.

    Here there is a really useful tutorial to install DNSmasq in a raspberry pi, but should not be very hard to follow the same steps in you own linux distribution https://alexellisuk.medium.com/lightweight-ad-blocking-with-dnsmasq-and-raspberry-pi-665dbb3242e3 

    Pi Hole

    This application has a very intuitive user interface and you can easily set it up once it is installed on your computer, this app automatically manages the black list for ads and gives an easy way to active, inactive add or remove new records in the list.

    My personal recommendation is installing through docker. 

    With Access to the ISP Router

    If you are lucky and you can access to the ISP Router or your ISP do it for you, you can define your DNS server as the DNS server for all your local network. 

    check the following diagram:

    Flow:

    1. Local PC asks for an URL i.e www.google.com
    2. ISP Router redirects the DNS request to the Local DNS server previously configured.
    3. if the DNS server is able to resolve the name, it will answer with the IP otherwise, it will redirect the name to another DNS server outside of the LAN (in this case, when another DNS server returns the IP, the local DNS Server will cache the answer for future requests).
    4. The IP is returned to the Local PC who ask for the URL

    Without Access to the ISP Router

    In case you don’t have access to the router, you will need to set up every device in your network to use your Local DNS Server. every device has their own way to do it, and the bad news is no all device allow this configuration i.e smart tvs.

    Flow:

    1. Local PC asks for an URL i.e www.google.com
    2. Local PC checks what is the preferred DNS server configured and asks that server.
    3. if the DNS server is able to resolve the name, it will answer with the IP otherwise, it will redirect the name to another DNS server outside of the LAN (in this case, when another DNS server returns the IP, the local DNS Server will cache the answer for future requests).
    4. The IP is returned to the Local PC directly.

    Conclusions

    Nothing is free, and setting up a DNS server at home gives us some advantages and disadvantages, and you are the only one who can decide the real value of this. personally this experience helped me to understand a little bit more the big world of the networks.

    Comments

    Leave a Reply

    Your email address will not be published. Required fields are marked *