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

How to make Zeroconf available on all interfaces [eth0/wlan0] #296

Open
jpiwek opened this issue Sep 3, 2020 · 7 comments
Open

How to make Zeroconf available on all interfaces [eth0/wlan0] #296

jpiwek opened this issue Sep 3, 2020 · 7 comments

Comments

@jpiwek
Copy link

jpiwek commented Sep 3, 2020

Hi,

I am playing with Zeroconf on an embedded linux system with a HTTP Server .
All interfaces have DHCP running.

How to configure Py-Zeroconf on all interfaces (eth0/wlan0) with DHCP on?
When I add the IP on eth0 e.g. 192.168.96.103 as in the code snippet below. Then it works accessing through PC on the networks, oherwise not.

addresses = [socket.inet_aton("192.168.96.103")]
   
info = ServiceInfo(
        "_http._tcp.local.",
        z_name,
        addresses=addresses,
        port=port,
        properties=desc,
        server=z_server,
)
@jstasiak
Copy link
Collaborator

jstasiak commented Sep 9, 2020

Pass InterfaceChoice.All (or manually constructed list of addresses) as interfaces parameter when constructing Zeroconf. The addresses in ServiceInfo are are addresses that you advertise your service to be available at, they have no bearing on what interfaces do you send the advertisements to.

@jpiwek
Copy link
Author

jpiwek commented Sep 10, 2020 via email

@jstasiak
Copy link
Collaborator

If you're talking about the addresses used to specify the network interfaces for Zeroconf to use then every time there's a network configuration change (new interface, existing interface closes, IP address changes) the behavior of this library is undefined I think and you're better off killing the existing instance (using the Zeroconf.close() method) and starting a new one (with either updated interfaces list or InterfaceChoice.All)

@om26er
Copy link

om26er commented Sep 25, 2020

Pass InterfaceChoice.All (or manually constructed list of addresses) as interfaces parameter when constructing Zeroconf. The addresses in ServiceInfo are are addresses that you advertise your service to be available at, they have no bearing on what interfaces do you send the advertisements to.

Wouldn't that have the same IP address published on all interfaces, which kind of is broken because if I publish my wlan IP on the ethernet interface as well then a client "looking" for my service on ethernet won't actually be able to connect because of wrong IP. I wonder if that's a bug in the library ?

@om26er
Copy link

om26er commented Sep 25, 2020

For example if I publish a service with avahi, it publishes the "right" IP for each interface.

+ docker0 IPv6 serviceName                                   Web Site             local
+ br-b8bcb69e92fd IPv6 serviceName                                   Web Site             local
+ lxdbr0 IPv6 serviceName                                   Web Site             local
+  wlan2 IPv6 serviceName                                   Web Site             local
+ mpqemubr0 IPv6 serviceName                                   Web Site             local
+     lo IPv4 serviceName                                   Web Site             local
+ docker0 IPv4 serviceName                                   Web Site             local
+ br-b8bcb69e92fd IPv4 serviceName                                   Web Site             local
+ lxdbr0 IPv4 serviceName                                   Web Site             local
+  wlan2 IPv4 serviceName                                   Web Site             local
+ mpqemubr0 IPv4 serviceName                                   Web Site             local
= docker0 IPv6 serviceName                                   Web Site             local
   hostname = [KNUC.local]
   address = [fe80::42:27ff:fe71:eaa3]
   port = [5353]
   txt = []
= br-b8bcb69e92fd IPv6 serviceName                                   Web Site             local
   hostname = [KNUC.local]
   address = [fe80::42:99ff:fefe:fe23]
   port = [5353]
   txt = []
= lxdbr0 IPv6 serviceName                                   Web Site             local
   hostname = [KNUC.local]
   address = [fd42:76d1:bed3:17e4::1]
   port = [5353]
   txt = []
=  wlan2 IPv6 serviceName                                   Web Site             local
   hostname = [KNUC.local]
   address = [fe80::9e5f:c600:9b70:1113]
   port = [5353]
   txt = []
= mpqemubr0 IPv6 serviceName                                   Web Site             local
   hostname = [KNUC.local]
   address = [fe80::5054:ff:fe42:2398]
   port = [5353]
   txt = []
=     lo IPv4 serviceName                                   Web Site             local
   hostname = [KNUC.local]
   address = [127.0.0.1]
   port = [5353]
   txt = []
= docker0 IPv4 serviceName                                   Web Site             local
   hostname = [KNUC.local]
   address = [172.17.0.1]
   port = [5353]
   txt = []
= br-b8bcb69e92fd IPv4 serviceName                                   Web Site             local
   hostname = [KNUC.local]
   address = [172.18.0.1]
   port = [5353]
   txt = []
= lxdbr0 IPv4 serviceName                                   Web Site             local
   hostname = [KNUC.local]
   address = [10.153.181.1]
   port = [5353]
   txt = []
=  wlan2 IPv4 serviceName                                   Web Site             local
   hostname = [KNUC.local]
   address = [192.168.100.254]
   port = [5353]
   txt = []
= mpqemubr0 IPv4 serviceName                                   Web Site             local
   hostname = [KNUC.local]
   address = [10.119.114.1]
   port = [5353]
   txt = []

@webdevbyjoss
Copy link

hi all,
I have the same concern right now, @om26er did you actually figured this out?

@bdraco
Copy link
Member

bdraco commented Jun 22, 2021

There is a PR open to add support for addresses per interface but its gone stale
#180

To make it work correctly we need a major architectural change as well
#806

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants