Comments (6)
from dns.
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.
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.
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.
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.
I solved this issue by creating another TCP DNS server and using the same handler for both the servers.
from dns.
Related Issues (20)
- Add isdn record HOT 1
- Message pack and unpack fails with an empty name in a RR header HOT 1
- Duplicate DNS rCode? HOT 2
- dns: overflow unpacking uint16 HOT 2
- Can't retrieve TXT records for some domains HOT 1
- Trailing backslash results in non-FQDN targets HOT 6
- RFC: Parsing record contents directly HOT 6
- Wildcard domains as per RFC-4592 HOT 10
- digest type 3 (GOST94) HOT 2
- Request timeout middleware dns.HandlerFunc HOT 1
- IsDomainName total length check issues HOT 1
- Idiomatic way of printing the IPs / A records returned by a query HOT 4
- NewRR accepts invalid RR string HOT 2
- Public Key size from DNSKEY HOT 3
- IsDomainName gives an ok for domains longer than the RFC maximum length HOT 1
- DNSSEC grab public key from private for DNSKEY HOT 7
- `Server.WriteTimeout` is unused HOT 1
- Passing context param to `ListenAndServe` method
- TXT entry more than 255 characters will cause SERVFAIL HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dns.