Golang ProgramsGolang Programs

Go program to find Name Server (NS) record of a domain

The NS records describe the authorized name servers for the zone. The NS also delegates subdomains to other organizations on zone files. The net.LookupNS() function takes a domain name(facebook.com) as a string and returns DNS-NS records as a slice of NS structs.
package main
 
import (
	"fmt"
	"net"
)
 
func main() {
	nameserver, _ := net.LookupNS("facebook.com")
	for _, ns := range nameserver {
		fmt.Println(ns)
	}
}

The NS records that support the domain are shown below:

C:\golang\dns>go run example4.go
&{a.ns.facebook.com.}
&{b.ns.facebook.com.}