Here’s how to send TCP fallback DNS queries with dnspython.
dnspython supports TCP fallback since version 1.10.
many thanks.
Looking into the code also helps me understand dns.resolver.Resolver.
install dnspython on ubuntu 13.04
# tail -1 /etc/lsb-release
DISTRIB_DESCRIPTION="Ubuntu 13.04"
# uname -ri
3.8.0-25-generic x86_64
# apt-get install python-dnspython –y
|
[ enable EDN0 ]
# cat enable_edns0.py -n
# cat -n enable_edns0.py
1 #!/usr/bin/env python
2
3 import dns.resolver
4
5 myresolver = dns.resolver.Resolver(configure=False)
6 myresolver.use_edns(0,0,4096)
7 myresolver.nameservers = ['192.168.10.200']
8 result = myresolver.query('www.foo.bar','a',source="192.168.10.100")
9 for i in result:
10 print i
|
use_edns(0,0,4096)
enable edns0 = 0 , disable edns0 = -1 ,
edns version
payload size
capture data when dnspython sending a query to the DNS server.
Queries
www.foo.bar: type A, class IN
Name: www.foo.bar
Type: A (Host address)
Class: IN (0x0001)
Additional records
<Root>: type OPT
Name: <Root>
Type: OPT (EDNS0 option)
UDP payload size: 4096
Higher bits in extended RCODE: 0x0
EDNS0 version: 0
Z: 0x0
Data length: 0
|
[ disable EDNS0 ]
# cat disable_edns0.py -n
1 #!/usr/bin/env python
2
3 import dns.resolver
4
5 myresolver = dns.resolver.Resolver(configure=False)
6 myresolver.use_edns(-1,0,4096)
7 myresolver.nameservers = ['192.168.10.200']
8 result = myresolver.query('www.foo.bar','a',tcp=False,source="192.168.10.100",source_port=50000)
9 for i in result:
10 print i
|
or you can disable edns0 by just removing the line “use_edns ..” .
cap data ( dnspython to DNS server )
Queries
www.foo.bar: type A, class IN
Name: www.foo.bar
Type: A (Host address)
Class: IN (0x0001)
|
[ send only TCP queries without sending UDP queries ]
# cat -n send_TCP_queries.py
1 #!/usr/bin/env python
2
3 import dns.resolver
4
5 myresolver = dns.resolver.Resolver(configure=False)
6 myresolver.use_edns(0,0,4096)
7 myresolver.nameservers = ['192.168.10.200']
8 result = myresolver.query('www.foo.bar','a',tcp=True,source="192.168.10.100")
9 for i in result:
10 print i
|
nice tool!
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.