hassio-addons / addon-adguard-home

AdGuard Home - Home Assistant Community Add-ons
https://addons.community
MIT License
388 stars 48 forks source link

Port 53 / 5353 Collision with same IP on multiple interfaces #349

Closed s-ol closed 1 year ago

s-ol commented 1 year ago

298 is still an issue. I'm running a HAOS 9.0 install on an Odroid N2+ with the following (latest as of writing) versions:

Home Assistant Core 2022.9.7 Supervisor 2022.09.1 Frontend 20220907 OS 9.0

I've verified that no other addons that have port bindings for 53 / 5353. The only addons that I have installed that have host-mode networking are snapcastserver-respot, spotify and adguard itself.

I've verified with nc localhost 53 and dig google.com @localhost that there is no (functional?) DNS server running locally, but I'm not sure how to check what might be occupying the ports from within the Terminal addon container.

s-ol commented 1 year ago

Tried some more and it doesn't look like it's even a real port collision outside the addon. I've tried ports 53, 5353, 53535 and a random ports 29293 and 8887 and they are all "already in use" according to HomeGuard:

 Network-wide ads & trackers blocking DNS server
-----------------------------------------------------------
 Add-on version: 4.7.4
 You are running the latest version of this add-on.
 System: Home Assistant OS 9.0  (aarch64 / odroid-n2)
 Home Assistant Core: 2022.9.7
 Home Assistant Supervisor: 2022.09.1
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
cont-init: info: /etc/cont-init.d/00-banner.sh exited 0
cont-init: info: running /etc/cont-init.d/01-log-level.sh
cont-init: info: /etc/cont-init.d/01-log-level.sh exited 0
cont-init: info: running /etc/cont-init.d/adguard.sh
cont-init: info: /etc/cont-init.d/adguard.sh exited 0
cont-init: info: running /etc/cont-init.d/discovery.sh
[20:46:43] INFO: Successfully send discovery information to Home Assistant.
cont-init: info: /etc/cont-init.d/discovery.sh exited 0
cont-init: info: running /etc/cont-init.d/nginx.sh
cont-init: info: /etc/cont-init.d/nginx.sh exited 0
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
services-up: info: copying legacy longrun adguard (no readiness notification)
services-up: info: copying legacy longrun nginx (no readiness notification)
s6-rc: info: service legacy-services successfully started
[20:46:44] INFO: Starting AdGuard Home server...
2022/09/29 20:46:44.164088 [info] AdGuard Home, version v0.107.13
2022/09/29 20:46:44.167803 [error] creating dhcpv4 srv: dhcpv4: <nil> is not an IP address
2022/09/29 20:46:44.272969 [info] Initializing auth module: /data/adguard/data/sessions.db
2022/09/29 20:46:44.273136 [info] auth: initialized.  users:0  sessions:0
2022/09/29 20:46:44.273167 [info] Initialize web module
2022/09/29 20:46:44.274408 [info] DNS cache is enabled
2022/09/29 20:46:44.274439 [info] MaxGoroutines is set to 300
2022/09/29 20:46:44.292170 [info] AdGuard Home is available at the following addresses:
2022/09/29 20:46:44.292208 [info] Go to http://127.0.0.1:45158
[20:46:44] INFO: Starting NGinx...
2022/09/29 20:46:44.688339 [info] Starting the DNS proxy server
2022/09/29 20:46:44.688393 [info] Ratelimit is enabled and set to 20 rps
2022/09/29 20:46:44.688405 [info] The server is configured to refuse ANY requests
2022/09/29 20:46:44.688419 [info] DNS cache is enabled
2022/09/29 20:46:44.688439 [info] MaxGoroutines is set to 300
2022/09/29 20:46:44.688473 [info] Creating the UDP server socket
2022/09/29 20:46:44.688674 [info] Listening to udp://192.168.1.253:29293
2022/09/29 20:46:44.688697 [info] Creating the UDP server socket
2022/09/29 20:46:44.688915 [info] Listening to udp://[2001:b07:add:e868:fe25:1198:420c:a0ee]:29293
2022/09/29 20:46:44.688943 [info] Creating the UDP server socket
2022/09/29 20:46:44.691432 [fatal] couldn't start forwarding DNS server: listening to udp socket: listen udp 192.168.1.253:29293: bind: address already in use
[20:46:45] INFO: Starting AdGuard Home server...
2022/09/29 20:46:45.164761 [info] AdGuard Home, version v0.107.13
2022/09/29 20:46:45.168136 [error] creating dhcpv4 srv: dhcpv4: <nil> is not an IP address
2022/09/29 20:46:45.232239 [info] Initializing auth module: /data/adguard/data/sessions.db
2022/09/29 20:46:45.232387 [info] auth: initialized.  users:0  sessions:0
2022/09/29 20:46:45.232411 [info] Initialize web module
2022/09/29 20:46:45.233297 [info] DNS cache is enabled
2022/09/29 20:46:45.233317 [info] MaxGoroutines is set to 300
2022/09/29 20:46:45.255501 [info] AdGuard Home is available at the following addresses:
2022/09/29 20:46:45.255571 [info] Go to http://127.0.0.1:45158
2022/09/29 20:46:45.697589 [info] Starting the DNS proxy server
2022/09/29 20:46:45.697628 [info] Ratelimit is enabled and set to 20 rps
2022/09/29 20:46:45.697634 [info] The server is configured to refuse ANY requests
2022/09/29 20:46:45.697639 [info] DNS cache is enabled
2022/09/29 20:46:45.697650 [info] MaxGoroutines is set to 300
2022/09/29 20:46:45.697670 [info] Creating the UDP server socket
2022/09/29 20:46:45.697824 [info] Listening to udp://192.168.1.253:29293
2022/09/29 20:46:45.697834 [info] Creating the UDP server socket
2022/09/29 20:46:45.697901 [info] Listening to udp://[2001:b07:add:e868:fe25:1198:420c:a0ee]:29293
2022/09/29 20:46:45.697908 [info] Creating the UDP server socket
2022/09/29 20:46:45.699872 [fatal] couldn't start forwarding DNS server: listening to udp socket: listen udp 192.168.1.253:29293: bind: address already in use
[20:46:46] INFO: Starting AdGuard Home server...
2022/09/29 20:46:46.166012 [info] AdGuard Home, version v0.107.13
2022/09/29 20:46:46.169759 [error] creating dhcpv4 srv: dhcpv4: <nil> is not an IP address
2022/09/29 20:46:46.233823 [info] Initializing auth module: /data/adguard/data/sessions.db
2022/09/29 20:46:46.234000 [info] auth: initialized.  users:0  sessions:0
2022/09/29 20:46:46.234033 [info] Initialize web module
2022/09/29 20:46:46.235175 [info] DNS cache is enabled
2022/09/29 20:46:46.235195 [info] MaxGoroutines is set to 300
2022/09/29 20:46:46.252542 [info] AdGuard Home is available at the following addresses:
2022/09/29 20:46:46.252583 [info] Go to http://127.0.0.1:45158
2022/09/29 20:46:46.651949 [info] Starting the DNS proxy server
2022/09/29 20:46:46.651988 [info] Ratelimit is enabled and set to 20 rps
2022/09/29 20:46:46.651994 [info] The server is configured to refuse ANY requests
2022/09/29 20:46:46.652000 [info] DNS cache is enabled
2022/09/29 20:46:46.652011 [info] MaxGoroutines is set to 300
2022/09/29 20:46:46.652033 [info] Creating the UDP server socket
2022/09/29 20:46:46.652199 [info] Listening to udp://192.168.1.253:29293
2022/09/29 20:46:46.652208 [info] Creating the UDP server socket
2022/09/29 20:46:46.652269 [info] Listening to udp://[2001:b07:add:e868:fe25:1198:420c:a0ee]:29293
2022/09/29 20:46:46.652276 [info] Creating the UDP server socket
2022/09/29 20:46:46.658036 [fatal] couldn't start forwarding DNS server: listening to udp socket: listen udp 192.168.1.253:29293: bind: address already in use
[20:46:47] INFO: Starting AdGuard Home server...
2022/09/29 20:46:47.167635 [info] AdGuard Home, version v0.107.13
2022/09/29 20:46:47.171465 [error] creating dhcpv4 srv: dhcpv4: <nil> is not an IP address
2022/09/29 20:46:47.175760 [info] Initializing auth module: /data/adguard/data/sessions.db
2022/09/29 20:46:47.175904 [info] auth: initialized.  users:0  sessions:0
2022/09/29 20:46:47.175930 [info] Initialize web module
2022/09/29 20:46:47.176975 [info] DNS cache is enabled
2022/09/29 20:46:47.177002 [info] MaxGoroutines is set to 300
2022/09/29 20:46:47.198946 [info] AdGuard Home is available at the following addresses:
2022/09/29 20:46:47.199005 [info] Go to http://127.0.0.1:45158
bennibeloisi commented 1 year ago

I'm having the same issue, Supervised HASSiO install on RPi4 on RPi OS. Before i had no problems, only recently I had no more DNS. It seems that is not an AdGuard/AddOn problem, but a home assistant problem. For me it was system-resolved that is blocking port 53.

Running these commands (found them on this page: https://aaronfisher.net/2022/04/docker-port-53/) sudo systemctl disable systemd-resolved.service sudo systemctl stop systemd-resolved

worked fine for me and i could used the port again. what are the consequences on the long run - i am not sure.

s-ol commented 1 year ago

On HAOS it's not possible to access the host systemd without developer mode, so this is not a feasible workaround for most users.

@bennibeloisi have you tried changing the ports on your system without disabling systemd-resolved? As I mentioned above, in my case that didn't help either so I'm wondering if maybe therse are separate issues.

pho3nixf1re commented 1 year ago

~I just had this happen after applying the latest HAOS update today. The systemctl command does not exist in my ssh connection but that is likely due to not running in developer mode. Seems weird that this suddenly popped up after running fine for months.~

So I rebooted the adguard container (addon) and it's all working again. So this may just be an issue on initial system startup.

github-actions[bot] commented 1 year ago

There hasn't been any activity on this issue recently, so we clean up some of the older and inactive issues. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thanks!

LordNex commented 1 year ago

I'm having a similar issue. I have a multi VLAN network and have several nics, one with a VLAN attached and it shows the same IP as the interface on that. AdGuard sees both addresses and fires up DNS on the first instance of the IP and then when it comes across the second reference IP pointing it to the VLAN it fails with the same error as above.

I cant change it because its the only way to get Home Assistant to send data like mDNS and UPnP across broadcast domains. Is there a way to specify which interfaces I want AdGuard to use and not use?

s-ol commented 1 year ago

I'm having a similar issue. I have a multi VLAN network and have several nics, one with a VLAN attached and it shows the same IP as the interface on that. AdGuard sees both addresses and fires up DNS on the first instance of the IP and then when it comes across the second reference IP pointing it to the VLAN it fails with the same error as above.

I cant change it because its the only way to get Home Assistant to send data like mDNS and UPnP across broadcast domains. Is there a way to specify which interfaces I want AdGuard to use and not use?

Oh, this probably explains why I am getting it as well! I have both wifi and ethernet set up such that wifi can serve as fallback if my powerline system fails, but that also means they have the same IP.

s-ol commented 1 year ago

@LordNex looks like this is the responsible bit of code:

https://github.com/hassio-addons/addon-adguard-home/blob/main/adguard/rootfs/etc/cont-init.d/adguard.sh#L51-L57

No way to configure it currently, but maybe there should be. In any case it should deal with duplicates better.

github-actions[bot] commented 1 year ago

There hasn't been any activity on this issue recently, so we clean up some of the older and inactive issues. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thanks!