sdgathman / pyspf

Other
49 stars 26 forks source link

Allow custom DNS server #29

Open slavkoja opened 3 years ago

slavkoja commented 3 years ago

Please, add option to use custom DNS server address.

I have split horizon DNS with SMTP server in my local infrastructure, thus i get local IP for A/MX records from system resolver and i cannot use this project to verify public IP with own SPF... Using custom DNS server will allow to bypass this restriction.

sdgathman commented 3 years ago

By default, pyspf uses dnspython or py[3]dns. Those packages have options for DNS server. For instance, py3dns calls DNS.Base._DiscoverNameServers() which populates global dictionary Base.defaults with lists at 'domain' and 'server'. The method is platform dependent (e.g. reading /etc/resolv.conf). So for py(3)dns I would do something like:

import DNS
DNS.Base.defaults['server'] = [ '8.8.8.8', '8.8.4.4' ]
sdgathman commented 3 years ago

The hook in pyspf itself is spf.DNSLookup. By default this is set to spf.DNSLookup_dnspython, or if that can't be imported, to spf.DNSLookup_pydns. You could supply your own DNSLookup.

slavkoja commented 3 years ago

It seems, that i was not clean enough. I mean to add the command line option to spfquery.py script.

sdgathman commented 3 years ago

That can be done.