提供一个非常简单的dns服务器。
pydnserver的Python项目详细描述
提供一个非常简单的dns服务器。它提供以下功能: *将主机名解析为IP地址。(查记录) *将主机名解析为主机名。(CNAME查找)
启动DNS服务器:
from pydnserver import DNSServer ip = u'192.168.0.10 # Set this to the IP address of your network interface. dns = DNSServer(interface=ip, port=53) dns.start() try: while True: pass except KeyboardInterrupt: dns.stop()
这将启动一个将所有请求转发到google dns服务器(8.8.8.8,8.8.4.4)的裸体dns服务器。
当前可以使用configurationutil.configuration接口管理配置。
配置是动态的。如果更改,它将反映在下一个请求中。