-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
On MAC, we used the code
dns.HandleFunc(".", handleDNSRequest) defer dns.HandleRemove(".") // start serverUDP serverUDP := &dns.Server{Addr: "127.0.0.1:53", Net: "udp"} go serverUDP.ListenAndServe() defer serverUDP.Shutdown()
It bound properly on specific IP and PORT as shown below:
udp4 0 0 127.0.0.1.53 .
But as soon as we write DNS response from handler function like
msg.Authoritative = true domain := msg.Question[0].Name msg.Answer = append(msg.Answer, &dns.A{ Hdr: dns.RR_Header{Name: domain, Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: 60}, A: net.ParseIP("1.2.3.4"), }) w.WriteMsg(&msg)
Binding changes to as shown below:
udp4 0 0 *.53 .
This impacts other DNS server which is running on another interface.
I debugged the UDP DNS code and figured out that after the below line is executed the binding changes
conn.WriteMsgUDP(b, oob, session.raddr)
Please let me know any more information is required such that this great code can be useful in case we wanted to bind to specific IP address and retain the binding
cc: @fastest963
Metadata
Metadata
Assignees
Labels
No labels