<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Pivotal Labs &#187; bonjour</title>
	<atom:link href="http://pivotallabs.com/tag/bonjour/feed/" rel="self" type="application/rss+xml" />
	<link>http://pivotallabs.com</link>
	<description>Agility Developed</description>
	<lastBuildDate>Wed, 19 Jun 2013 22:16:35 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Making Printers and Common Resources Available to Separate Network Segments via Bonjour and DNS-SD</title>
		<link>http://pivotallabs.com/moving-printers-and-common-resources-to-a-separate-network-and-making-them-easily-available-via-bonjour-and-dns-sd/</link>
		<comments>http://pivotallabs.com/moving-printers-and-common-resources-to-a-separate-network-and-making-them-easily-available-via-bonjour-and-dns-sd/#comments</comments>
		<pubDate>Wed, 28 Mar 2012 01:43:00 +0000</pubDate>
		<dc:creator>Brian Cunnie</dc:creator>
				<category><![CDATA[Labs]]></category>
		<category><![CDATA[bonjour]]></category>
		<category><![CDATA[djbdns]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[dns-sd]]></category>
		<category><![CDATA[ops]]></category>
		<category><![CDATA[tinydns]]></category>

		<guid isPermaLink="false">http://pivotallabs.com/moving-printers-and-common-resources-to-a-separate-network-and-making-them-easily-available-via-bonjour-and-dns-sd/</guid>
		<description><![CDATA[<p><h2>Abstract</h2>

<p>When we moved to a new office, we faced a problem:  how do we give printer access to everyone even though
we had segregated machines to different networks? And how do we make it transparent to the user?</p>

<p>The solution we found was to add a new VLAN &#40;i.e. network segment&#41; for the printers &#40;and other common resources, e.g. license servers&#41;, and use <a href="http://www.dns-sd.org/">DNS Service Discovery</a> &#40;dns-sd&#41; and a handful of crafted records to our DNS server.</p>

<p>This blog post is directed at Operations staff at companies which have the following characteristics:</p>

<ul>
<li>primarily use Apple workstations</li>
<li>have network-attached printers</li>
<li>use Bonjour for printer discovery</li>
<li>need to print from multiple VLANs</li>
</ul>

<h2>The Problem</h2>

<p>The short version:  people couldn't print from the WiFi network.</p> <a href="http://pivotallabs.com/moving-printers-and-common-resources-to-a-separate-network-and-making-them-easily-available-via-bonjour-and-dns-sd/">Continue reading <span class="meta-nav">&#8594;</span></a></p><p>The post <a href="http://pivotallabs.com/moving-printers-and-common-resources-to-a-separate-network-and-making-them-easily-available-via-bonjour-and-dns-sd/">Making Printers and Common Resources Available to Separate Network Segments via Bonjour and DNS-SD</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></description>
				<content:encoded><![CDATA[<h2>Abstract</h2>
<p>When we moved to a new office, we faced a problem: how do we give printer access to everyone though we had segregated machines to different networks? And how do we make it transparent to the user?</p>
<p>The solution we found was to add a new VLAN (i.e. network segment) for the printers (and other common resources, e.g. license servers), use <a href="http://www.dns-sd.org/">DNS Service Discovery</a> (dns-sd), and add a handful of crafted records to our DNS server.</p>
<p>This blog post is directed at Operations staff at companies which have the following characteristics:</p>
<ul>
<li>primarily use Apple workstations</li>
<li>have network-attached printers</li>
<li>use Bonjour for printer discovery</li>
<li>need to print from multiple VLANs</li>
<li>use djbdns</li>
</ul>
<h2>The Problem</h2>
<p>The short version: people couldn&#8217;t print from the WiFi network.</p>
<h2>Network/VLAN Configuration</h2>
<p>This is a synopsis of our network (note: the IP addresses and subnet masks are simplified for purposes of our discussion):</p>
<pre><code>VLAN    Name            IP
1       PIVOT           10.0.1.0/24
2       SERVER          10.0.2.0/24
3       PAIRING_DMZ     10.0.3.0/24
4       VOIP            10.0.4.0/24
5       PIVOTAL_WIFI    10.0.5.0/24
6       PIVOTAL_GUEST   10.0.6.0/24
7       SECURITY        10.0.7.0/24
8       COMMON          10.0.8.0/24
</code></pre>
<p>Note that the last VLAN (&#8220;COMMON&#8221;) is the one where we have placed all the resources. We named it <em>COMMON</em> as in &#8220;Common Resources&#8221;.</p>
<h2>Determining What Records Needed to be Added</h2>
<p>We used a <a href="http://www.tildesoft.com/">bonjour browser</a> to discover which records we needed to add (note: you need to run the bonjour browser on a machine that is on <em>the same network</em> as the printers, otherwise the printers won&#8217;t show up). We navigated as follows: local. → _pdl-datastream._tcp. <sup><a href="#ftn.idpdl" name="idpdl">1</a></sup> We found our printers (goldfinger and blofeld, named after James Bond villains). Here are the relevant records for Goldfinger:</p>
<ul>
<li>Goldfinger
<ul>
<li>goldfinger.local.:9100</li>
<li>txtvers=1</li>
<li>qtotal=1</li>
<li>pdl=application/postscript,application/vnd.hp-PCL,application/vnd.hp-PCLXL</li>
<li>ty=HP Color LaserJet 4700</li>
<li>product=(HP Color LaserJet 4700)</li>
<li>priority=40</li>
<li>adminurl=http://goldfinger.local.</li>
</ul>
</li>
</ul>
<p>In our setup, we use tinydns to serve our DNS records. For those using BIND, the dns-sd.org website has an excellent <a href="http://www.dns-sd.org/ServerSetup.html">how-to</a>.</p>
<h2>Add the Required DNS-SD records</h2>
<p>First, we need to create the basic dns-sd records. We only need to add these records once.</p>
<pre><code>^b._dns-sd._udp.sf.pivotallabs.com.:sf.pivotallabs.com.:86400::
^lb._dns-sd._udp.sf.pivotallabs.com.:sf.pivotallabs.com.:86400::
</code></pre>
<h2>Translating the bonjour records to DNS—the easy way</h2>
<p>Download this <a href="https://raw.github.com/cunnie/bin/master/make_printer_dns">script</a> to create the DNS records (courtesy Michael Sierchio). Save the script as &#8220;make_printer_dns&#8221;.  Then use the bonjour browser to extract the printer information and save that information to a file with the same name as the printer (e.g. hp4020.sf.pivotallabs.com).  In this example, we use a <a href="http://en.wikipedia.org/wiki/Here_document">heredoc</a> to save the information extracted from the HP 4700 Color Laserjet, and then we run the script to output the djbdns records:</p>
<pre><code>$ cat &gt; goldfinger.sf.pivotallabs.com. &lt;&lt;EOF
txtvers=1
qtotal=1
pdl=application/postscript,application/vnd.hp-PCL,application/vnd.hp-PCLXL
ty=HP Color LaserJet 4700
product=(HP Color LaserJet 4700)
priority=40
adminurl=http://goldfinger.sf.pivotallabs.com.
EOF
$ make_printer_dns goldfinger.sf.pivotallabs.com. 

^_pdl-datastream._tcp.sf.pivotallabs.com.:goldfinger._pdl-datastream._tcp.sf.pivotallabs.com.
:goldfinger._pdl-datastream._tcp.sf.pivotallabs.com.:33:\000\000\000\000\043\214\012goldfinger\002sf\013pivotallabs\003com\000\000
:goldfinger._pdl-datastream._tcp.sf.pivotallabs.com.:16:\011txtvers=1\010qtotal=1\112pdl=application/postscript,application/vnd.hp-PCL,application/vnd.hp-PCLXL\031ty=HP Color LaserJet 4700\040product=(HP Color LaserJet 4700)\013priority=40\056adminurl=http\072//goldfinger.sf.pivotallabs.com.</code></pre>
<p>Copy the above records into your djbdns source files and regenerate the database (i.e. tinydns-data).  You have now created the  records necessary to allow printer discovery across subnets.</p>
<h2>Translating the bonjour records to DNS—the hard way</h2>
<p><em>[Editor's note:  do not use this hard technique; use the easy way instead.  This portion is meant for instruction rather than actual implementation]</em></p>
<p>We add a PTR record for Goldfinger printer. We&#8217;ll need to add a similar record every time we add a new printer:</p>
<pre><code>^_pdl-datastream._tcp.sf.pivotallabs.com.:Goldfinger._pdl-datastream._tcp.sf.pivotallabs.com.
</code></pre>
<p>Then we need to create DNS SRV records for the Goldfinger printer. These can be crafted by hand, but I prefer to use Anders Brownworth&#8217;s <a href="http://anders.com/projects/sysadmin/djbdnsRecordBuilder/">tinydns record builder</a>. We enter the following information for the SRV record builder:</p>
<ul>
<li>Service: <strong>Goldfinger._pdl-datastream._tcp.sf.pivotallabs.com.</strong></li>
<li>Priority: <strong>0</strong></li>
<li>Weight: <strong>0</strong></li>
<li>Port: <strong>9100</strong></li>
<li>Target: <strong>goldfinger.sf.pivotallabs.com.</strong></li>
<li>Time To Live: <strong>86400</strong></li>
</ul>
<p>Anders&#8217;s script gives us the following record, which we add to our tinydns records:</p>
<pre><code>:Goldfinger._pdl-datastream._tcp.sf.pivotallabs.com.:33:\000\000\000\000\043\214\012goldfinger\002sf\013pivotallabs\003com\000:86400
</code></pre>
<p>But we&#8217;re not done: we still need to create the TXT record which has the important information we uncovered with our bonjour browser. A regular tinydns TXT record (one which begins with a &#8220;&#8216;&#8221;) won&#8217;t do because we have <em>several</em> records. We need to use a generic record (a special TXT record). This one we&#8217;ll need to handcraft.</p>
<ul>
<li>First, start with a colon (&#8220;:&#8221;) to indicate a generic record, then add the FQDN:</li>
</ul>
<pre><code>
:Goldfinger._pdl-datastream._tcp.sf.pivotallabs.com.
</code></pre>
<ul>
<li>Then, append the record type (TXT, type 16):</li>
</ul>
<pre><code>
:16:
</code></pre>
<ul>
<li>Then we&#8217;ll need to prepare our data. We take the information we pulled from the Bonjour browser:</li>
</ul>
<pre><code>
txtvers=1
qtotal=1
pdl=application/postscript,application/vnd.hp-PCL,application/vnd.hp-PCLXL
ty=HP Color LaserJet 4700
product=(HP Color LaserJet 4700)
priority=40
adminurl=http://goldfinger.sf.pivotallabs.com.
</code></pre>
<ul>
<li>Then we pipe that data through a small ruby script:</li>
</ul>
<pre><code>
ruby -e 'STDIN.read.split("\n").each { |t| printf("\\%03o%s",t.length,t.gsub(":","\\\\072")) }; puts'
</code></pre>
<ul>
<li>We take the result, and append it to our record. Our final record looks like this:</li>
</ul>
<pre><code>
:Goldfinger._pdl-datastream._tcp.sf.pivotallabs.com.:16:\011txtvers=1\010qtotal=1\112pdl=application/postscript,application/vnd.hp-PCL,application/vnd.hp-PCLXL\031ty=HP Color LaserJet 4700\040product=(HP Color LaserJet 4700)\013priority=40\056adminurl=http\072//goldfinger.sf.pivotallabs.com.
</code></pre>
<h2>Testing the output</h2>
<p>Once we&#8217;ve added the records and rebuilt our djbdns database, we test to make sure it really works:</p>
<pre><code>nslookup -query=srv goldfinger._pdl-datastream._tcp.sf.pivotallabs.com.
Server:		10.80.0.18
Address:	10.80.0.18#53

Non-authoritative answer:
goldfinger._pdl-datastream._tcp.sf.pivotallabs.com	service = 0 0 9100 goldfinger.sf.pivotallabs.com.</code></pre>
<pre><code>
nslookup -query=txt Goldfinger._pdl-datastream._tcp.sf.pivotallabs.com.

Goldfinger._pdl-datastream._tcp.sf.pivotallabs.com  text = "txtvers=1" "qtotal=1" "pdl=application/postscript,application/vnd.hp-PCL,application/vnd.hp-PCLXL" "ty=HP Color LaserJet 4700" "product=(HP Color LaserJet 4700)" "priority=40" "adminurl=http://goldfinger.sf.pivotallabs.com."</code></pre>
<p>Note the following:</p>
<ul>
<li>we have replaced the bonjour hostname, &#8220;goldfinger.local.&#8221;, with the fully qualified DNS name, &#8220;goldfinger.sf.pivotallabs.com.&#8221;</li>
<li>we have ignored the very first bonjour record, &#8220;goldfinger.local.:9100&#8243;. It served no purpose in dns-sd.</li>
</ul>
<h2>Success</h2>
<p>After restarting our DNS server, our clients were able to add a printer easily through Mac OS X&#8217;s System Preferences → Printers → &#8220;+&#8221;.</p>
<h2>Gotchas</h2>
<p>Client machines need to have the domain (e.g. &#8220;sf.pivotallabs.com&#8221;) in their search-path for dns-sd to work. For ISC-dhcpd, the appropriate entry would be &#8220;option domain-name &#8216;sf.pivotallabs.com&#8217;;&#8221;</p>
<p>We noticed a propagation delay with older (Snow Leopard) Macs—they didn&#8217;t always see the printers right away. In these cases, we tried flushing the DNS cache (&#8220;dscacheutil -flushcache&#8221; or, in Lion, &#8220;sudo killall -HUP mDNSResponder&#8221;), but that seemed to have no effect. A few days later the printers became discoverable from those workstations.</p>
<p>Apple clients will use SNMP queries to determine some of the printers capabilities.  We encourage you to all SNMP traffic to the network where the printers are located.</p>
<h2>Footnotes</h2>
<p><sup><a href="#idpdl" name="ftn.idpdl">1</a></sup> <em>pdl-datastream</em> is a <a href="http://www.iana.org/assignments/port-numbers">Registered Port</a> for printing. There are at least 2 other ports commonly used for printing: <em>ipp</em> (631) and <em>printer</em> (515). Our decision to use <em>pdl-datastream</em> over the other two was arbitrary. That being said, we have found that using the <em>ipp</em> port to be counter-productive and should be avoided. We have found that when we advertise ipp <em>and</em> the printer in question is <a href="http://en.wikipedia.org/wiki/AirPrint">Airprint</a>-capable, then printing will not work (I suspect AirPrint does not work across subnets, but am not sure).</p>
<h2>Acknowledgements</h2>
<p>Special thanks to my co-authors <a href="http://www.tenebras.com">Michael Sierchio</a> and <a href="https://github.com/mkocher">Matthew Kocher</a></p>
<h2>Keywords</h2>
<p>tinydns, dns-sd, DNS Service Discovery</p>
<p>The post <a href="http://pivotallabs.com/moving-printers-and-common-resources-to-a-separate-network-and-making-them-easily-available-via-bonjour-and-dns-sd/">Making Printers and Common Resources Available to Separate Network Segments via Bonjour and DNS-SD</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://pivotallabs.com/moving-printers-and-common-resources-to-a-separate-network-and-making-them-easily-available-via-bonjour-and-dns-sd/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic (Feed is rejected)
Page Caching using apc
Database Caching 3/7 queries in 0.006 seconds using apc
Object Caching 405/413 objects using apc

 Served from: pivotallabs.com @ 2013-06-19 19:07:14 by W3 Total Cache -->