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

dnsproxy with configuration DoT, forward IP #7

Closed
syrm opened this issue Jan 23, 2019 · 11 comments
Closed

dnsproxy with configuration DoT, forward IP #7

syrm opened this issue Jan 23, 2019 · 11 comments
Labels
question Further information is requested

Comments

@syrm
Copy link

syrm commented Jan 23, 2019

Hello,

I run dnsproxy like that :
dnsproxy -p 5353 --tls-port=853 -u 127.0.0.1:53 --tls-crt=/fullchain.pem --tls-key=privkey.pem

But my internal DNS server (127.0.0.1) see request coming from 127.0.0.1 instead original IP, is it possible to fix that ?

@ameshkov ameshkov added the question Further information is requested label Jan 23, 2019
@ameshkov
Copy link
Member

Well, it makes sense as dnsproxy sends this request to it. I don't think there is an easy solution for that.

@syrm
Copy link
Author

syrm commented Jan 23, 2019

Can it forge package to change IP ?

@ameshkov
Copy link
Member

In order for your DNS server to see the real the real client IP, you'll need to spoof the source address in the UDP packet (which is hard by itself). The second problem with that is that in this case the response will be sent not to dnsproxy but to that spoofed address, and you'll need to somehow intercept these packets and re-route them back to dnsproxy. I doubt it is feasible.

I've got another idea that might work, though.

There is a EDNS Client Subnet extension which allows indicating the client subnet to the upstream DNS server. Maybe if dnsproxy adds this extension to outgoing queries, your local DNS server will see it and indicate in the interface.

To test it add this code to https://github.com/AdguardTeam/dnsproxy/blob/master/proxy/proxy.go#L224

	o := new(dns.OPT)
	o.Hdr.Name = "."
	o.Hdr.Rrtype = dns.TypeOPT
	e := new(dns.EDNS0_SUBNET)
	e.Code = dns.EDNS0SUBNET
	e.Family = 1         // 1 for IPv4 source address, 2 for IPv6
	e.SourceNetmask = 32 // 32 for IPV4, 128 for IPv6
	e.SourceScope = 0
	e.Address = net.ParseIP("1.2.3.4").To4() // Hardcoded IP just for test
	o.Option = append(o.Option, e)
	d.Req.Extra = append(d.Req.Extra, o)

@syrm
Copy link
Author

syrm commented Jan 23, 2019

I tried like that :


   o := new(dns.OPT)
   o.Hdr.Name = "."
   o.Hdr.Rrtype = dns.TypeOPT
   e := new(dns.EDNS0_SUBNET)
   e.Code = dns.EDNS0SUBNET
   e.Family = 1         // 1 for IPv4 source address, 2 for IPv6
   e.SourceNetmask = 32 // 32 for IPV4, 128 for IPv6
   e.SourceScope = 0
   e.Address = net.ParseIP("1.2.3.4").To4() // Hardcoded IP just for test
   o.Option = append(o.Option, e)
   d.Req.Extra = append(d.Req.Extra, o)

   dnsUpstream := d.Upstream

   // execute the DNS request

Without success

@ameshkov
Copy link
Member

Does your local DNS support ECS?

@syrm
Copy link
Author

syrm commented Jan 23, 2019

@ameshkov
Copy link
Member

Oh, that's not ECS support, this looks as this is simply a part of the resolver description.

Btw, on a side note, full DOH/DOT support will be in the next version of AdGuard Home:
AdguardTeam/AdGuardHome#285

@syrm
Copy link
Author

syrm commented Jan 23, 2019

Hum ok, i gonna ask pi-hole to support ECS so

@syrm
Copy link
Author

syrm commented Jan 24, 2019

pi-hole use dnsmasq which one seems supporting EDNS

@ameshkov
Copy link
Member

I guess I might've been unclear. All modern DNS servers support EDNS, that's not the point.

What I mean by supporting ECS is somehow indicating it in the interface/logs. I've outlined the idea it here: AdguardTeam/AdGuardHome#558

@syrm
Copy link
Author

syrm commented Jan 24, 2019

Ok sorry, i think we can close this :-)
Thank you

@syrm syrm closed this as completed Jan 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants