推荐学习书目
› 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
dbow
V2EX  ›  Python

分享自写的 DNS 污染过滤程序。

  •  1
     
  •   dbow ·
    maliubiao · Aug 19, 2014 · 3360 views
    This topic created in 4464 days ago, the information mentioned may be changed or developed.
    又一个DNS污染过滤项目,只不过用起来简单爆了。
    项目地址: https://github.com/maliubiao/simple_dns
    说明:
    python gfw.py domain
    结果是查询domain的A Record, 用黑名单过滤污染的包, 返回正确的包的结构dump.

    python localdns.py
    在本地53端口建立DNS转发,默认转发到8.8.8.8, 同样过滤污染的包。
    在/etc/resolv.conf添加127.0.0.1作为默认的NS即可

    dns.py
    解析dns包的库

    总共不到一千行代码, 拿来即用, 不需要配置, 代码非常简单易懂, 修改方便, 转发包采EPOLL高效异步,CPU使用平均0.05%, 仅支持linux。

    不过仅过滤DNS污染效果不明显,很多是直接IP屏蔽的,也有有效的,比如dropbox使用了localdns之后就能用了。


    欢迎反馈,欢迎fork.
    Supplement 1  ·  Aug 21, 2014
    已经增加了通用的select支持, windows, linux, BSD(OSX, BSD系列)应该都能用了。
    10 replies  •  2014-09-20 14:26:19 +08:00
    JoeyChan
    JoeyChan
    Aug 19, 2014❤️1
    1
    很复杂的样子,我一直用iptables过滤,大概几十条规则就可以解决污染了。
    dbow
    dbow
    OP
    Aug 19, 2014
    2
    @JoeyChan localdns挺简单的,而且你可以看到每一个DNS请求的域名,以及域名是不是被gfw污染。
    gyteng
    gyteng
    Aug 19, 2014
    3
    最近开始学nodejs,昨天也写了个简单粗暴的
    https://github.com/gyteng/smartDNS
    20150517
    20150517
    Aug 19, 2014
    4
    重写轮子啊,你dns功能可以直接用twisted包里的dns服务器啊
    whtsky
    whtsky
    Aug 19, 2014 via iPhone
    5
    能不能别强制用 epoll ...
    run2
    run2
    Aug 20, 2014
    6
    没有 EPOLL -.-
    dbow
    dbow
    OP
    Aug 20, 2014
    7
    @whtsky
    @sobigfish
    已添加select.select支持. :)
    run2
    run2
    Aug 21, 2014
    8
    youjustdoit
    youjustdoit
    Sep 20, 2014
    9
    @JoeyChan dns污染很讨厌,正在学习iptables,如何用iptables过滤dns污染,能否分享一个
    JoeyChan
    JoeyChan
    Sep 20, 2014
    10
    @youjustdoit
    参考
    https://code.google.com/p/openwrt-gfw/wiki/AntiDNSPoisoning
    使用这个教程一段时间就会自动生成几十条过滤规则,基本可以彻底杜绝污染,而且不影响本地cdn加速。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4032 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 73ms · UTC 07:09 · PVG 15:09 · LAX 23:09 · JFK 02:09
    ♥ Do have faith in what you're doing.