Giter Site home page Giter Site logo

pydnsserver's Introduction

PyDNSServer

一个Python实现的简单的可配置的DNS服务程序。

支持域名完全匹配(相等)或正则匹配(re.match)。比如***www.baidu.com***对应***www.baidu.com***,***\S+\.baidu\.com***对应任意的baidu.com二级域名,比如***img.baidu.com***、***cloud.baidu.com***等

支持指定ip、允许、禁止策略:

  • 指定ip: 直接返回该指定的ip地址
  • 允许: 返回该域名对应的正真ip地址
  • 禁止: 不对该域名进行解析,即返回解析失败

dnf.cfg文件内容如下:

# 一行一个配置
# 主机名(域名)支持正在方式配置
# 策略支持ip地址或者允许(allow)或者禁止(deny)
# 对于同时符合多个正则的域名,优先级从上到下

# 格式:
#  主机名或正则模式   ip或allow或deny
# 

# more info : https://github.com/sintrb/PyDNSServer

#  hostname|pattern   ip|allow|deny

# allow www.baidu.com
www.baidu.com allow

# deny xxx.360.com
\S+\.360\.com deny

# set www.qq.com with ip 192.168.0.100
www.qq.com 192.168.0.100

# deny other hostname
.* deny

使用 首先,运行服务(使用DNS的53端口,需要管理员权限):

# python RunMain.py

直接在本机测试:

> nslookup www.baidu.com 1270.0.0.1

> nslookup www.360.com 1270.0.0.1

pydnsserver's People

Contributors

sintrb avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.