Skip to main content

Pure Python DNS server for developers

Project description

https://img.shields.io/pypi/v/devns.svg https://img.shields.io/pypi/l/devns.svg https://img.shields.io/pypi/wheel/devns.svg https://img.shields.io/pypi/pyversions/devns.svg https://travis-ci.org/daveisadork/PyDevNS.svg?branch=master https://codecov.io/gh/daveisadork/PyDevNS/branch/master/graph/badge.svg

PyDevNS is a pure Python DNS server for developers. You know how you need a domain name to use for interacting with your app locally? Well, this is the tool for you.


I know what you’re thinking

Dude, what? I just put local.dev in my /etc/hosts file.

Well, that’s all well and good, but what about when you need local.dev and *.local.co?

There’s like a million things out there that do this. I could use dnsmasq, or one of the other 40 random Python “dev DNS” servers you probably stole your implementation from.

OK, dnsmasq kind of seems like overkill, but what about when you need local.dev or reallycoolprogrammer.local.dev to work from inside a docker container?

Well then I just make dnsmasq resolve it to my real IP instead of 127.0.0.1.

So you edit the config and restart dnsmasq every time you move from home, to the coffee shop, to the office, wherever…

That is kind of a pain, now that you mention it…

Thought so.

Default Behavior

If you run devns with no arguments, the server will start, bind to 0.0.0.0 with a random port and try to discover a suitable IP address to use for resolving any incoming DNS requests. It literally does not care what domain you ask for, it always responds and always with the same IP, hopefully the IP address of your actual network interface (e.g. 192.168.1.52 or whatever). It tries to figure that out on its own, and I think it does a pretty good job of it.

But then how do I make DNS queries go to it, especially if it’s using a random port every time it runs?

Glad you asked. It’ll also try to write a file to /etc/resolver/dev, which if your OS supports such things, would tell it to send any DNS queries for domains ending it .dev to devns.

But wouldn’t I need to…

Run it with sudo to do that? Yeah probably, unless your system is insane and just lets anybody write to /etc all willy nilly, in which case you have bigger problems than getting local.dev to resolve to something sensible.

Examples

Run the server with a random port and auto-configured resolver for .dev resolving to a sensible, auto-detected IP address:

sudo devns

Listen on port 53535 without writing any resolver files:

devns --port 53535 --no-resolver

Respond with a specific IP every time instead of an auto discovered one:

sudo devns --address 172.24.3.1

Listen on port 53535, write config files for .dev and .local.co:

sudo devns --port 53535 --domains dev local.co

Bind to a random port on 127.0.0.1, and make a lot of noise:

sudo devns --host 127.0.0.1 -vvv


Here’s what devns --help gets you:

usage: devns [-h] [--verbose | --quiet] [--address ADDRESS | --ttl SECONDS]
             [--host HOST] [--port PORT] [--domains [DOMAIN [DOMAIN ...]]]
             [--resolver-dir DIRECTORY] [--no-resolver]

optional arguments:
  -h, --help            show this help message and exit
  --verbose, -v         verbose output
  --quiet, -q           quiet mode
  --address ADDRESS     IP address to respond with
  --ttl SECONDS         how often to refresh the address

Network:
  --host HOST           address to listen on
  --port PORT           port to listen on

Resolver:
  --domains [DOMAIN [DOMAIN ...]]
                        domains to create resolver files for
  --resolver-dir DIRECTORY
                        where to put resolver files
  --no-resolver, -nr    disable creating resolver files

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

devns-0.4.2.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

devns-0.4.2-py2.py3-none-any.whl (14.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file devns-0.4.2.tar.gz.

File metadata

  • Download URL: devns-0.4.2.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for devns-0.4.2.tar.gz
Algorithm Hash digest
SHA256 1ca6c17b24c8c5f85d1539901ed4963c298f4c301e56877ef518ebe9e6bd0774
MD5 ebd188d63ac1f051f5e8efd4fc08b684
BLAKE2b-256 1c95995f22d550de83a0ce05988affe8f915c060b64ec192a5c3d1c833bf53b7

See more details on using hashes here.

File details

Details for the file devns-0.4.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for devns-0.4.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 2006b7ee6e944a34608a1a33dc606751df29e8de66153d44cec15b53afae2916
MD5 a8a65a2e60f684484c6b2d2d4367a20f
BLAKE2b-256 6ccab7f100a32c2595c3eb883968acb8ce3b5f3755cbaf7964d042a8374068cf

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page