A simple DNS server implementation in Java that can handle basic DNS queries and responses.
DNSReader is a lightweight DNS server implementation that demonstrates the basic functionality of DNS (Domain Name System) protocol. It can handle DNS queries and respond with IP addresses for registered domain names.
- Basic DNS query handling
- UDP-based communication
- In-memory DNS record storage
- Multi-threaded request processing
- Support for A record type queries
- Java 17 or higher
- Maven
- Clone the repository:
git clone https://github.com/yourusername/DNSReader.git
cd DNSReader- Build the project using Maven:
mvn clean install- Run the DNS server:
java -jar target/DNSReader-1.0-SNAPSHOT.jar-
The server will start listening on port 53 (default DNS port)
-
You can test the server using tools like
digornslookup:
nslookup example.com localhostThe server comes with some sample DNS records pre-configured:
- example.com → 93.184.216.34
- localhost → 127.0.0.1
- test.local → 192.168.1.10
DNSReader/
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── org/
│ │ │ └── example/
│ │ │ └── Main.java
│ │ └── resources/
│ └── test/
├── pom.xml
└── .gitignore
- Uses Java's
DatagramSocketfor UDP communication - Implements basic DNS message parsing and response creation
- Supports concurrent request handling through multi-threading
- Uses a simple HashMap for DNS record storage
This is a simplified DNS server implementation and has the following limitations:
- Only supports A record type queries
- Uses a fixed-size response buffer
- Has limited error handling
- Does not support DNS caching
- No support for recursive queries
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.