Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat]: Add support for recursive DNS #11

Open
benjivesterby opened this issue Dec 22, 2022 · 3 comments
Open

[Feat]: Add support for recursive DNS #11

benjivesterby opened this issue Dec 22, 2022 · 3 comments

Comments

@benjivesterby
Copy link
Member

Possibly with the use of: https://github.com/0xRyuk/IPX

@benjivesterby
Copy link
Member Author

@benjivesterby
Copy link
Member Author

@benjivesterby
Copy link
Member Author

package main

import (
	"fmt"
	"github.com/miekg/dns"
)

func main() {
	c := new(dns.Client)
	m := new(dns.Msg)
	m.SetQuestion(dns.Fqdn("example.com"), dns.TypeA) // Replace "example.com" with your domain
	m.RecursionDesired = true

	r, _, err := c.Exchange(m, "8.8.8.8:53") // Replace "8.8.8.8:53" with your DNS server
	if err != nil {
		fmt.Println(err)
		return
	}

	if r.Rcode != dns.RcodeSuccess {
		fmt.Println("Failed to get an answer:\n", r)
		return
	}

	for _, ans := range r.Answer {
		Arecord := ans.(*dns.A)
		fmt.Printf("Name: %s \n", Arecord.Hdr.Name)
		fmt.Printf("A record IP: %s \n", Arecord.A)
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant