getdnsapi / stubby

Stubby is the name given to a mode of using getdns which enables it to act as a local DNS Privacy stub resolver (using DNS-over-TLS).
https://dnsprivacy.org/dns_privacy_daemon_-_stubby/
BSD 3-Clause "New" or "Revised" License
1.2k stars 99 forks source link

Stubby doesn't listen on TCP/IPv6 when using 0::0 #281

Open hanjo opened 3 years ago

hanjo commented 3 years ago

Hi,

I'd like Stubby do listen on all my interfaces/addresses, so I've configured

listen_addresses:
  - 0.0.0.0
  - 0::0

This however doesn't seem to work with TCP on IPv6, the daemon doesn't seem to listen:

$ sudo netstat -lnp | grep stubby
tcp        0      0 0.0.0.0:53              0.0.0.0:*               LISTEN      2073/stubby
udp        0      0 0.0.0.0:53              0.0.0.0:*                           2073/stubby
udp6       0      0 :::53                   :::*                                2073/stubby

However, when I put in a real IPv6 address in the config:

listen_addresses:
  - 0.0.0.0
  - fd4e:...

it works:

$ sudo netstat -lnp | grep stubby
tcp        0      0 0.0.0.0:53              0.0.0.0:*               LISTEN      2122/stubby
tcp6       0      0 fd4e:...::53            :::*                    LISTEN      2122/stubby
udp        0      0 0.0.0.0:53              0.0.0.0:*                           2122/stubby
udp6       0      0 fd4e:...::53            :::*                                2122/stubby

I assume this is a bug, but maybe my configuration above for listening on all IPv6 addresses is not correct.

wtoorop commented 3 years ago

Yes this is quite peculiar and does have something to do with dual-stack mode IPv6, though it doesn't actually bind dual stack when providing just the IPv6 so I suppose I have to look into what is going on here... You can workaround the issue by disabling dual-stack mode IPv6:

# echo 1 > /proc/sys/net/ipv6/bindv6only
hanjo commented 3 years ago

Thansk for pointing out the workaround - seems to be working now:

$ sudo netstat -lnp | grep stubby
tcp        0      0 0.0.0.0:53              0.0.0.0:*               LISTEN      645/stubby
tcp6       0      0 :::53                   :::*                    LISTEN      645/stubby
udp        0      0 0.0.0.0:53              0.0.0.0:*                           645/stubby
udp6       0      0 :::53                   :::*                                645/stubby