Giter Club home page Giter Club logo

Comments (6)

miekg avatar miekg commented on June 1, 2024 1

from dns.

semihalev avatar semihalev commented on June 1, 2024 1

Short explain;

"When a DNS response exceeds the maximum packet size that can be transmitted over UDP (typically 512 bytes without EDNS), the server sends back a truncated response to the client. This truncated response indicates to the client that the full response was not received due to size constraints.

In such cases, the client needs to establish a TCP connection to the DNS server to retrieve the complete DNS response. TCP is used as an alternative protocol when UDP responses are truncated, as it allows for the transmission of larger data payloads without the limitations of UDP packet size.

Therefore, TCP is essential for handling large DNS responses that exceed the UDP packet size limit and ensuring that clients receive complete and accurate DNS information. Without TCP, clients may encounter incomplete or inaccurate DNS data, leading to potential issues with DNS resolution and service reliability."

You set UDPSize as 65535 but this cannot be work in real world. OS or other limitations maybe stop that. If your server received truncated response from UDP response then they must be try connect TCP connection.

Did you check the response size for the queries?

from dns.

gouravkrosx avatar gouravkrosx commented on June 1, 2024

You mean second dns.Server for tcp? as I have already one for udp. And using the same ServeDNS handler for this server as well.

from dns.

gouravkrosx avatar gouravkrosx commented on June 1, 2024

Thanks for the detailed answer, I haven't checked the request size and according to your explanation it should be changed but my problem is that how can i use my existing handler (ServeDNS) from the handleConnection as i am getting dns queries over tcp server. Right now i have configured my client to use tcp server to solve the problem if any query comes via tcp in future.One quick way is to make another dns server for tcp and use different port and i guess that server can use the same ServeDNS handler which udp dns server is using. Then why can't i use my existing connection getting in handleConnection to be handled in ServeDNS for dns queries (coming at port 53).

I hope you understood my thought process.

from dns.

semihalev avatar semihalev commented on June 1, 2024

You can use same ServeDNS handler. You must be check response was truncated or not and try TCP query in resolveDNSQuery function. You can check the this short example functions;

func Exchange(req *dns.Msg, addr string, net string) (*dns.Msg, error) {
	client := dns.Client{Net: net}
	resp, _, err := client.Exchange(req, addr)

	if err == nil && resp.Truncated && net == "udp" {
		return Exchange(req, addr, "tcp")
	}

	return resp, err
}

func Query() {
        req := new(dns.Msg)
        req.SetQuestion("cisco.com", dns.TypeTXT)
        resp, err := Exchange(req, "8.8.8.8:53", "udp")
}

Note: You must be consider your ServeDNS response to client. If your client cannot be get large UDP response size, you need return your client truncated tag with empty answer reponse and then your client can try TCP connection to your server.

from dns.

gouravkrosx avatar gouravkrosx commented on June 1, 2024

I solved this issue by creating another TCP DNS server and using the same handler for both the servers.

from dns.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.