make a gcp cloud dns server and blacklist certain domains

109 Views Asked by At

Is it possible to create a gcp cloud dns server that works like any regular dns eg 8.8.8.8 but has a list of blocked domains? The requirement is that the dns server when set should work with low latency from multiple countries. Is this a task that gcp's Cloud Dns service can handle for multiple users say 10,000+?

2

There are 2 best solutions below

2
On BEST ANSWER

Google Cloud DNS provides name servers for only your domains. Cloud DNS is not a public recursive name server (public DNS resolver) similar to Google Public DNS.

Yes, Cloud DNS can support 10,000 queries per second. The concept of users does not exist for Cloud DNS.

1
On

i am not much experienced in it but diving it a try pleas point any mistake of mine if any one founds in order to create a DNS server with blocked domains using Google Cloud DNS, you can follow these steps:

1st.Set up a Google Cloud Platform (GCP) project and enable the Cloud DNS API. which you have done for sure

2nd. then Create a managed zone in Cloud DNS for your domain.

  1. add the necessary DNS records for your domain.

  2. Configure the DNS server to block specific domains by creating DNS firewall rules.

you may lave littel bit of idea from the below logic example to create a DNS firewall rule to block a domain using the Google Cloud DNS API:

from google.cloud import dns

def create_dns_firewall_rule(project_id, zone_name, domain):
    client = dns.Client(project=project_id)
    zone = client.zone(zone_name)

    rule = zone.firewall_rules.build(
        action="deny",
        description="Block access to a specific domain",
        direction="outbound",
        priority=1000,
        target="dnsQueries",
        target_types=["dnsName"],
        targets=[domain],
    )

    zone.firewall_rules.add(rule)
    zone.update()

# Usage example
project_id = "your-project-id"
zone_name = "your-zone-name"
domain_to_block = "example.com"

create_dns_firewall_rule(project_id, zone_name, domain_to_block)

try it and let me know.