Metadata-Version: 2.1
Name: dns_local
Version: 2.1.2
Summary: Simple python3 DNS server
Author-email: doronz88 <doron88@gmail.com>
Maintainer-email: doronz88 <doron88@gmail.com>
License: GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
Project-URL: Homepage, https://github.com/doronz88/dns_local
Project-URL: Bug Reports, https://github.com/doronz88/dns_local/issues
Keywords: dns,protocol
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: ifaddr
Requires-Dist: click
Requires-Dist: coloredlogs
Requires-Dist: dnslib
Provides-Extra: test
Requires-Dist: pytest; extra == "test"

[![Python application](https://github.com/doronz88/dns_local/workflows/Python%20application/badge.svg)](https://github.com/doronz88/dns_local/actions/workflows/python-app.yml "Python application action")
[![Pypi version](https://img.shields.io/pypi/v/dns_local.svg)](https://pypi.org/project/dns_local/ "PyPi package")

# Description

Simple python3 DNS server

# Installation

```shell
python3 -m pip install dns_local
```

Or directly from sources:

```shell
git clone git@github.com:doronz88/dns_local.git
cd dns_local
python3 -m pip install -e .
```

# Usage

```
Usage: python -m dns_local [OPTIONS]

  Start a DNS implemented in Python

Options:
  --bind TEXT      bind address
  --tcp            enable TCP server
  --udp            enable UDP server
  --domain TEXT    domain reply (e.g. example\\.com:127.0.0.1)
  --fallback TEXT  fallback dns server (e.g. 8.8.8.8)
  --help           Show this message and exit.
```

For example, consider the following usage:

```shell
python3 -m dns_local --bind 192.168.2.1:53 --udp --fallback 8.8.8.8 --domain kaki:192.168.2.1 --domain kaki2:192.168.2.1
```

This will start a `udp` DNS server listening at `192.168.2.1:53` with the two entries:

- `kaki1` -> `192.168.2.1`
- `kaki2` -> `192.168.2.1`

And use Google's DNS server (`8.8.8.8`) as a fallback for any entry not in given domain list.

Domains also support regex patterns. For example, the following will forward all domains to 127.0.0.1, except for google.com which will be forwarded to 8.8.8.8:

```shell
python3 -m dns_local --bind 192.168.2.1:53 --udp --domain "google\\.com:8.8.8.8" --domain ".*:127.0.0.1"
```
