How To: Create Printer Discovery in DNS for MAC Clients

dns
bind
printer
howto
bonjour
mdns

#1

Based on CUPS and DNS-SD printing.

How to create printer discovery in DNS for MAC clients

Mac OS from version 10.8 on discovers printer by using multicast DNS (mDNS or Bonjour). However, if your printers are located in a different IP-subnet this does not work as mDNS is limited to the local net only.
But mDNS works in conjunction with DNS Service Discovery (DNS-SD). So what you would need is to enable the bind nameserver from UCS to serve the needed service records.

Note: UMC currently does not allow the creation of such records. See this bug. Because of this the below steps are not persistent during updates. The files from Steps 2 will get overwritten every time when UMC rewrites the DNS configuration.
Additional Note: The changes could be made permanent when editing /etc/univention/templates/files/etc/bind/named.conf.samba4 but this will prevent UCS getting newer releases of this template file.

Workaround

Step 1

Identify the backend you are using for your environment by using the ucr command:

root@ucs:/etc/bind# ucr get dns/backend
ldap

If using Samba you would get “samba4” back instead of the above "ldap".

In the further steps you need to edit the configuration files according to your backend.

Step 2

Add the response-policy to your configuration file.

For ldap use named.conf.proxy.
For samba4 use named.conf.samba4.

In the section

options {
...
};

add the following lines:

response-policy {
  zone "rp-printer";
};

Step 3

Add the zone entry to the configuration files.

For ldap use /etc/bind/local.conf.proxy
For samba4 use /etc/bind/local.conf.samba4

Add the following lines:

zone "rp-printer" {
  type master;
  file "/etc/bind/rp-printer";
  allow-query { none; };
};

Step 4

Create the above mentioned zone file /etc/bind/rp-printer with the following content by replacing the “example.com” with your zone name:

$TTL 1H
@ SOA LOCALHOST. hostmaster.example.org (1 1h 15m 30d 2h)
 	NS LOCALHOST.

; define all internal domains to overwrite
b._dns-sd._udp           PTR  printserver.example.org.
lb._dns-sd._udp          PTR  printserver.example.org.
_ipp._tcp                PTR  printer._ipp._tcp.example.com.
_cups._sub._ipp._tcp      PTR  printer._ipp._tcp.example.com.
_universal._sub._ipp._tcp PTR  printer._ipp._tcp.example.com.
printer._ipp._tcp        SRV  0 0 631 printserver.example.com.
printer._ipp._tcp        TXT ( 
			   "txtvers=1"
			   "qtotal=1"
			   "rp=printers/printer"
			   "adminurl=ipp://printserver.examle.com:631/printers/printer102"
			   "product=(Xerox WorkCentre 7556)"
			   "note=Room.120"
			   "ty=Xerox WorkCentre 7556"
			   "pdl=application/postscript"
			  )

The b and lb entries tell the clients to use DNS for service discovery.
The _ipp and _cups entries point to the printer itself.
The _universal is needed for AirPrint.
The printer SRV record tells where the printer is attached to.
The TXT record just gives additional information regarding the printer.

You want to check if you created the file with correct syntax:

root@master:~# named-checkzone  example.com /etc/bind/printer-response-policy
zone example.com/IN: loaded serial 1
OK

If you are not getting the “OK” you need to check the file for typing errors.

Step 5

Restart your bind DNS server:

systemctl restart bind9

Step 6

Verify the entry is available by requesting the PTR records from your DNS server to see if it works:

host -t PTR _ipp._tcp.example.com

This will show all printer capable of doing IPP over TCP. If this works your basic setup works.

If you have avahi installed you can run the same check like this:

avahi-browse -t -d example.com _ipp._tcp