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

AdGuardHome doesn't display ECS (EDNS) requester IP in webui, uses client IP instead #3978

Closed
gtxaspec opened this issue Dec 22, 2021 · 14 comments

Comments

@gtxaspec
Copy link

gtxaspec commented Dec 22, 2021

Issue Details

  • Version of AdGuard Home server:
    Latest Master
  • How did you install AdGuard Home:
    from edge installer on github
  • How did you setup DNS configuration:
    openwrt running dnsmasq > dedicated adguard server
  • If it's a router or IoT, please write device model:
    dedicated server
  • CPU architecture:
    arm64
  • Operating system and version:
    Debian 11

Expected Behavior

As AdGuardHome receives a DNS request, it should extract the ECS data (requester IP) and use this in the WebUI logs instead of using the client IP.

Actual Behavior

AdGuard ignores the ECS requesters IP and uses the client IP to display in the WebUI.

In the log below, you can see that the client IP ( [debug] client ip: 200x:xxx:xxxd::50 ) is used, not the ECS requester ( [debug] Passing through ECS data: 10.xx.1.17/32 )

When you have a router that has several clients behind it, the logs only show the client IP (router's IP), not the actual requesting client's IP even though the requester's information is provided using ECS/EDNS data to AdGuard. This would be useful in a household network or a small office to see what the IP of the actual requesting device is.

Screenshots

InkedScreenshot 2021-12-21 233725_LI

Additional Information

logs:

2021/12/21 23:19:42.096828 1336#5274 [debug] github.com/AdguardTeam/dnsproxy/proxy.(*Proxy).udpHandlePacket(): Start handling new UDP packet from [200x:xxx:xxxd::50]:51621
2021/12/21 23:19:42.096942 1336#5274 [debug] github.com/AdguardTeam/dnsproxy/proxy.(*Proxy).logDNSMessage(): IN: ;; opcode: QUERY, status: NOERROR, id: 31629
;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; QUESTION SECTION:
;android.com.	IN	 A

;; ADDITIONAL SECTION:

;; OPT PSEUDOSECTION:
; EDNS: version 0; flags: ; udp: 512
; LOCAL OPT: 65001:0x100ba9600318
; SUBNET: 10.25.1.17/32/0

2021/12/21 23:19:42.097026 1336#5274 [debug] hosts container: handling the request
2021/12/21 23:19:42.097095 1336#5274 [debug] Passing through ECS data: 10.xx.1.17/32
2021/12/21 23:19:42.097138 1336#5274 [debug] serving response from subnet cache
2021/12/21 23:19:42.097174 1336#5274 [debug] DNSFwd: Checking record A (142.250.188.228) for android.com.
2021/12/21 23:19:42.097214 1336#5274 [debug] ipset: starting processing
2021/12/21 23:19:42.097241 1336#5274 [debug] ipset: added 0 new ipset entries
2021/12/21 23:19:42.097268 1336#5274 [debug] client ip: 200x:xxx:xxxd::50
2021/12/21 23:19:42.097315 1336#5274 [debug] github.com/AdguardTeam/dnsproxy/proxy.(*Proxy).logDNSMessage(): OUT: ;; opcode: QUERY, status: NOERROR, id: 31629
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; QUESTION SECTION:
;android.com.	IN	 A

;; ANSWER SECTION:
android.com.	2265	IN	A	142.250.188.228

;; ADDITIONAL SECTION:

;; OPT PSEUDOSECTION:
; EDNS: version 0; flags: ; udp: 512
@jumpsmm7
Copy link
Contributor

jumpsmm7 commented Dec 23, 2021

Issue Details

* **Version of AdGuard Home server:**
  Latest Master

* **How did you install AdGuard Home:**
  from edge installer on github

* **How did you setup DNS configuration:**
  openwrt running dnsmasq > dedicated adguard server

* **If it's a router or IoT, please write device model:**
  dedicated server

* **CPU architecture:**
  arm64

* **Operating system and version:**
  Debian 11

Expected Behavior

As AdGuardHome receives a DNS request, it should extract the ECS data (requester IP) and use this in the WebUI logs instead of using the client IP.

Actual Behavior

AdGuard ignores the ECS requesters IP and uses the client IP to display in the WebUI.

In the log below, you can see that the client IP ( [debug] client ip: 200x:xxx:xxxd::50 ) is used, not the ECS requester ( [debug] Passing through ECS data: 10.xx.1.17/32 )

When you have a router that has several clients behind it, the logs only show the client IP (router's IP), not the actual requesting client's IP even though the requester's information is provided using ECS/EDNS data to AdGuard. This would be useful in a household network or a small office to see what the IP of the actual requesting device is.

Screenshots

InkedScreenshot 2021-12-21 233725_LI

Additional Information

logs:

2021/12/21 23:19:42.096828 1336#5274 [debug] github.com/AdguardTeam/dnsproxy/proxy.(*Proxy).udpHandlePacket(): Start handling new UDP packet from [200x:xxx:xxxd::50]:51621
2021/12/21 23:19:42.096942 1336#5274 [debug] github.com/AdguardTeam/dnsproxy/proxy.(*Proxy).logDNSMessage(): IN: ;; opcode: QUERY, status: NOERROR, id: 31629
;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; QUESTION SECTION:
;android.com.	IN	 A

;; ADDITIONAL SECTION:

;; OPT PSEUDOSECTION:
; EDNS: version 0; flags: ; udp: 512
; LOCAL OPT: 65001:0x100ba9600318
; SUBNET: 10.25.1.17/32/0

2021/12/21 23:19:42.097026 1336#5274 [debug] hosts container: handling the request
2021/12/21 23:19:42.097095 1336#5274 [debug] Passing through ECS data: 10.xx.1.17/32
2021/12/21 23:19:42.097138 1336#5274 [debug] serving response from subnet cache
2021/12/21 23:19:42.097174 1336#5274 [debug] DNSFwd: Checking record A (142.250.188.228) for android.com.
2021/12/21 23:19:42.097214 1336#5274 [debug] ipset: starting processing
2021/12/21 23:19:42.097241 1336#5274 [debug] ipset: added 0 new ipset entries
2021/12/21 23:19:42.097268 1336#5274 [debug] client ip: 200x:xxx:xxxd::50
2021/12/21 23:19:42.097315 1336#5274 [debug] github.com/AdguardTeam/dnsproxy/proxy.(*Proxy).logDNSMessage(): OUT: ;; opcode: QUERY, status: NOERROR, id: 31629
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; QUESTION SECTION:
;android.com.	IN	 A

;; ANSWER SECTION:
android.com.	2265	IN	A	142.250.188.228

;; ADDITIONAL SECTION:

;; OPT PSEUDOSECTION:
; EDNS: version 0; flags: ; udp: 512

I have noticed this same issue as well. While AdguardHome is able adequately parse the client IP information with ECS data, it does not properly reflect the client identification information in the WEBUI, thus filter rules are not able to be adequately defined(or applied) per client identified in this manner. As mentioned by the OP, this can be troublesome for one not only wanting to monitor traffic or define rules for clients identified in this manner, but also provides issues for people with multiple interfaces, or VLANs on the same network destined for adguardhome.

@agneevX
Copy link
Contributor

agneevX commented Jan 1, 2022

2021/12/21 23:19:42.097095 1336#5274 [debug] Passing through ECS data: 10.xx.1.17/32

I think AGH should not send private IP ranges as ECS data to resolvers.

@jumpsmm7
Copy link
Contributor

jumpsmm7 commented Jan 2, 2022

2021/12/21 23:19:42.097095 1336#5274 [debug] Passing through ECS data: 10.xx.1.17/32

I think AGH should not send private IP ranges as ECS data to resolvers.

We are talking two different things. He is not saying take the clients Private IP and pass it to the upstream resolvers. He is saying Locally identifying clients by the ECS data parsed from the clients information.

@agneevX
Copy link
Contributor

agneevX commented Jan 2, 2022

I'm aware; its an observation.

@gspannu
Copy link

gspannu commented Feb 15, 2022

@ainar-g @EugeneOne1

It would be useful to add a boolean flag (in the yaml file) whether the ECS data or Client IP data should be used for display, rules, etc...

Something like client_ecs_data: true/ false

@ainar-g
Copy link
Contributor

ainar-g commented Feb 15, 2022

@gspannu, this issue is currently only about the UI. Using the ECS data to identify clients is another topic, and I'm not even sure if that can be done reliably, considering that clients can put any value there.

@gspannu
Copy link

gspannu commented Feb 15, 2022

@gspannu, this issue is currently only about the UI. Using the ECS data to identify clients is another topic, and I'm not even sure if that can be done reliably, considering that clients can put any value there.

The reason for the request (and hopefully I have not misunderstood)...

I have AdGuard Home running in the cloud.
All encrypted and supports DoT and DoH clients.
iOS devices well protected as I am using .mobileconfig and have specified individual clients (DoH)

I also use the same AGH instance from my home router (Asus router running Merlin)

All my queries from router to AGH instance are also running DoT...
and herein lies the issue.

AGH Instance detects all queries from the router (public IP) as originating from the router rather than the underlying client IPs (192.168.x.x)

I have set the flags add-mac and add-subnet=32 in my dnsmasq settings in the router, but it seems that AGH ignores this data when receiving DoH/DoT request from the client and only uses the ClientID field.

Is there any way where I can have AGH identify the underlying clients (192.168.x.x) and still make a DoH/DoT DNS request to the AGH instance?

@ainar-g
Copy link
Contributor

ainar-g commented Feb 15, 2022

@gspannu, this is not really the right place for such questions; we strive to keep them in the Discussions.

ClientID should be enough to identify the client, and if you want to identify them by IP over DoH, you should set the appropriate headers in your HTTP proxy and use the trusted_proxies parameter. If that doesn't work for you, please post a new discussion about that. Thanks.

adguard pushed a commit to AdguardTeam/dnsproxy that referenced this issue Feb 17, 2022
Merge in DNS/dnsproxy from 3978-ecs-ip to master

Updates AdguardTeam/AdGuardHome#3978

Squashed commit of the following:

commit 6522971
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Wed Feb 16 21:13:12 2022 +0300

    proxy: impl rfc better

commit dd2284a
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Wed Feb 16 20:02:48 2022 +0300

    proxy: fix deps, imp tests

commit 50003c4
Merge: d2b98d4 99558ce
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Wed Feb 16 19:24:25 2022 +0300

    Merge branch 'master' into 3978-ecs-ip

commit d2b98d4
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Wed Feb 16 19:22:37 2022 +0300

    proxy: turn ecs into ipnet

commit 99ec30d
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Feb 15 17:40:27 2022 +0300

    proxy: imp code, docs

commit 7f48aa3
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Feb 15 16:15:52 2022 +0300

    proxy: export ecs data
adguard pushed a commit that referenced this issue Mar 3, 2022
Merge in DNS/adguard-home from 3978-ecs-ip to master

Updates #3978.

Squashed commit of the following:

commit 915b94a
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Mar 3 17:46:40 2022 +0300

    all: rm dot

commit 2dd2ed0
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Mar 3 17:42:45 2022 +0300

    client: imp txt

commit 8d5a23d
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Mar 3 14:36:04 2022 +0300

    client: imp text

commit 69c8567
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Mar 3 14:24:56 2022 +0300

    client: imp description

commit cd01501
Merge: 28181fb e0b557e
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Wed Mar 2 21:02:16 2022 +0300

    Merge branch 'master' into 3978-ecs-ip

commit 28181fb
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Wed Mar 2 20:45:50 2022 +0300

    client: show ecs

commit cdc5e7f
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Feb 17 20:15:56 2022 +0300

    openapi: fix milestone

commit 404d6d8
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Feb 17 20:08:21 2022 +0300

    all: fix deps, docs

commit 8fb8052
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Feb 17 19:39:34 2022 +0300

    all: add querylog ecs backend
@EugeneOne1
Copy link
Member

@gtxaspec, @gspannu, hello again and sorry for the delay. We've added the ECS into the request details section of query log entries. It's already available in the latest edge build. Could you please install it and check if it works properly?

@jumpsmm7
Copy link
Contributor

jumpsmm7 commented Mar 3, 2022

@EugeneOne1

@gtxaspec, @gspannu, hello again and sorry for the delay. We've added the ECS into the request details section of query log entries. It's already available in the latest edge build. Could you please install it and check if it works properly?

I will test for you shortly as well. Thank you for this brilliant addition!

@gtxaspec
Copy link
Author

gtxaspec commented Mar 3, 2022

@EugeneOne1

Latest edge, i can confirm that the ECS details do show up under the "Request details" of the user interface.

Will the "Client details" be updated with this information as well,in the future? thank you

@EugeneOne1
Copy link
Member

@gtxaspec, we've got a couple of ECS-related issues already (e.g. #1727, #2514). Do you mean duplicating this info to the "Client details" of the same query log entry?

So far, it seems the issue may be closed for now. Please consider opening a new one if it isn't yet.

@jojost1
Copy link

jojost1 commented Mar 10, 2022

@gtxaspec

Latest edge, i can confirm that the ECS details do show up under the "Request details" of the user interface.

Would it be possible to share a screenshot here showing how the UI displays it? I'm building support for ECS display inside AdGuard Home Remote and I can't test this myself. Thanks!

@gspannu
Copy link

gspannu commented Mar 10, 2022

@gtxaspec

Latest edge, i can confirm that the ECS details do show up under the "Request details" of the user interface.

Would it be possible to share a screenshot here showing how the UI displays it? I'm building support for ECS display inside AdGuard Home Remote and I can't test this myself. Thanks!

Screenshot

@ainar-g ainar-g modified the milestones: v0.108.0, v0.107.7 Jun 2, 2022
adguard pushed a commit that referenced this issue Jun 2, 2022
Merge in DNS/adguard-home from 3978-ecs-ip to master

Updates #3978.

Squashed commit of the following:

commit 915b94a
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Mar 3 17:46:40 2022 +0300

    all: rm dot

commit 2dd2ed0
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Mar 3 17:42:45 2022 +0300

    client: imp txt

commit 8d5a23d
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Mar 3 14:36:04 2022 +0300

    client: imp text

commit 69c8567
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Mar 3 14:24:56 2022 +0300

    client: imp description

commit cd01501
Merge: 28181fb e0b557e
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Wed Mar 2 21:02:16 2022 +0300

    Merge branch 'master' into 3978-ecs-ip

commit 28181fb
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Wed Mar 2 20:45:50 2022 +0300

    client: show ecs

commit cdc5e7f
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Feb 17 20:15:56 2022 +0300

    openapi: fix milestone

commit 404d6d8
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Feb 17 20:08:21 2022 +0300

    all: fix deps, docs

commit 8fb8052
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Feb 17 19:39:34 2022 +0300

    all: add querylog ecs backend
heyxkhoa pushed a commit to heyxkhoa/AdGuardHome that referenced this issue Mar 20, 2023
Merge in DNS/adguard-home from 3978-ecs-ip to master

Updates AdguardTeam#3978.

Squashed commit of the following:

commit 915b94a
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Mar 3 17:46:40 2022 +0300

    all: rm dot

commit 2dd2ed0
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Mar 3 17:42:45 2022 +0300

    client: imp txt

commit 8d5a23d
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Mar 3 14:36:04 2022 +0300

    client: imp text

commit 69c8567
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Mar 3 14:24:56 2022 +0300

    client: imp description

commit cd01501
Merge: 28181fb e0b557e
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Wed Mar 2 21:02:16 2022 +0300

    Merge branch 'master' into 3978-ecs-ip

commit 28181fb
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Wed Mar 2 20:45:50 2022 +0300

    client: show ecs

commit cdc5e7f
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Feb 17 20:15:56 2022 +0300

    openapi: fix milestone

commit 404d6d8
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Feb 17 20:08:21 2022 +0300

    all: fix deps, docs

commit 8fb8052
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Feb 17 19:39:34 2022 +0300

    all: add querylog ecs backend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants