Skip to content

Instantly share code, notes, and snippets.

@nathanleclaire
Last active August 8, 2016 21:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathanleclaire/47657140ce0005b90bdea7443e784b10 to your computer and use it in GitHub Desktop.
Save nathanleclaire/47657140ce0005b90bdea7443e784b10 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"log"
"github.com/miekg/dns"
)
const (
service = "servers"
dockerDNSServer = "127.0.0.11:53"
)
func main() {
m := &dns.Msg{}
m.SetQuestion("tasks."+service+".", dns.TypeA)
c := &dns.Client{}
in, _, err := c.Exchange(m, dockerDNSServer)
if err != nil {
log.Panic(err)
}
for _, answer := range in.Answer {
if a, ok := answer.(*dns.A); ok {
fmt.Println(a.A)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment