Handling Reverse DNS Lookup after moving to Cloudflare


My application receives webhooks from sendgrid inbound parser.
To confirm that the webhooks indeed came from Sendgrid, I have to do a reverse DNS lookup on the IP. This currently works well.

My question is, after moving the site to Cloudflare, I understand that all IPs will be Cloudflare’s.
How do I handle this so my application can confirm that a request came from sendgrid (through cloudflare)

Note - we confirmed that Sendgrid does not allow us to set a security key or provide a list of IPs for this particular functionality, so we have to do a reverse lookup as recommended by their support team.

You will want to restore the original IP address, which Cloudflare passes along as a header.

If you need to implement this directly into your application, there are basically 2 steps:

  1. Confirm the request came from a Cloudflare IP (IP Ranges)
  2. Read the IP from the CF-Connecting-IP header.
1 Like

Thank you!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.