Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two or more records per domain #16

Open
s0i37 opened this issue Jun 13, 2018 · 3 comments
Open

Two or more records per domain #16

s0i37 opened this issue Jun 13, 2018 · 3 comments

Comments

@s0i37
Copy link

s0i37 commented Jun 13, 2018

Hello.
How can I specify many records for something domain, like this:
*zone.com=1.2.3.4, 5.6.7.8

@gokalper
Copy link

HI This would be really useful, I also need this functionality

@adfoster-r7
Copy link

Would love this functionality too 👍

@adfoster-r7
Copy link

I hacked this in to support only the scenario that I needed, ipv4 and ipv6 lookups.

Multiple values are separated by commas:

sudo -E python3 ./dnschef.py --interface 0.0.0.0 --fakeip '127.0.0.1,192.168.200.201' --fakeipv6 '2001:db8:3333:4444:5555:6666:7777:8888,2001:db8:3333:4444:5555:6666:7777:5555'

Changes:

diff --git a/dnschef.py b/dnschef.py
index c57924d..bfe509b 100755
--- a/dnschef.py
+++ b/dnschef.py
@@ -127,9 +127,17 @@ class DNSHandler():
                     log.info(f"{self.client_address[0]}: cooking the response of type '{qtype}' for {qname} to {fake_record}")
 
                     # IPv6 needs additional work before inclusion:
+
                     if qtype == "AAAA":
-                        ipv6_hex_tuple = list(map(int, ip_address(fake_record).packed))
-                        response.add_answer(RR(qname, getattr(QTYPE,qtype), rdata=RDMAP[qtype](ipv6_hex_tuple)))
+                        for ipv6 in fake_record.split(','):
+                            ipv6_hex_tuple = list(map(int, ip_address(ipv6).packed))
+                            response.add_answer(RR(qname, getattr(QTYPE,qtype), rdata=RDMAP[qtype](ipv6_hex_tuple)))
+
+                    elif qtype == "A":
+                        for ipv4 in fake_record.split(','):
+                            # dnslib doesn't like trailing dots
+                            if ipv4[-1] == ".": ipv4 = ipv4[:-1]
+                            response.add_answer(RR(qname, getattr(QTYPE,qtype), rdata=RDMAP[qtype](ipv4)))
 
                     elif qtype == "SOA":
                         mname,rname,t1,t2,t3,t4,t5 = fake_record.split(" ")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants