V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
linkerlin
V2EX  ›  Python

[发布]一个DNS代理,支持TCP协议,支持内网私有DNS

  •  1
     
  •   linkerlin · 2013-06-13 11:27:28 +08:00 · 12668 次点击
    这是一个创建于 3971 天前的主题,其中的信息可能已经有所发展或是发生改变。
    BlackHolePy 一个支持TCP和白名单的DNS代理服务器

    https://github.com/linkerlin/BlackHolePy

    BlackHolePy
    ===========


    BlackHolePy是一个迷你型的DNS(代理)服务器。
    它的主要特色:
    1) 支持TCP DNS并支持白名单,从而在防止DNS污染的同时支持了内部私有域名解析。
    如果你的企业或组织在内部架设了自己的DNS Server,那么可以配置 config.py 里面的 WHITE_DNSS 。
    2) 内置了Cache, 带给你飞一般的感觉。尤其是访问国外网站的时候。





    运行需求
    ===========
    Python 2.7 或者 PyPy 2.0.2
    如果能安装 GEvent 和 dnspython 那就最好了。不装也能跑。
    安装GEvent以后,BlackHolePy运行在单线程模式,快捷并节约系统资源。
    在 PyPy 2.0.2 下测试通过。但是PyPy的coroutine暂时还没有支持。


    运行
    ===========
    sudo python dnsproxy.py


    然后把你的DNS服务器配置到 127.0.0.1 即可。


    感谢
    ===========
    本项目是基于以下两个项目的思路,重新编写的。
    https://github.com/henices/Tcp-DNS-proxy
    https://github.com/code4craft/blackhole
    在此感谢这两个项目的作者!
    8 条回复    1970-01-01 08:00:00 +08:00
    venmos
        1
    venmos  
       2013-06-15 22:48:09 +08:00
    已经clone到一台linux server上使用,装了gevent和pythondns感觉速度还不错,没装前有点慢。
    暂时没什么问题,good job
    fqrouter2
        2
    fqrouter2  
       2013-06-15 23:55:24 +08:00
    也许楼主的需求不是为了翻墙,但是与我为了anti-GFW做的fqdns很像: https://github.com/fqrouter/fqdns
    fqdns的目标是最快速度拿到没有被污染的解析结果,而且解析出来的IP还最好是最佳的线路。
    Ellonia
        3
    Ellonia  
       2013-06-16 02:31:36 +08:00
    这是不是一个简化版的dnsmasq?
    wowo2088
        4
    wowo2088  
       2013-06-16 14:54:37 +08:00
    明天试一试~~
    wowo2088
        5
    wowo2088  
       2013-06-17 16:36:49 +08:00
    cannot find dnspython
    cannot find gevent
    cannot find dnspython
    >> Please wait program init....
    >> Init finished!
    >> Now you can set dns server to 127.0.0.1
    listening at: ('0.0.0.0', 53)

    这个状态是正常的么~~~
    cannot find dnspython
    cannot find gevent
    cannot find dnspython
    这三行不碍事吧~
    dnser
        6
    dnser  
       2013-06-17 18:35:50 +08:00
    和DNSCrpyt有什么区别?
    linkerlin
        7
    linkerlin  
    OP
       2013-07-07 02:17:34 +08:00
    出现没有gevent提示的,可以装一下gevent。
    虽然稍微有些麻烦。
    不装也能跑,但是不是很快了。
    pythonee
        8
    pythonee  
       2013-09-15 11:48:54 +08:00
    能先说为什么需要dns代理吗,我是小白
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2706 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 11:19 · PVG 19:19 · LAX 04:19 · JFK 07:19
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.