Skip to content

amantyagi22/dns-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DNS Server Implementation

This repository contains code to build a DNS server in JavaScript (Node.js), inspired by the tutorial at engineerhead/dns-server and engineerhead.github.io/dns-server. The goal is to create a toy DNS server for educational purposes to deepen understanding of the Domain Name System (DNS).

About DNS

DNS (Domain Name Service) is like the phone book of the Internet. It translates human-readable domain names (e.g., example.com) into numerical IP addresses (e.g., 93.184.216.34) that web browsers use to connect to servers. Before DNS, a centralized file called HOSTS.TXT maintained hostnames and their corresponding IP addresses, which became impractical as the Internet grew. In 1983, Paul Mockapetris created the Domain Name System, which has evolved into the distributed, hierarchical system used today.

This project implements a basic DNS server to handle simple DNS queries, providing a practical way to learn about DNS protocols and networking.

Features

  • JavaScript (Node.js) Implementation: A functional DNS server that handles basic DNS queries.
  • Simple and lightweight for learning purposes.

Prerequisites

To run the Node.js DNS server, ensure you have the following installed:

  • Node.js (v14 or higher recommended)
  • npm (comes with Node.js)
  • Basic understanding of DNS and networking concepts

Installation

  1. Clone the Repository

    git clone https://github.com/amantyagi22/dns-server.git
    cd dns-server
  2. Run the DNS Server

    This folder contains the code for implementation of a basic authoritative DNS server in Node.js (JavaScript). To run the DNS server:

    node index.js

    The server will start listening for DNS queries on the default port (e.g., 53 or a custom port if configured). Ensure you have the necessary permissions to bind to port 53 (may require sudo on some systems).

Usage

  1. Configure your system or a DNS client to send queries to the server's IP address and port.

  2. Query the server using:

    dig example.com @127.0.0.1

    The server will respond with the IP address for supported domain names based on its internal mapping or configuration.

Project Structure

dns-server/
├── index.js         # Main Node.js DNS server implementation
├── parser.js        # Parser.js for master file parsing
├── package.json     # Node.js dependencies and scripts
├── README.md        # This file
└── zones/           # Contains the master file example

Future Plans

  • Add support for recursive DNS resolution.
  • Enhance the server with caching and more DNS record types (e.g., MX, CNAME).

Resources

Contributing

Contributions are welcome! Feel free to submit pull requests or open issues for bugs, features, or improvements. Please follow the coding style and include tests where applicable.

Acknowledgments

  • Inspired by engineerhead/dns-server.
  • Thanks to Paul Mockapetris for creating the DNS system.
  • Built with the help of the open-source community and Node.js ecosystem.

About

A Node.js implementation of a basic authoritative DNS server

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors