Created
March 4, 2016 09:36
-
-
Save akkijp/f0f00c5632e09a341a99 to your computer and use it in GitHub Desktop.
check_ip_address
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "log" | |
| "github.com/miekg/dns" | |
| ) | |
| func main() { | |
| target := "getd.xyz" | |
| // server := "220.152.39.12" | |
| server := "8.8.8.8" | |
| c := dns.Client{} | |
| m := dns.Msg{} | |
| m.SetQuestion(target+".", dns.TypeA) | |
| r, t, err := c.Exchange(&m, server+":53") | |
| if err != nil { | |
| log.Fatal(err) | |
| } | |
| log.Printf("Took %v", t) | |
| if len(r.Answer) == 0 { | |
| log.Fatal("No results") | |
| } | |
| for _, ans := range r.Answer { | |
| Arecord := ans.(*dns.A) | |
| log.Printf("%s", Arecord.A) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment