How To: Create Printer Discovery in DNS for MAC Clients

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-subnets 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@master:/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 "rpz"; };

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 "rpz" {
	type master;
	file "/etc/bind/db.rpz";
};

Step 4

Create the above mentioned zone file /etc/bind/db.rpz with the following content

Please change

  • example.com” by your domain
  • printserver.example.com” by the full hostname of your printserver - dont forget the dot at the end.
  • “printer01” and “printer02” by the printernames of the printers, you want to publish
  • the TXT-values with your printers values. For informations about that, please consult your printers manufactor and Apples bonjour-documentation.
$TTL 60
@	IN	SOA	localhost. root.localhost. (
				1	; serial - needs to be increased on each change.
				1h	; refresh
				15m	; retry
				30d	; expiry
				2h	; minimum
			)
 			IN	NS localhost.

; define global dns-sd overwrites
b._dns-sd._udp.example.com			    IN PTR  printserver.example.com.
lb._dns-sd._udp.example.com			    IN PTR  printserver.example.com.

; define _ipp-records per printer
_ipp._tcp.example.com			        IN PTR  printer01._ipp._tcp.example.com.
_ipp._tcp.example.com			        IN PTR  printer02._ipp._tcp.example.com.

; define _cups-records per printer
_cups._sub._ipp._tcp.example.com		IN PTR  printer01._ipp._tcp.example.com.
_cups._sub._ipp._tcp.example.com		IN PTR  printer02._ipp._tcp.example.com.

; define _universal-records per printer
_universal._sub._ipp._tcp.example.com	IN PTR  printer01._ipp._tcp.example.com.
_universal._sub._ipp._tcp.example.com	IN PTR  printer02._ipp._tcp.example.com.

; define srv-records per printer
printer01._ipp._tcp.example.com	        IN SRV  0 0 631 printserver.example.com.
printer02._ipp._tcp.example.com	        IN SRV  0 0 631 printserver.example.com.

; define TXT-records per printer
printer01._ipp._tcp.example.com 		IN TXT ( 
			   "txtvers=1"
			   "qtotal=1"
			   "rp=printers/printer01"
			   "adminurl=ipp://printserver.example.com:631/printers/printer01"
			   "product=(Xerox WorkCentre 7556)"
			   "note=Room.121"
			   "ty=Xerox WorkCentre 7556"
			   "pdl=application/postscript"
			  )
printer02._ipp._tcp.example.com 		IN TXT ( 
			   "txtvers=1"
			   "qtotal=1"
			   "rp=printers/printer02"
			   "adminurl=ipp://printserver.example.com:631/printers/printer02"
			   "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 gives details about the used printer model.

You can check your zone-file with the following command:

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

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 your are using linux as guest operatingsystem, you can also check the DNS-settings with avahi:

root@master:~# avahi-browse -rt -d example.com _ipp._tcp
+   k.A. k.A. printer02                                     Internet Printer     example.com
+   k.A. k.A. printer01                                     Internet Printer     example.com
=   k.A. k.A. printer02                                     Internet Printer     example.com
   hostname = [printserver.example.com]
   address = [192.168.2.2]
   port = [631]
   txt = ["pdl=application/postscript" "ty=Xerox WorkCentre 7556" "note=Room.120" "product=(Xerox WorkCentre 7556)" "adminurl=ipp://printserver.example.com:631/printers/printer02" "rp=printers/printer02" "qtotal=1" "txtvers=1"]
=   k.A. k.A. printer01                                     Internet Printer     duch.on
   hostname = [printserver.example.com]
   address = [192.168.2.2]
   port = [631]
   txt = ["pdl=application/postscript" "ty=Xerox WorkCentre 7556" "note=Room.121" "product=(Xerox WorkCentre 7556)" "adminurl=ipp://printserver.example.com:631/printers/printer01" "rp=printers/printer01" "qtotal=1" "txtvers=1"]

Mastodon