All pastes #40518 Raw Edit

fakeDNS.py

public python v1 · immutable
#40518 ·published 2006-02-07 11:03 UTC
rendered paste body
from twisted.application import service,internetfrom twisted.internet import reactorfrom twisted.names import hosts,server,dnsfrom twisted.python import logimport sysval = "192.168.1.1"def rewritten(file, name):    print "Requested",name    return valif __name__ == '__main__':    log.startLogging(sys.stdout, 0)    hosts.searchFileFor = rewritten    c = hosts.Resolver(file = '/etc/hosts')    f = server.DNSServerFactory(None, [],                                [c,], verbose=False)    p = dns.DNSDatagramProtocol(f)    f.noisy = 0       s = internet.UDPServer(53, p, interface='127.0.0.1')    s.startService()    reactor.run()