Coder Social home page Coder Social logo

dnserver's Introduction

dnserver

Simple DNS server written in python for use in development and testing.

The DNS serves it's own records, if none are found it proxies the request to and upstream DNS server eg. google at 8.8.8.8.

You can setup records you want to serve with a custom zones.txt file, see example_zones.txt for the format.

To use with docker:

docker run -p 5053:53/udp -p 5053:53/tcp --rm samuelcolvin/dnserver

(See dnserver on hub.docker.com)

Or with a custom zone file

docker run -p 5053:53/udp -v `pwd`/zones.txt:/zones/zones.txt --rm samuelcolvin/dnserver

(assuming you have your zone records at ./zones.txt, TCP isn't required to use dig, hence why it's omitted in this case.)

Or see docker-compose.yml for example of using dnserver with docker compose. It demonstrates using dnserver as the DNS server for another container with then tries to make DNS queries for numerous domains.

To run without docker (assuming you have dnslib==0.9.7 and python 3.6 installed):

PORT=5053 ZONE_FILE='./example_zones.txt' ./dnserver.py

You can then test (either of the above) with

~ ➤  dig @localhost -p 5053 example.com MX
...
;; ANSWER SECTION:
example.com.		300	IN	MX	5 whatever.com.
example.com.		300	IN	MX	10 mx2.whatever.com.
example.com.		300	IN	MX	20 mx3.whatever.com.

;; Query time: 2 msec
;; SERVER: 127.0.0.1#5053(127.0.0.1)
;; WHEN: Sun Feb 26 18:14:52 GMT 2017
;; MSG SIZE  rcvd: 94

~ ➤  dig @localhost -p 5053 tutorcruncher.com MX
...
;; ANSWER SECTION:
tutorcruncher.com.	299	IN	MX	10 aspmx2.googlemail.com.
tutorcruncher.com.	299	IN	MX	5 alt1.aspmx.l.google.com.
tutorcruncher.com.	299	IN	MX	5 alt2.aspmx.l.google.com.
tutorcruncher.com.	299	IN	MX	1 aspmx.l.google.com.
tutorcruncher.com.	299	IN	MX	10 aspmx3.googlemail.com.

;; Query time: 39 msec
;; SERVER: 127.0.0.1#5053(127.0.0.1)
;; WHEN: Sun Feb 26 18:14:48 GMT 2017
;; MSG SIZE  rcvd: 176

You can see that the first query took 2ms and returned results from example_zones.txt, the second query took 39ms as dnserver didn't have any records for the domain so had to proxy the query to the upstream DNS server.

dnserver's People

Contributors

samuelcolvin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.