Discussion:
[avahi] Bonjour/Avahi broadcasting with host names
Till Kamppeter
2017-01-09 21:54:43 UTC
Permalink
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
Trent Lloyd
2017-05-20 05:18:04 UTC
Permalink
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
Post by Till Kamppeter
Hi,
tl;dr: Local IPv6 IP address has an alternative host name assigned but
Avahi broadcast uses the system's default host name.
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
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
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
https://lists.freedesktop.org/mailman/listinfo/avahi
Loading...