mileusna/spf

Lookup not working?

Closed this issue · 3 comments

muety commented

I might be mistaken here or maybe I'm overlooking something. If so, feel free to close the issue again. However, please take a look at the following example:

func main() {
  result := spf.CheckHost(net.ParseIP("213.203.238.1"), "mailbox.org", "test123@mailbox.org", "")
  println(result) // outputs NONE
}

However, the SPF record for mailbox.org looks like so:

v=spf1 ip4:213.203.238.0/25 ip4:195.10.208.0/24 ip4:91.198.250.0/24 ip4:80.241.56.0/21 ip6:2001:67c:2050::/48 ip4:80.241.60.0/24 mx ~all

Without being too familiar with SPF, I would expect that 213.203.238.1 is well within the allowed range and the lookup should return a PASS?

muety commented

Looks like a problem with the TXT lookup itself. If I temporarily replace lookupTXT() in resolver.go with net.LookupTXT() everything works fine. For some reason, the DNS query contains no answers. Any ideas why?

I had the same issue. I discovered (wireguard) that the EDNS OPT record wasn't used.

It uses Google's 8.8.8.8 DNS server by default. I will implement setting for custom DNS server as proposed in #1 so you can use your own DNS server for resolver.
I don't use net.LookupTXT() since it returns error if TXT doesn't exists which makes it tricky to produce right SPF reply in that case (should be NONE).

I will check the settings recommended by @juergenhoetzel as well.