Country Base DNS Answer


i need to add country based dns A ptr record, for ex;

A ptr (ALL) -> abc pointing to
A ptr (DE) -> abc pointing to
A ptr (US) -> abc pointing to

i need to add;
if some one resolveing abc subdomain, and is on germany,
i need to send him to different ip, if he on us and resolve from, i need to send diffrent ip for same subdomain.

its possible? i need to do this on dns level, and its possible make it on cloudflare?


Take a look at Load Balancing! That’s exactly what it can do.

I didn’t quite get what you are trying to say in the second part, though.


I think a possible approach would be some fancy .htaccess rewrites based upon the CF country header:

As of now, I don’t believe Cloudflare has this DNS feature. I only know it from Amazon’s Route 53:

As for Load Balancing, here are the instructions. Geo Routing is about Âľ the way down the page.


hi matteo,
I want to return a different ip address for the subdomain, looking at the country of the DNS querying ip address.

if someone querying same subdomain from U.S. , i want to send him to diffrent ip,
if someone querying same subdomain from DE. , i want to send him to diffrent ip,

and need to do this on dns level, and with cloudflare its possible ?


There’s a lot packed into your question… so potentially several answers. First if the A record is being proxied by Cloudflare, it doesn’t matter what IP address is being returned to the user. The IP address will be an address which points to Cloudflare’s edge. What matters in that instance based on what you’ve described is where Cloudflare routes it.

As @sdayman mentioned you can use Cloudflare’s Geo Load Balancing, but as a point of clarification, load balancing occurs based on the region/pop the user connects to. That is not necessarily the same place that the user resides for a variety of reasons.

List of regions:

Cloudflare Load Balancers can also be configured on a per POP basis for Enterprise customers which allows more granular control, but again a user doesn’t always connect to a POP in country.

Users can also be routed based on their country using workers with the CF-Country header and a resolve override.

What your original question asked about, at least as stated, I think was if Cloudflare supports EDNS-Client-Subnet. The DNS Cloudflare offers does not, however Cloudflare offers the solutions mentioned above and also offers a service called DNS Firewall. In the DNS Firewall offering if your DNS server supports and is configured for EDNS-Client-Subnet Cloudflare can support/protect that server.

But that would only be useful for responses which weren’t being proxied by Cloudflare.


thanks for replay, i trying do,

I will buy a server from Germany, i ll say to datacenter, please block all incoming traffic from outside germany.
but this rule will block google like search engine.
i dont want to block search engine like services, and i dont want to clone my web page links.
for this require country based dns answer, looking at the resolveing ip addresses.

closed #7

This topic was automatically closed after 14 days. New replies are no longer allowed.