[avahi] Bonjour/Avahi broadcasting with host names

Trent Lloyd lathiat at bur.st
Sat May 20 05:18:04 UTC 2017


Tracking this here after discussion with Till.  Most likely going to 
look at always activate the loopback interface to support this use case.
https://github.com/lathiat/avahi/issues/125

Cheers,
Trent
@lathiat

On 10/01/17 05:54, Till Kamppeter wrote:
> Hi,
>
> tl;dr: Local IPv6 IP address has an alternative host name assigned but 
> Avahi broadcast uses the system's default host name.
>
> I am working on the ippusbxd project:
>
> https://github.com/tillkamppeter/ippusbxd/
>
> ippusbxd makes an IPP-over-USB printer appear on the system like a 
> network printer. This way one can use the same software and discovery 
> method as for IPP network printers, as CUPS' IPP backend, 
> cups-browsed, avahi-daemon, ...). Especially newer IPP (and 
> IPP-over-USB) printers using the IPP 2.0 protocol and understanding 
> PWG Raster or Apple Raster can be set up fully automatically without 
> any printer driver.
>
> The printer needs only be available to the local machine and should 
> not pollute other machines in the local network, as a normal USB 
> printer. To share it one would share the CUPS queue as usual.
>
> So the most intuitive is to mirror it to localhost (127.0.0.1) on a 
> port other than 631 (631 is already used by CUPS). I use 60000. Now 
> for CUPS and cups-browsed to discover the printer, ippusbxd has to do 
> Bonjour/Avahi broadcasts, as a real network printer does. 
> Unfortunately Avahi only supports multicast-capable network interfaces 
> and as the loopback interface ("lo") is not multicast-capable, 
> localhost cannot be used.
>
> So I set up a dummy interface via
>
> sudo ip link add ippusbxd type dummy
> sudo ip link set ippusbxd up
> sudo ip link set ippusbxd multicast on
> sudo ip -6 addr add 'fd00:1:1::1/64' dev ippusbxd
>
> I use IPv6-only as there are enough IPv6 IP spaces so the chance to 
> clash with some other local service is practically zero. For testing I 
> have selected a fixed address now, but for production a random prefix 
> in the appropriate space (ULAs) has to be used and for each printer a 
> suffix derived from the identity of the printer (to make it easier to 
> get predictable URIs for the printers). The link-local address which 
> the interface automatically gets is very awkward to use as one has to 
> specify the interface when accessing the printer.
>
> I am able now to broadcast the printer with this dummy interface named 
> "ippusbxd" and cups-browsed correctly discovered it, being able to 
> auto-create a working CUPS queue for the printer.
>
> The problem is that all this only works based on IP adresses and there 
> are problems with host names.
>
> After having manually run the four lines to create the interface shown 
> above, ippusbxd is called to mirror the printer to the "ippusbxd" 
> interface and then ippusbxd resgisters the printer to Avahi with the 
> following call:
>
> error =
>     avahi_entry_group_add_service_strlst(bonjour_data->ipp_ref,
>                 (int)if_nametoindex("ippusbxd"),
>         AVAHI_PROTO_UNSPEC, 0,
>         dnssd_name,
>         "_ipp._tcp", NULL, NULL, 60000,
>         ipp_txt);
>
> This makes the printer being broadcasted, but with the host name of 
> the system. The "Address:" entry in the Bonjour record visible in 
> avahi-discover (Interface: ippusbxd -> local -> Internet Printer) reads:
>
> Address: till-x1carbon.local/fd00:1:1::1:60000
>
> With the host name being from the system. This would mean that 
> printing via the URI ipp://till-x1carbon.local:60000/ipp/print or 
> accessing the printer's web admin interface via 
> http://till-x1carbon.local:60000/ does not work.
>
> So as a first approach I added the line
>
> fd00:1:1::1    ippusbxd-printers
>
> to /etc/hosts. This makes Firefox now access the web interface via
>
> http://ippusbxd-printers:60000/
>
> but the Avahi broadcasts are still wrong, having still
>
> Address: till-x1carbon.local/fd00:1:1::1:60000
>
> in the avahi-discover output.
>
> I already tried to register with
>
> error =
>     avahi_entry_group_add_service_strlst(bonjour_data->ipp_ref,
>                 (int)if_nametoindex("ippusbxd"),
>         AVAHI_PROTO_UNSPEC, 0,
>         dnssd_name,
>         "_ipp._tcp", NULL, "ippusbxd-printers", 60000,
>         ipp_txt);
>
> But with this the registration failed.
>
> How do I get the correct broadcasts with
>
> Address: ippusbxd-printers/fd00:1:1::1:60000
>
> in the avahi-discover output?
>
> Should work somehow, as the local 127.0.0.1 also gets localhost as 
> name and not the system's host name.
>
> And also how can I make ippusbxd zeroconf-register the 
> ippusbxd-printers -> fd00:1:1::1 name assignment with Avahi, so that I 
> do not need to edit /etc/hosts?
>
> Thanks in advance for any kind of help.
>
>    Till
>
>
>
>
>
>
>
>
>
> _______________________________________________
> avahi mailing list
> avahi at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/avahi



More information about the avahi mailing list