{"id":22878115,"url":"https://github.com/sporestudio/dns-server","last_synced_at":"2026-04-26T12:32:58.093Z","repository":{"id":258403402,"uuid":"874183266","full_name":"sporestudio/dns-server","owner":"sporestudio","description":"This repository contains configuration files for setting up a DNS server with BIND, including master and slave zone management. ","archived":false,"fork":false,"pushed_at":"2024-10-21T19:46:38.000Z","size":1456,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T14:18:40.748Z","etag":null,"topics":["dns-server","vagrant"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sporestudio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-17T11:50:03.000Z","updated_at":"2024-11-29T21:11:49.000Z","dependencies_parsed_at":"2024-12-13T16:18:48.666Z","dependency_job_id":"29179540-5667-48a1-b3c5-bfa8dd28ab27","html_url":"https://github.com/sporestudio/dns-server","commit_stats":null,"previous_names":["sporestudio/dns-server"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sporestudio/dns-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sporestudio%2Fdns-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sporestudio%2Fdns-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sporestudio%2Fdns-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sporestudio%2Fdns-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sporestudio","download_url":"https://codeload.github.com/sporestudio/dns-server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sporestudio%2Fdns-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32297895,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T09:34:17.070Z","status":"ssl_error","status_checked_at":"2026-04-26T09:34:00.993Z","response_time":129,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dns-server","vagrant"],"created_at":"2024-12-13T16:18:33.010Z","updated_at":"2026-04-26T12:32:58.077Z","avatar_url":"https://github.com/sporestudio.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n    \u003ch1\u003eDNS SERVER\u003c/h1\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\".assets/diagram/dns-diagram.png\" alt=\"zone-transfer\"/\u003e\n\u003c/div\u003e\n\n## :snowflake: Description\nThis project implements a DNS service using [BIND](https://www.isc.org/bind/) (Berkeley Internet Name Domain) on two virtual servers configured with Vagrant: **a master server and a slave server**. The main goal is to provide a redundant DNS infrastructure by transferring zone from the master to the slave.\n\nThe `Vagrantfile` configures both virtual machines and provisions the servers with the necessary zone files so that they can resolve names and IP addresses associated with the `sistema.test` domain. The zone transfer between the master (earth) server and the slave (venus) server ensures that both servers maintain up-to-date information. The mars and mercury servers are included as additional hosts in the domain.\n\n\u003e All the computers in this project will be located within the 192.168.57.0/24 network.\n\n**Network structure:**\n\n|      Machine      | Fully Qualified Domain Name (FQDN) |     IP     |\n|-------------------|------------------------------------|------------|\n|  Graphical Linux  |        mercurio.sistema.test       |   .101     |\n|      Debian1      |          venus.sistema.test        |   .102     |\n|      Debian2      |         tierra.sistema.test        |   .103     |\n|  Windows Server   |          marte.sistema.test        |   .104     |\n\n\n## :snowflake: Project Structure\n\nThe project is organized in two DNS servers:\n\n**Master Server (tierra)**:\n- IP: 192.168.57.103\n- Responsible for storing the main zone files and answering DNS queries.\n- Configured to allow zone transfer to the slave server.\n\n**Slave Server (venus)**:\n- IP: 192.168.57.102\n- Receives zone information via transfer from the master server.\n- Serves as a backup DNS server to answer queries in case of failure of the master server.\n\n**Mail Server (marte)**:\n- IP: 192.168.57.104\n- Serves as mail server for the system.test domain.\n- Registered as MX in the zone files.\n\n**Additional Server (mercurio)**:\n- IP: 192.168.57.101\n- Additional server for DNS resolution testing.\n- Registered as an A host in the domain.\n\n### DNS Configuration\nThe configuration of zone files and BIND settings are handled by configuration files in `/etc/bind/` and zone files in `/var/lib/bind/`.\n\n#### Configuration files\n\n- `named`: Here we will configure the server to only process requests using the IPv4 protocol. To do this we will add the -4 parameter in options. This file will be located in `/etc/default/`.\n\n    ```bash\n    #\n    # run resolvconf?\n    RESOLVCONF=no\n\n    # startup options for the server\n    OPTIONS=\"-u bind -4\"\n    ```    \n\n- `named.conf.options`: In this file you configure general settings that affect the behavior of the server globally. Some of the key settings that can be defined in this file include:\n  - **Forwarder**: Specifies external DNS servers to which the BIND server will send queries that it cannot resolve locally. In our case, they will be sent to the address `208.67.222.222` ([OpenDNS](https://www.opendns.com/)).\n  - **ACLs (Access Control Lists)**: Defines rules that control access to the DNS server. In our case we have defined the “trusted” networks and the listening addresses that will listen on port 53 for requests.\n\n    ```bash\n    acl trusted {\n\t192.168.57.0/24;\n\t127.0.0.0/8;\n    };\n\n\n    acl listen-addresses {\n        192.168.57.103;\n        192.168.57.102;\n        127.0.0.1;\n    };\n    ```\n  - **Recursion**: Controls whether the server will perform recursive queries on its own or return an error if it is unable to resolve a domain locally.\n\n  - **Listen-on**: Specifies on which network interfaces and ports the DNS server will be listening for requests.\n\n    ```bash\n    listen-on port 53 { listen-addresses; };\n    ```\n  - **dnssec-validation**: Enables DNSSEC (Domain Name System Security Extensions) validation. DNSSEC is a set of security extensions for DNS that ensures that responses to DNS queries have not been altered during transmission and come from an authentic source.\n\n    ```bash\n    dnssec-validation yes;\n    ```\n\n- `named.conf.local` (maestro - tierra)\n\n    ```bash\n    zone \"sistema.test\" {\n        type master;\n        file \"/var/lib/bind/sistema.test.dns\";\n        allow-transfer { 192.168.57.102; };\n    };\n\n    zone \"57.168.192.in-addr.arpa\" {\n        type master;\n        file \"/var/lib/bind/sistema.test.rev\";\n        allow-transfer { 192.168.57.102; };\n    };\n    ```\n\n- `named.conf.local` (esclavo - venus)\n\n    ```bash\n    zone \"sistema.test\" {\n        type slave;\n        file \"/var/lib/bind/sistema.test.dns\";\n        masters { 192.168.57.103; };\n    };\n\n    zone \"57.168.192.in-addr.arpa\" {\n        type slave;\n        file \"/var/lib/bind/sistema.test.rev\";\n        masters { 192.168.57.103; };\n    };\n    ```\n\n- `system.test.dns`: direct zone file containing name records to IP addresses. It also includes aliases for the name servers and the mail server.\n\n    ```bash\n    $TTL\t86400\n    $ORIGIN sistema.test.\n\n    @\tIN\tSOA\ttierra root.sistema.test. (\n                    2\t\t; Serial\n                604800\t\t; Refresh\n                86400\t\t; Retry\n                2419200\t\t; Expire\n                   7200 )\t; Negative Cache TTL\n\n    ; Name servers NS \n    @\t\tIN\t\tNS\t\ttierra\n    @\t\tIN\t\tNS\t\tvenus\n\n    ; Aliases\n    ns1\t\tIN\t\tCNAME\ttierra\n    ns2\t\tIN\t\tCNAME\tvenus\n\n    ; Mail server\n    @\t\tIN\t\tMX\t\t10 marte\n\n    ; Servers directions\n    tierra\t\tIN\t\tA\t\t192.168.57.103\n    venus\t\tIN\t\tA \t\t192.168.57.102\n    marte\t\tIN\t\tA \t\t192.168.57.104\n    mercurio\tIN\t\tA \t\t192.168.57.101\n\n    ; Mail alias\n    mail\t\tIN\t\tCNAME\tmarte\n    ```\n\n- `system.test.rev`: reverse zone file that associates IP addresses to names. \n \n    ```bash\n    ;\n    ; 57.168.192\n    ;\n\n    $TTL\t86400\n    $ORIGIN 57.168.192.in-addr.arpa.\n\n    @\tIN\tSOA\ttierra.sistema.test root.sistema.test. (\n                    1\t\t; Serial\n                604800\t\t; Refresh\n                86400\t\t; Retry\n                2419200\t\t; Expire\n                  7200 )\t; Negative Cache TTL\n    ; Name Servers\n    @\t\tIN\t\tNS\t\ttierra.sistema.test.\n    @\t\tIN\t\tNS\t\tvenus.sistema.test.\n\n    ; Reverse directions\n    103\t\tIN\t\tPTR\t\ttierra.sistema.test.\n    102\t\tIN\t\tPTR\t\tvenus.sistema.test.\n    104\t\tIN\t\tPTR\t\tmarte.sistema.test.\n    101\t\tIN \t\tPTR\t\tmercurio.sistema.test.\n    ```\n\n### Architecture\nThe DNS is configured for the `sistema.test` domain with the following key elements:\n - **NS (Name Servers)**: defines the DNS servers responsible for resolving the domain.\n - **A records**: Associates server names to IP addresses.\n - **CNAME records**: Aliases that redirect one name to another.\n - **MX records**: Defines the mail servers for the domain.\n - **PTR records**: Records for reverse resolution (IP to name).\n\n ## :snowflake: Vagrant configuration\n The `Vagrantfile` configures the master and slave servers.\n\n ### Provisioning\n To provision the machines we use the file `scripts/provision.sh` where several functions are defined depending on the machine we are going to provision.\n\n- **General provision**: To update the repositories and install bind 9 and its utils. Provision the machines with the `named` file and with the `named.conf.options` which is common for the master server and the slave server.\n    ```bash\n    function general_provision() {\n        echo -e \"Updating and upgrading the repositories in $machine_name...\"\n        apt-get update -y \u0026\u0026 apt-get upgrade -y\n        echo -e \"Instaling bind9 and utils in $machine_name...\"\n        apt-get install -y bind9 bind9utils bind9-doc\n\n        # Common config files\n        echo -e \"Provisioning the dns server, master and slaves...\"\n        cp -v /vagrant/files/named /etc/default/\n        cp -v /vagrant/files/named.conf.options /etc/bind/\n    }\n    ```\n\n- **Specific provisioning for each server**: Provisioning of specific files for each server, tiera and venus.\n\n    - **Tierra provisioning**: In this provision we copy `named.conf.local` to `/etc/bind/`, and move the direct and inverse zone files to `/var/lib/bind/`.\n\n        ```bash\n       function tierra_setup() {\n            echo -e \"Provisoning $machine_name files...\"\n            cp -v /vagrant/files/tierra/named.conf.local /etc/bind/\n            cp -v /vagrant/files/sistema.test.dns /var/lib/bind/\n            cp -v /vagrant/files/sistema.test.rev /var/lib/bind/ \n            chown bind:bind /var/lib/bind/*\n            systemctl restart named\n        }\n        ```\n\n    - **Venus provisioning**: In the case of venus, we provision its local configuration file `named.conf.local`.\n\n        ```bash\n       function venus_setup() {\n            echo -e \"Provisioning $machine_name files...\"\n            cp -v /vagrant/files/venus/named.conf.local /etc/bind/ \n            systemctl restart named\n        }\n        ```\n\n- **Main function**: Where the program flow is controlled.\n\n    ```bash\n    function main() {\n        if [ \"$machine_name\" == \"tierra\" ]; then\n            general_provision\n            tierra_setup\n        elif [ \"$machine_name\" == \"venus\" ]; then\n            general_provision\n            venus_setup\n        else\n            echo -e \"Machine not recognized\"\n            exit 1\n        fi\n    }\n\n    main\n    ```\n\n\u003e [!IMPORTANT] \n\u003e It is necessary to make sure that the user and group that owns the zone files is `bind`, so that it can have read permissions to execute them and perform the zone transfer.\n\n## :wrench: Setup\nTo make the automatic deployment of the whole project we only have to enter the following command inside the working directory:\n\n```bash\n$ vagrant up\n```\n\n## :snowflake: Functional Checks\nOnce the project is configured, we can perform several checks to make sure that the DNS is working correctly.\n\n\n### Check named.conf.options\nWe can check that the syntax of the named.conf.options file is correct with the following command:\n\n```bash\n$ named-checkconf /etc/bind/named.conf.options\n```\nAs it usually happens with many linux commands: ***No news, good news***.\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\".assets/screenshots/check-named.conf.options.png\" alt=\"check-options\"/\u003e\n\u003c/div\u003e\n\n\n### Check zone files\nTo check that the configuration of the zone files is correct we will use the command:\n\n```bash\n$ named-checkzone sistema.test. /var/lib/bind/sistema.test.dns\n$ named-checkzone 57.168.192.in-addr.arpa. /var/lib/bind/sistema.test.rev\n```\n\nIn this case we will receive an output even if it is well configured; we will receive the loaded serial number and an OK if everything is OK.\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\".assets/screenshots/zone-check.png\" alt=\"check-options\"/\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\".assets/screenshots/rev-check.png\" alt=\"check-options\"/\u003e\n\u003c/div\u003e\n\n### Zone transfer\nOn the slave (venus), we can execute the following command to force the zone transfer:\n\n```bash\n$ dig @192.168.57.103 sistema.test AXFR\n```\n\nIf the zone transfer is successful, the following output will be displayed:\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\".assets/screenshots/dig-axfr.png\" alt=\"zone-transfer\"/\u003e\n\u003c/div\u003e\n\nIn parallel on the tierra server we can enter the following command to display the logs of the named service in real time (by the -f parameter):\n\n```bash\n$ sudo tail -f /var/log/syslog | grep named\n```\n\nThis log indicates that the slave server (venus) has successfully requested and received the system.test zone transfer from the master server (earth). The output shows that the process was completed smoothly and successfully:\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\".assets/screenshots/zonetransfer-check.png\" alt=\"transfer-logs\"/\u003e\n\u003c/div\u003e\n\n### Query DNS Records\n\nWe can use `nslookup`or `dig` to check the different records on both servers.\n\n#### Dig\n\n- We can check the NS servers of the domain:\n\n    ```bash\n    $ dig @192.168.57.103 sistema.test NS\n    ```\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\".assets/screenshots/query-ns.png\" alt=\"ns-check\"/\u003e\n\u003c/div\u003e\n\n- Check the resolution of a domain name:\n\n    ```bash\n    $ dig +short @192.168.57.103 tierra.sistema.test\n    ```\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\".assets/screenshots/namedomain-query.png\" alt=\"namedomain-check\"/\u003e\n\u003c/div\u003e\n\n- Resolver una IP a un nombre (resolución inversa):\n\n    ```bash\n    $ dig -x 192.168.57.103 @192.168.57.103\n    ```\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\".assets/screenshots/reverse-resolution.png\" alt=\"reverse-resolution\"/\u003e\n\u003c/div\u003e\n\n- Check the MX mail servers:\n\n    ```bash\n    $ dig +short @192.168.57.103 sistema.test MX\n    ```\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\".assets/screenshots/mx-query.png\" alt=\"mx-server\"/\u003e\n\u003c/div\u003e\n\n\n#### Nslookup\nWe can also run a series of queries with nslookup to make sure everything is working properly.\n\n##### A registers\n\nAs we can see below we make a couple of A register queries and it solves them.\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\".assets/screenshots/nslookup-Aregisters.png\" alt=\"mx-server\"/\u003e\n\u003c/div\u003e\n\n##### MX registers\nIt also solves our MX register queries.\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\".assets/screenshots/mx-register-check.png\" alt=\"mx-server\"/\u003e\n\u003c/div\u003e\n\n##### NS registers\nQuery to NS records.\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\".assets/screenshots/ns-reg-check.png\" alt=\"mx-server\"/\u003e\n\u003c/div\u003e\n\n\n##### CNAME registers (alias)\nQuery to the alias registers.\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\".assets/screenshots/cname-reg-check.png\" alt=\"mx-server\"/\u003e\n\u003c/div\u003e\n\n## :snowflake: Testing\nTo test the correct functioning of the DNS servers we have the script `test/test.sh`, which we will pass as parameter the network interface of the server we want to check and it will make the queries with dig for us.\n\n- Passing the test to the tierra server:\n\n    ```bash\n    $ chmod +x test/test.sh\n    $ cd test/\n    $ ./test.sh 192.168.57.103\n    ```\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\".assets/screenshots/test-tierra.png\" alt=\"test-tierra\"/\u003e\n\u003c/div\u003e\n\n- Passing the test to the venus server:\n\n    ```bash\n    $ ./test.sh 192.168.57.102\n    ```\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\".assets/screenshots/test-venus.png\" alt=\"test-venus\"/\u003e\n\u003c/div\u003e\n\n\n## :snowflake: License\n\nThis project is under \u003ca href=\"https://github.com/sporestudio/dns-server/blob/main/LICENSE\"\u003eGNU General Public License v3.0\u003c/a\u003e\n\n\n## :snowflake: Author\n\nCreated by \u003ca href=\"https://github.com/sporestudio/\"\u003esporestudio\u003c/a\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsporestudio%2Fdns-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsporestudio%2Fdns-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsporestudio%2Fdns-server/lists"}