Skip to main content

A non-poisonous and CDN-friendly Recursive DNS Resolver

Project description

Build Status Coverage Status

greendns

A DNS recursive resolve server to avoid result being poisoned and friendly to CDN. It will qeury dns servers at the same time and don’t wait for all responses. It’s more efficient and quicker than ChinaDNS

You must config at least two dns servers. One part is local and poisoned, the other part is unpoisoned(tunnel through VPN or use OpenDNS 443/5353 port, dnscrypt-proxy is recommended)

How it works

First filter poisoned ip with blocked iplist with -b argument.
Second,
                                       | A record is local | A record is foreign
    local and poisoned dns server      |    a              |   b
    unpoisoned dns server              |    c              |   d

From the matrix, we get the result as follows,
ac: use local dns server result
ad: use local dns server result
bc: impossible. use unpoisoned dns server result
bd: use unpoisoned dns server result

Conclusion,
Using local dns server result if returned A record is local.
Using unpoisoned dns server result if returned A record is Foreign.

It has two assumptions, * the polluted domain is foreign. * the A record in poisoned response is foreign.

Install

pip install greendns

Usage

greendns -r greendns -f /usr/etc/greendns/localroute.txt -b /usr/etc/greendns/iplist.txt

Configure

greendns -r greendns -h
usage: greendns.py [-h] [-r HANDLER] [-p PORT] [-u UPSTREAM] [-t TIMEOUT]
                   [-l LOGLEVEL] [-m MODE] -f LOCALROUTE -b BLACKLIST
                   [--rfc1918] [--cache]

optional arguments:
  -h, --help
  -r HANDLER, --handler HANDLER
                        Specify handler class, greendns|quickest (default:
                        None)
  -p PORT, --port PORT  Specify listen port or ip (default: 127.0.0.1:5353)
  -t TIMEOUT, --timeout TIMEOUT
                        Specify upstream timeout (default: 1.0)
  -l LOGLEVEL, --log-level LOGLEVEL
                        Specify log level, debug|info|warning|error (default:
                        info)
  -m MODE, --mode MODE  Specify io loop mode, select|epoll (default: select)
  --lds LDS             Specify local poisoned dns servers (default:
                        223.6.6.6:53,114.114.114.114:53)
  --rds RDS             Specify unpoisoned dns servers (default:
                        208.67.222.220:443,193.112.15.186:2323)
  -f LOCALROUTE, --localroute LOCALROUTE
                        Specify local routes file (default: None)
  -b BLACKLIST, --blacklist BLACKLIST
                        Specify ip blacklist file (default: None)
  --rfc1918             Specify if rfc1918 ip is local (default: False)
  --cache               Specify if cache is enabled (default: False)

Acknowledgements

  • @clowwindy: the author of the ChinaDNS

License

This project is under the MIT license. See the LICENSE file for the full license text.

Project details


Release history Release notifications

This version
History Node

0.9.2

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
greendns-0.9.2.tar.gz (80.0 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page