Skip to main content
The DNS service provides comprehensive management of DNS zones and resource record sets with support for DNSSEC, SOA configuration, geo-balancing, and failover capabilities.

Service Structure

The DNS service is organized into several sub-services:
  • Zones - DNS zone management with DNSSEC and SOA configuration
  • Rrsets - Resource record sets (A, AAAA, CNAME, MX, TXT, SRV, NS)
  • Locations - Location-based routing information
  • Metrics - DNS query metrics and analytics
  • Pickers - Advanced traffic routing and balancing rules
  • NetworkMappings - CIDR range associations for private DNS resolution

Initialization

import (
    "github.com/G-Core/gcore-go"
    "github.com/G-Core/gcore-go/option"
)

client := gcore.NewClient(
    option.WithAPIKey("your-api-key"),
)

// Access DNS service
dnsService := client.DNS

Get Account Overview

Retrieve DNS account information including name servers.
ctx := context.Background()

info, err := client.DNS.GetAccountOverview(ctx)
if err != nil {
    log.Fatal(err)
}

fmt.Printf("Name Server 1: %s\n", info.Info.NameServer1)
fmt.Printf("Name Server 2: %s\n", info.Info.NameServer2)
fmt.Printf("Contact: %s\n", info.Info.Contact)

Response Fields

Info
object
required
Account information

DNS Lookup

Perform DNS lookups using various resolvers.
ctx := context.Background()

results, err := client.DNS.Lookup(ctx, dns.DNSLookupParams{
    Name: gcore.F("example.com"),
    RequestServer: gcore.F(dns.DNSLookupParamsRequestServerGcore),
})
if err != nil {
    log.Fatal(err)
}

for _, record := range *results {
    fmt.Printf("Type: %s, Name: %s, TTL: %d\n", record.Type, record.Name, record.Ttl)
    fmt.Printf("Content: %v\n", record.Content)
}

Parameters

name
string
Domain name to lookup
request_server
string
Resolver to use for the query. Options:
  • authoritative_dns - Use authoritative DNS servers
  • google - Use Google DNS (8.8.8.8)
  • cloudflare - Use Cloudflare DNS (1.1.1.1)
  • open_dns - Use OpenDNS
  • quad9 - Use Quad9 DNS
  • gcore - Use Gcore DNS servers

Response Fields

name
string
required
The queried domain name
type
string
required
DNS record type (A, AAAA, CNAME, etc.)
ttl
integer
required
Time to live in seconds
content
array
required
Array of record values

Next Steps

DNS Zones

Create and manage DNS zones

DNS Records

Manage DNS resource record sets

Build docs developers (and LLMs) love