Answer taken from SO here Author: Swift. Adapted to fit the question. Also, have a read here on general SPF stuff.
We started with:
v=spf1 a mx include:_spf.google.com include:servers.mcsv.net include:sendgrid.net ~all
We get 10 total lookups before we throw the
Too many DNS lookups error:
2 (Initial TXT & SPF Lookups)
2 (a & mx Lookups)
So without even following the included SPF records, we have 7 lookups.
Now, let's dive a level deeper.
The google SPF record evaluates to:
v=spf1 include:_netblocks.google.com include:_netblocks6.google.com ?all
Each of which resolve to the following values:
v=spf1 ip4:126.96.36.199/19 ip4:188.8.131.52/19 ip4:184.108.40.206/20 ip4:220.127.116.11/18 ip4:18.104.22.168/17 ip4:22.214.171.124/20 ip4:126.96.36.199/16 ip4:188.8.131.52/20 ip4:184.108.40.206/20 ip4:220.127.116.11/16 ?all
v=spf1 ip6:2607:f8b0:4000::/36 ip6:2a00:1450:4000::/36 ?all
So google gives us 2 more lookups, bringing the total up to 9 Lookups.
Mailchimp is a bit of a doosey because it adds a whole 3 extra lookups:
v=spf1 include:spf1.mcsv.net include:spf2.mcsv.net include:spf.mandrillapp.com ?all
I would imagine that depending on what you're sending through Mailchimp, you might be able to remove one or two of these records (but you'll have to evaluated that yourself).
Anyway, those resolve to the following:
v=spf1 ip4:18.104.22.168/31 ip4:22.214.171.124/29 ip4:126.96.36.199/29 ip4:188.8.131.52/29 ip4:184.108.40.206/27 ip4:220.127.116.11/27 ip4:18.104.22.168/26 ?all
v=spf1 ip4:22.214.171.124/24 ip4:126.96.36.199/27 ip4:188.8.131.52/27 ip4:184.108.40.206/27 ip4:220.127.116.11/24 ip4:18.104.22.168/20 ip4:22.214.171.124/24 ?all
v=spf1 ip4:126.96.36.199/24 ip4:188.8.131.52/24 ?all
This brings us up to a total of 12 Lookups (Which is two over the limit already).
SendGrid ends up being the fewest number of additional lookups for us.
v=spf1 ip4:184.108.40.206/24 ip4:220.127.116.11/24 ip4:18.104.22.168/27 ip4:22.214.171.124/24 ip4:126.96.36.199/27 ip4:188.8.131.52/28 ip4:184.108.40.206/27 ip4:220.127.116.11/24 ip4:18.104.22.168/24 ip4:22.214.171.124/24 ip4:126.96.36.199/24 include:sendgrid.biz ~all
So the only additional lookup here is
sendgrid.biz, which evaluates to:
v=spf1 ip4:188.8.131.52/24 ip4:184.108.40.206/24 ip4:220.127.116.11/24 ip4:18.104.22.168/24 ip4:22.214.171.124/24 ip4:126.96.36.199/24 ip4:188.8.131.52/24 ip4:184.108.40.206/20 ip4:220.127.116.11/19 ip4:18.104.22.168/20 ~all
This brings our grand total up to 14 lookups.
So our grand total is 14 Lookups. We need to get that down to 10. I've outlined a couple of options below, you may need to use more than 1 of them to get it down.
Directly include some of the redirected spf records. Now that we know which servers the spf records redirect to, you could cut out the middleman and include them directly. Note: If any of the services end up changing their SPF records, you'll have to go through the process of updating yours manually.
Remove some of the services that you're using. Not sure what your use case is for having all of these services, but there's definitely some overlap that you might be able to use. For instance, SendGrid supports (1) transactional outgoing mail, (2) newsletter / marketing emails, and (3) incoming mail. So there may be some reducible redundancy.
Remove the MX record if it is redundant. Depending on your setup, the MX lookup can be redundant.