Total Pageviews

Wednesday 6 July 2016

SimpleDNS

https://badge.fury.io/py/simpledns.png
A lightweight yet useful proxy DNS server designed to cope with complicated Internet environment in China, inspired by ChinaDNS , dnsmasq-chinadns and fqdns, powered by Python Twisted.

Requirement

  • Python 2.7(其实要求python的版本最低为3.4)
  • Twisted
  • Tornado for using Tornado IOLoop(optional)

Install

  • Linux/Mac OS X:
    # Clone this project
    $ sudo python setup.py install
    
  • Windows

Usage

Run sudo simpledns on your local machine. Then set your DNS server to 127.0.0.1.
$ dig www.twitter.com +short
twitter.com.
199.59.149.230
199.59.148.10
199.59.150.7
199.59.150.39
Note that the default cache lifetime depends on the ttl of DNS answer. You may want to set a larger ttl using --min-ttl to extend the cache lifetime.

Advanced

$ simpledns -h
usage: simpledns [-h] [-b BIND_ADDR] [-p BIND_PORT]
                 [--upstream-ip UPSTREAM_IP] [--upstream-port UPSTREAM_PORT]
                 [--query-timeout QUERY_TIMEOUT] [--min-ttl MIN_TTL]
                 [--max-ttl MAX_TTL] [--cache-size CACHE_SIZE] [-t]
                 [--hosts-file HOSTS_FILE] [--dispatch-conf DISPATCH_CONF]
                 [-v {0,1,2}] [-q] [-V]

A lightweight yet useful proxy DNS server

optional arguments:
  -h, --help            show this help message and exit
  -b BIND_ADDR, --bind-addr BIND_ADDR
                        local address to listen
  -p BIND_PORT, --bind-port BIND_PORT
                        local port to listen
  --upstream-ip UPSTREAM_IP
                        upstream DNS server ip address
  --upstream-port UPSTREAM_PORT
                        upstream DNS server port
  --query-timeout QUERY_TIMEOUT
                        time before close port used for querying
  --min-ttl MIN_TTL     the minimum time a record is held in cache
  --max-ttl MAX_TTL     the maximum time a record is held in cache
  --cache-size CACHE_SIZE
                        record cache size
  -t, --tcp-server      enables TCP serving
  --hosts-file HOSTS_FILE
                        hosts file
  --dispatch-conf DISPATCH_CONF
                        URL dispatch conf file
  -v {0,1,2}, --verbosity {0,1,2}
                        output verbosity
  -q, --quiet           disable output
  -V, --version         print version number and exit

Configuration

Configuration file is at /usr/local/etc/simpledns/dispatch.conf.
Dispatch conf file uses the same rule as in Dnsmasq. 'Address' and 'Server' rules are supported.
address=/example1.com/1.1.1.1
server=/example2.com/1.1.1.2
Default dispatch conf file is from dnsmasq-china-list.

Fake ip list file is at /usr/local/ect/simpledns/iplist/txt. The source is ChinaDNS.
from https://github.com/skyline75489/SimpleDNS

用法:
sudo simpledns --bind-addr 127.0.0.1 --bind-port 53 --upstream-ip 8.8.8.8 --upstream-port 53
--------

SimpleDNS,又一个DNS代理服务器

我就开始在网上找其他的解决方案。
我找到了ChinaDNSfqdns。他们解决DNS污染的思路是,将GFW返回的假冒记录忽略掉,这个思路比我之前想方设法得到正确的结果来的简单多了,不过局限性也很明显,需要维护一个GFW的假冒地址列表。还好GFW那帮人看起来也挺懒的,来回来去就用那么几个地址,一时半会儿应该不会怎么变化。
ChinaDNS支持的功能比较少,fqdns支持的功能多一点(国内域名使用国内DNS解析,强制TCP等)。但是有些我想要的功能它们都没有,比方说我很喜欢Dnsmasq的address和server规则,可以很灵活的根据地址配置不同的DNS服务器,还有pdnsd的根据min-ttl设置缓存时间的功能。等那两个项目的作者开发出来看起来是不现实了,于是我就自己用Twisted框架写了一个SimpleDNS,它支持了这些功能,同时由于使用了Twisted框架,保证了代码的轻巧和灵活性。它是我现在的DNS解决方案。
PS:在中国想好好上个网实在太费劲了
PPS:折腾了半天,还是Hosts大法好啊.

from https://skyline75489.github.io/post/2014-9-7_simpledns-the-proxy-dns-server.html
--------

相关帖子:https://briteming.blogspot.com/2019/10/godns-proxy.html