<?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>Services (Printing + Networking) | FreeBSD Foundation</title>
	<atom:link href="https://staging.freebsdfoundation.org/topic/services-printing-networking/feed/" rel="self" type="application/rss+xml" />
	<link>https://staging.freebsdfoundation.org</link>
	<description>A non-profit organization dedicated to supporting and building the FreeBSD Project</description>
	<lastBuildDate>Sat, 24 Aug 2024 13:28:28 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://staging.freebsdfoundation.org/wp-content/uploads/2015/12/favicon.png</url>
	<title>Services (Printing + Networking) | FreeBSD Foundation</title>
	<link>https://staging.freebsdfoundation.org</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Networking Basics: WiFi and Bluetooth</title>
		<link>https://staging.freebsdfoundation.org/resource/networking-basics-wifi-and-bluetooth/</link>
		
		<dc:creator><![CDATA[Anne Dickison]]></dc:creator>
		<pubDate>Mon, 15 Aug 2022 18:33:01 +0000</pubDate>
				<guid isPermaLink="false">https://freebsdfoundation.org/?post_type=resource&#038;p=11565</guid>

					<description><![CDATA[<p>Our latest how-to guide is all about networks, covering the basics of Wi-Fi and Bluetooth. Learn how to set up and configure Wi-Fi and Bluetooth on FreeBSD devices, even when the network is hidden. Further setup for USB tethering and using your FreeBSD device as an access point is also covered. This is intended to be an introductory level guide, with only limited required experience of the FreeBSD operating system.</p>
<p>The post <a href="https://staging.freebsdfoundation.org/resource/networking-basics-wifi-and-bluetooth/">Networking Basics: WiFi and Bluetooth</a> first appeared on <a href="https://staging.freebsdfoundation.org">FreeBSD Foundation</a>.</p>]]></description>
										<content:encoded><![CDATA[<section class="block block-classic-editor"><p></section><section class="block block-core-spacer"></p>
<div class="wp-block-spacer" aria-hidden="true"> </div>
<p></section>
<div class="wp-block-image"><section class="block block-core-image"></p>
<figure class="aligncenter size-large"><img fetchpriority="high" decoding="async" width="1024" height="512" class="wp-image-11216" src="https://staging.freebsdfoundation.org/wp-content/uploads/2022/04/Untitled-design-8-1024x512.png" alt="" srcset="https://staging.freebsdfoundation.org/wp-content/uploads/2022/04/Untitled-design-8-1024x512.png 1024w, https://staging.freebsdfoundation.org/wp-content/uploads/2022/04/Untitled-design-8-300x150.png 300w, https://staging.freebsdfoundation.org/wp-content/uploads/2022/04/Untitled-design-8-1536x768.png 1536w, https://staging.freebsdfoundation.org/wp-content/uploads/2022/04/Untitled-design-8-2048x1024.png 2048w, https://staging.freebsdfoundation.org/wp-content/uploads/2022/04/Untitled-design-8.png 1920w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
<p></section></div>
<section class="block block-core-heading"></p>
<h2 class="wp-block-heading" id="_kernel_configuration">Wireless Configuration/Set-up</h2>
<p></section>
<section class="block block-core-separator"></p>
<hr class="wp-block-separator has-css-opacity" />
<p></section>
<section class="block block-core-paragraph"></p>
<p>A wireless networking card is required to use a wireless network, FreeBSD will also need to be configured to the correct wireless network support. The correct module will need to be modified, depending on the type of networking card. The most commonly used wireless devices are those that use parts made by Atheros. These devices are supported by <a href="https://www.freebsd.org/cgi/man.cgi?query=ath&amp;sektion=4&amp;format=html" target="_blank" rel="noreferrer noopener">ath(4)</a> and require the following line to be added to <code>/boot/loader.conf</code>:</p>
<p></section>
<section class="block block-core-preformatted"></p>
<pre class="wp-block-preformatted"><code>if_ath_load="YES"</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>If unsure about the device, you can identify many common wireless adaptors through the use of the  <a href="https://www.freebsd.org/cgi/man.cgi?query=sysctl&amp;sektion=8&amp;format=html" target="_blank" rel="noreferrer noopener">sysctl(8)</a> <code>net.wlan.devices</code> variable:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code>% sysctl net.wlan.devices</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>To load support for a different type of wireless device, specify the module for that device. This example is for devices based on the Intersil Prism parts (<a href="https://www.freebsd.org/cgi/man.cgi?query=wi&amp;sektion=4&amp;format=html" target="_blank" rel="noreferrer noopener">wi(4)</a>) driver:</p>
<p></section>
<section class="block block-core-preformatted"></p>
<pre class="wp-block-preformatted"><code>if_wi_load="YES"</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p><strong>Note:</strong><em> A list of available wireless drivers and supported adapters can be found in the FreeBSD Hardware Notes, available on the <a href="https://www.freebsd.org/releases/" target="_blank" rel="noreferrer noopener">Release Information</a> page of the FreeBSD website. </em></p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>In addition, the modules that implement cryptographic support for the security protocols to use must be loaded. These are intended to be dynamically loaded on demand by the <a href="https://www.freebsd.org/cgi/man.cgi?query=wlan&amp;sektion=4&amp;format=html" target="_blank" rel="noreferrer noopener">wlan(4)</a> module. To load these modules at boot time, add the following lines to /boot/loader.conf:</p>
<p></section>
<section class="block block-core-preformatted"></p>
<pre class="wp-block-preformatted">wlan_wep_load="YES"
wlan_ccmp_load="YES"
wlan_tkip_load="YES"</pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Information about the wireless device should appear in the boot messages, like this:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code>ath0: &lt;Atheros 5212&gt; mem 0x88000000-0x8800ffff irq 11 at device 0.0 on cardbus1
ath0: [ITHREAD]
ath0: AR2413 mac 7.9 RF2413 phy 4.5</code></pre>
<p></section>
<section class="block block-core-spacer"></p>
<div class="wp-block-spacer" aria-hidden="true"> </div>
<p></section>
<section class="block block-core-heading"></p>
<h2 class="wp-block-heading">Connecting to a Network:</h2>
<p></section>
<section class="block block-core-separator"></p>
<hr class="wp-block-separator has-css-opacity" />
<p></section>
<section class="block block-core-heading"></p>
<h3 class="wp-block-heading">Open Networks</h3>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Directly connecting to an unsecure network, while not recommended, is extremely common. It&#8217;s also a very simple process on FreeBSD. In this example I&#8217;ll beconnecting to the John F Kennedy International Airport&#8217;s free WiFi.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Start by finding the name of the network:</p>
<p></section>
<section class="block block-core-preformatted"></p>
<pre class="wp-block-preformatted">ifconfig wlan0 up scan</pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>This will look for available networks and return a list, In this case, we want to connect to the JFK free wifi so we&#8217;ll use:</p>
<p></section>
<section class="block block-core-preformatted"></p>
<pre class="wp-block-preformatted">ifconfig wlan0 ssid _Free JFK WiFi</pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Hopefully you will see that it&#8217;s joined, and running ifconfig ath0 will show that it&#8217;s associated. You can then get an address with:</p>
<p></section>
<section class="block block-core-preformatted"></p>
<pre class="wp-block-preformatted">dhclient wlan0</pre>
<p></section>
<section class="block block-core-heading"></p>
<h3 class="wp-block-heading"><strong>WPA/WPA2/Personal</strong></h3>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Most home/private networks will rely on these security protocols. Connecting a computer to an existing WPA/WPA2/Personal wireless network is a very common situation.</p>
<p></section>
<section class="block block-core-list"></p>
<ul class="wp-block-list">
	<li>Obtain the SSID (Service Set Identifier) and PSK (Pre-Shared Key) from the network administrator, these may also be listed on the router.</li>
	<li>Add an entry for this network to <code>/etc/wpa_supplicant.conf</code>. If the file does not exist, create it. Replace <em>myssid</em> and <em>mypsk</em> with the SSID and PSK provided by the network administrator.</li>
</ul>
<p></section>
<section class="block block-core-preformatted"></p>
<pre class="wp-block-preformatted">network={ 
        ssid="myssid" 
        psk="mypsk" 
}
</pre>
<p></section>
<section class="block block-core-list"></p>
<ul class="wp-block-list">
	<li><strong>Note</strong>: If the wireless network is <em>hidden</em>, add an additional line to indicate that the network is not publicly visible.</li>
</ul>
<p></section>
<section class="block block-core-preformatted"></p>
<pre class="wp-block-preformatted">network={
        scan_ssid=1
        ssid="mywpa"
        psk="1234"
}</pre>
<p></section>
<section class="block block-core-list"></p>
<ul class="wp-block-list">
	<li>Add entries to <code>/etc/rc.conf</code> to configure the network on startup. Make sure to use the correct wireless adapter as identified earlier (this example will use the Atheros <code>ath0</code> wireless adapter).</li>
</ul>
<p></section>
<section class="block block-core-preformatted"></p>
<pre class="wp-block-preformatted">wlans_ath0="wlan0" 
ifconfig_wlan0="WPA SYNCDHCP"</pre>
<p></section>
<section class="block block-core-list"></p>
<ul class="wp-block-list">
	<li>Restart the computer, or restart the network service to connect to the network:</li>
</ul>
<p></section>
<section class="block block-core-preformatted"></p>
<pre class="wp-block-preformatted"># service netif restart</pre>
<p></section>
<section class="block block-core-spacer"></p>
<div class="wp-block-spacer" aria-hidden="true"> </div>
<p></section>
<section class="block block-core-heading"></p>
<h2 class="wp-block-heading">FreeBSD as an Access Point:</h2>
<p></section>
<section class="block block-core-separator"></p>
<hr class="wp-block-separator has-css-opacity" />
<p></section>
<section class="block block-core-paragraph"></p>
<p>FreeBSD can act as an Access Point (AP) in order to act as a gateway or to eliminate the need to purchase AP hardware. Before an Access Point can be set up, the kernel must be configured with the appropriate networking support for the wireless card as well as the security protocols being used. This mode is only supported by native FreeBSD wireless drivers.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>After setting up wireless networking, you can check if the device supports host-based access point mode:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># ifconfig wlan0 create wlandev ath0
# ifconfig wlan0 list caps
drivercaps=6f85edc1&lt;STA,FF,TURBOP,IBSS,<strong><span class="has-inline-color has-luminous-vivid-orange-color">HOSTAP</span></strong>,AHDEMO,TXPMGT,SHSLOT,SHPREAMBLE,MONITOR,MBSS,WPA1,WPA2,BURST,WME,WDS,BGSCAN,TXFRAG&gt;
cryptocaps=1f&lt;WEP,TKIP,AES,AES_CCM,TKIPMIC&gt;</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>This output displays the card’s capabilities. The <strong><span class="has-inline-color has-luminous-vivid-orange-color"><code>HOSTAP</code> </span></strong>word confirms that this wireless card can act as an AP.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>The wireless device can only be put into hostap mode during the creation of the network pseudo-device, so a previously created device must be destroyed first:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># ifconfig wlan0 destroy</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>then regenerated with the correct option before setting the other parameters:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># ifconfig wlan0 create wlandev ath0 wlanmode hostap
# ifconfig wlan0 inet 192.168.0.1 netmask 255.255.255.0 ssid freebsdap mode 11g channel 1</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Use <a href="https://www.freebsd.org/cgi/man.cgi?query=ifconfig&amp;sektion=8&amp;format=html" target="_blank" rel="noreferrer noopener">ifconfig(8)</a> again to see the status of the wlan0 interface:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># ifconfig wlan0
  wlan0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; metric 0 mtu 1500
	  ether 00:11:95:c3:0d:ac
	  inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
	  media: IEEE 802.11 Wireless Ethernet autoselect mode 11g &lt;<span class="has-inline-color has-luminous-vivid-orange-color"><strong>hostap</strong></span>&gt;
	  status: running
	  ssid freebsdap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
	  country US ecm authmode OPEN privacy OFF txpower 21.5 scanvalid 60
	  protmode CTS wme burst dtimperiod 1 -dfs</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>The <strong><span class="has-inline-color has-luminous-vivid-orange-color"><code>hostap</code> </span></strong>parameter indicates the interface is running in the host-based access point mode.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>The interface configuration can be done automatically at boot time by adding the following lines to <code>/etc/rc.conf</code>:</p>
<p></section>
<section class="block block-core-preformatted"></p>
<pre class="wp-block-preformatted">wlans_ath0="wlan0"
create_args_wlan0="wlanmode hostap"
ifconfig_wlan0="inet 192.168.0.1 netmask 255.255.255.0 ssid freebsdap mode 11g channel 1"</pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p id="block-f5bdf692-e2f3-4f0a-b7b1-71df80dba746">Once the AP is configured, initiate a scan from another wireless machine to find the AP.</p>
<p></section>
<section class="block block-core-spacer"></p>
<div class="wp-block-spacer" aria-hidden="true"> </div>
<p></section>
<section class="block block-core-heading"></p>
<h2 class="wp-block-heading">USB Tethering</h2>
<p></section>
<section class="block block-core-separator"></p>
<hr class="wp-block-separator has-css-opacity" />
<p></section>
<section class="block block-core-paragraph"></p>
<p>Many cellphones can share data connection over USB, FreeBSD provides support through a variety of protocols:</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Before attaching a device, load the appropriate driver into the kernel:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># kldload if_urndis                     # driver generally used by Android&#x2122; device
# kldload if_ipheth                     # driver used by Apple® devices
# kldload if_cdce                       # driver often used in older devices</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Once the device is attached <code>ue</code><em>0</em> will be available for use like a normal network device. Be sure that the &#8220;USB tethering&#8221; option is enabled on the mobile device.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>To make this change permanent and load the driver as a module at boot time, place the appropriate line of the following in /boot/loader.conf:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code>if_urndis_load="YES"
if_cdce_load="YES"
if_ipheth_load="YES"</code></pre>
<p></section>
<section class="block block-core-spacer"></p>
<div class="wp-block-spacer" aria-hidden="true"> </div>
<p></section>
<div class="wp-block-image"><section class="block block-core-image"></p>
<figure class="aligncenter size-large"><img decoding="async" width="1024" height="512" class="wp-image-11217" src="https://staging.freebsdfoundation.org/wp-content/uploads/2022/04/Untitled-design-9-1024x512.png" alt="" srcset="https://staging.freebsdfoundation.org/wp-content/uploads/2022/04/Untitled-design-9-1024x512.png 1024w, https://staging.freebsdfoundation.org/wp-content/uploads/2022/04/Untitled-design-9-300x150.png 300w, https://staging.freebsdfoundation.org/wp-content/uploads/2022/04/Untitled-design-9-1536x768.png 1536w, https://staging.freebsdfoundation.org/wp-content/uploads/2022/04/Untitled-design-9-2048x1024.png 2048w, https://staging.freebsdfoundation.org/wp-content/uploads/2022/04/Untitled-design-9.png 1920w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
<p></section></div>
<section class="block block-core-heading"></p>
<h1 class="wp-block-heading">Bluetooth:</h1>
<p></section>
<section class="block block-core-paragraph"></p>
<p>&nbsp;</p>
<p></section>
<section class="block block-core-heading"></p>
<h2 class="wp-block-heading" id="_loading_bluetooth_support">Loading Bluetooth Support</h2>
<p></section>
<section class="block block-core-separator"></p>
<hr class="wp-block-separator has-css-opacity" />
<p></section>
<section class="block block-core-paragraph"></p>
<p>Before attaching a Bluetooth device, determine which Bluetooth driver it uses. A broad variety of Bluetooth USB dongles are supported by <a href="https://www.freebsd.org/cgi/man.cgi?query=ng_ubt&amp;sektion=4&amp;format=html">ng_ubt(4)</a>. Broadcom BCM2033 based Bluetooth devices are supported by the <a href="https://www.freebsd.org/cgi/man.cgi?query=ubtbcmfw&amp;sektion=4&amp;format=html">ubtbcmfw(4)</a> and <a href="https://www.freebsd.org/cgi/man.cgi?query=ng_ubt&amp;sektion=4&amp;format=html">ng_ubt(4)</a> drivers. The 3Com Bluetooth PC Card 3CRWB60-A is supported by the <a href="https://www.freebsd.org/cgi/man.cgi?query=ng_bt3c&amp;sektion=4&amp;format=html">ng_bt3c(4)</a> driver. Serial and UART based Bluetooth devices are supported by <a href="https://www.freebsd.org/cgi/man.cgi?query=sio&amp;sektion=4&amp;format=html">sio(4)</a>, <a href="https://www.freebsd.org/cgi/man.cgi?query=ng_h4&amp;sektion=4&amp;format=html">ng_h4(4)</a>, and <a href="https://www.freebsd.org/cgi/man.cgi?query=hcseriald&amp;sektion=8&amp;format=html">hcseriald(8)</a>. For example, if the device uses the <a href="https://www.freebsd.org/cgi/man.cgi?query=ng_ubt&amp;sektion=4&amp;format=html">ng_ubt(4)</a> driver:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># kldload ng_ubt</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>If the Bluetooth device will be attached to the system during system startup, the system can be configured to load the module at boot time by adding the driver to <code>/boot/loader.conf</code>:</p>
<p></section>
<section class="block block-core-preformatted"></p>
<pre class="wp-block-preformatted">ng_ubt_load="YES"</pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Once the driver is loaded, plug in the USB dongle. If the driver load was successful, output similar to the following should appear on the console and in <code>/var/log/messages</code>:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code>ubt0: vendor 0x0a12 product 0x0001, rev 1.10/5.25, addr 2
ubt0: Interface 0 endpoints: interrupt=0x81, bulk-in=0x82, bulk-out=0x2
ubt0: Interface 1 (alt.config 5) endpoints: isoc-in=0x83, isoc-out=0x3,
      wMaxPacketSize=49, nframes=6, buffer size=294</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>To start and stop Bluetooth, use the driver&#8217;s startup script.</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># service bluetooth start ubt0</code></pre>
<p></section>
<section class="block block-core-spacer"></p>
<div class="wp-block-spacer" aria-hidden="true"> </div>
<p></section>
<section class="block block-core-heading"></p>
<h2 class="wp-block-heading" id="_finding_other_bluetooth_devices">Finding Other Bluetooth Devices</h2>
<p></section>
<section class="block block-core-separator"></p>
<hr class="wp-block-separator has-css-opacity" />
<p></section>
<section class="block block-core-paragraph"></p>
<p>FreeBSD uses <a href="https://www.freebsd.org/cgi/man.cgi?query=hccontrol&amp;sektion=8&amp;format=html" target="_blank" rel="noreferrer noopener">hccontrol(8)</a> to find and identify Bluetooth devices within RF proximity.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>One of the most common tasks is discovery of Bluetooth devices within RF proximity. This operation is called <em>inquiry</em>. Inquiry and other HCI related operations are done using <a href="https://www.freebsd.org/cgi/man.cgi?query=hccontrol&amp;sektion=8&amp;format=html">hccontrol(8)</a>. To display a list of devices that are in range use:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code>% hccontrol -n ubt0hci inquiry
Inquiry result, num_responses=1
Inquiry result #0
       <span class="has-inline-color has-luminous-vivid-orange-color"><strong>BD_ADDR</strong></span>: 00:80:37:29:19:a4
       Page Scan Rep. Mode: 0x1
       Page Scan Period Mode: 00
       Page Scan Mode: 00
       Class: 52:02:04
       Clock offset: 0x78ef
Inquiry complete. Status: No error [00]</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p><strong>Note</strong>: only devices that are set to discoverable mode will be li<em>sted.</em></p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>The <span class="has-inline-color has-luminous-vivid-orange-color"><strong><code>BD_ADDR</code> </strong></span>is the unique address of a Bluetooth device, similar to the MAC address of a network card. This address is needed for further communication with a device. To to obtain the human readable name that was assigned to the remote device:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code>% hccontrol -n ubt0hci remote_name_request 00:80:37:29:19:a4
BD_ADDR: 00:80:37:29:19:a4
Name: Pav's T39</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>The Bluetooth system provides a point-to-point connection between two Bluetooth units, or a point-to-multipoint connection which is shared among several Bluetooth devices. The following example shows how to create a connection to a remote device:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code>% hccontrol -n ubt0hci create_connection BT_ADDR</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p><code>create_connection</code> accepts <code>BT_ADDR</code> as well as host aliases in /etc/bluetooth/hosts.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>The following example shows how to obtain the list of active baseband connections for the local device:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code>% hccontrol -n ubt0hci read_connection_list
Remote BD_ADDR    Handle Type Mode Role Encrypt Pending Queue State
00:80:37:29:19:a4     41  ACL    0 MAST    NONE       0     0 OPEN</code></pre>
<p></section>
<section class="block block-core-spacer"></p>
<div class="wp-block-spacer" aria-hidden="true"> </div>
<p></section>
<section class="block block-core-heading"></p>
<h2 class="wp-block-heading" id="_device_pairing">Bluetooth Device Pairing</h2>
<p></section>
<section class="block block-core-separator"></p>
<hr class="wp-block-separator has-css-opacity" />
<p></section>
<section class="block block-core-paragraph"></p>
<p>While a Bluetooth device can choose to require authentication, communication is normally not authenticated, so any Bluetooth device can talk to any other device. If the device requires authentication, the <em>PIN</em> code must be entered on both devices, the devices will then generate a <em>link key</em>. After that, the link key can be stored either in the devices or in a persistent storage. This procedure is called <em>pairing</em>.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>The <a href="https://www.freebsd.org/cgi/man.cgi?query=hcsecd&amp;sektion=8&amp;format=html">hcsecd(8)</a> daemon is responsible for handling Bluetooth authentication requests. The default configuration file is <code>/etc/bluetooth/hcsecd.conf</code>. An example section for a cellular phone with the PIN code set to <code>1234</code> is shown below:</p>
<p></section>
<section class="block block-core-preformatted"></p>
<pre class="wp-block-preformatted">device {
        bdaddr  00:80:37:29:19:a4;
        name    "iPhone";
        key     nokey;
        pin     "1234";
      }</pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>The only limitation on PIN codes is length. Some devices, such as Bluetooth headsets, may have a fixed PIN code built in. The <code>-d</code> switch forces <a href="https://www.freebsd.org/cgi/man.cgi?query=hcsecd&amp;sektion=8&amp;format=html">hcsecd(8)</a> to stay in the foreground, so it is easy to see what is happening. Set the remote device to receive pairing and initiate the Bluetooth connection to the remote device. The remote device should indicate that pairing was accepted and request the PIN code. Enter the same PIN code listed in<code> hcsecd.conf</code>. Now the computer and the remote device are paired.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>The following line can be added to /etc/rc.conf to configure <a href="https://www.freebsd.org/cgi/man.cgi?query=hcsecd&amp;sektion=8&amp;format=html">hcsecd(8)</a> to start automatically on system start:</p>
<p></section>
<section class="block block-core-preformatted"></p>
<pre class="wp-block-preformatted">hcsecd_enable="YES"</pre>
<p></section><section class="block block-classic-editor"></p></section><p>The post <a href="https://staging.freebsdfoundation.org/resource/networking-basics-wifi-and-bluetooth/">Networking Basics: WiFi and Bluetooth</a> first appeared on <a href="https://staging.freebsdfoundation.org">FreeBSD Foundation</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Audio on FreeBSD – Quick Guide</title>
		<link>https://staging.freebsdfoundation.org/resource/audio-on-freebsd-quick-guide/</link>
		
		<dc:creator><![CDATA[Anne Dickison]]></dc:creator>
		<pubDate>Mon, 15 Aug 2022 15:05:30 +0000</pubDate>
				<guid isPermaLink="false">https://freebsdfoundation.org/?post_type=resource&#038;p=11535</guid>

					<description><![CDATA[<p>Whether for music, communication, or notifications, audio is an important feature of many personal computer systems. In a new FreeBSD system, an audio card will need to be configured to process audio files and send them to the connected speakers. Our newest FreeBSD quick guide will walk through setting up and configuring audio, connecting a pair of headphones (including pairing Bluetooth models), and testing the system's sound, all in under 10 minutes!</p>
<p>The post <a href="https://staging.freebsdfoundation.org/resource/audio-on-freebsd-quick-guide/">Audio on FreeBSD – Quick Guide</a> first appeared on <a href="https://staging.freebsdfoundation.org">FreeBSD Foundation</a>.</p>]]></description>
										<content:encoded><![CDATA[<section class="block block-classic-editor"><p></section><div class="wp-block-image"><section class="block block-core-image"></p>
<figure class="aligncenter size-large is-resized"><img decoding="async" class="wp-image-11339" src="https://staging.freebsdfoundation.org/wp-content/uploads/2022/06/Untitled-design-12-1024x1024.png" alt="" width="431" height="431" srcset="https://staging.freebsdfoundation.org/wp-content/uploads/2022/06/Untitled-design-12-1024x1024.png 1024w, https://staging.freebsdfoundation.org/wp-content/uploads/2022/06/Untitled-design-12-300x300.png 300w, https://staging.freebsdfoundation.org/wp-content/uploads/2022/06/Untitled-design-12-150x150.png 150w, https://staging.freebsdfoundation.org/wp-content/uploads/2022/06/Untitled-design-12.png 1080w" sizes="(max-width: 431px) 100vw, 431px" /></figure>
<p></section></div>
<section class="block block-core-paragraph"></p>
<p>Whether for music, communication, or notifications, audio is an important feature of many personal computer systems. In a new FreeBSD system, an audio card will need to be configured to process audio files and send them to the connected speakers.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Fortunately, setting up audio on FreeBSD is simple and straightforward. This guide will walk through setting up and configuring audio, connecting a pair of headphones (including pairing Bluetooth models), and testing the system&#8217;s sound, all in under 10 minutes!</p>
<p></section>
<section class="block block-core-spacer"></p>
<div class="wp-block-spacer" aria-hidden="true"> </div>
<p></section>
<section class="block block-core-heading"></p>
<h2 class="wp-block-heading" id="sound-setup">1. Setting Up the Sound Card</h2>
<p></section>
<section class="block block-core-separator"></p>
<hr class="wp-block-separator has-css-opacity" />
<p></section>
<section class="block block-core-paragraph"></p>
<p>FreeBSD supports a wide variety of sound cards, these are listed in the <a href="https://www.freebsd.org/releases/">Hardware Compatability List</a> for each FreeBSD release. The Hardware Notes will list supported audio devices and which FreeBSD driver it uses. Start by identifying which driver will be needed for your specific audio device.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>The device driver will need to be loaded to use the sound card, this can be easily done with <a href="https://www.freebsd.org/cgi/man.cgi?query=kldload&amp;sektion=8&amp;format=html">kldload(8)</a>. To load the intel-specific driver, for example:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># kldload snd_hda</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>The driver can be automatically loaded on boot by configuring <code>/boot/loader.conf</code>. Available sound modules are listed in the <code><a href="https://www.freebsd.org/cgi/man.cgi?query=sound&amp;apropos=0&amp;sektion=0&amp;manpath=FreeBSD+13.1-RELEASE+and+Ports&amp;arch=default&amp;format=html" target="_blank" rel="noreferrer noopener">sound(1)</a></code> manual page, these can be viewed by using:</p>
<p></section>
<section class="block block-core-preformatted"></p>
<pre class="wp-block-preformatted"><code> # </code>man -k snd</pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Once the sound module has been checked, add a line to <code>/boot/loader.conf</code> to automatically load the driver. The line for the previous Intel driver would be:</p>
<p></section>
<section class="block block-core-preformatted"></p>
<pre class="wp-block-preformatted">snd_hda_load="YES"</pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>To simplify identifying and loading a driver, the <code>snd_driver</code> module, a meta driver that loads all of the common sound drivers, can also be loaded:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code>snd_driver_load="YES"</code></pre>
<p></section>
<section class="block block-core-spacer"></p>
<div class="wp-block-spacer" aria-hidden="true"> </div>
<p></section>
<section class="block block-core-heading"></p>
<h2 class="wp-block-heading" id="bluetooth-headset">2. Setting up Bluetooth</h2>
<p></section>
<section class="block block-core-paragraph"></p>
<p>If the audio output require a Bluetooth connection, further configurations will have to be made to ensure Bluetooth support is loaded and configured. This section can be skipped if Bluetooth is not needed.</p>
<p></section>
<section class="block block-core-separator"></p>
<hr class="wp-block-separator has-css-opacity" />
<p></section>
<section class="block block-core-heading"></p>
<h3 class="wp-block-heading" id="_loading_bluetooth_support">2.1 Loading Bluetooth Support</h3>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Before attaching a Bluetooth device, determine which Bluetooth driver it uses. A broad variety of Bluetooth USB dongles are supported by <a href="https://www.freebsd.org/cgi/man.cgi?query=ng_ubt&amp;sektion=4&amp;format=html">ng_ubt(4)</a>. Broadcom BCM2033 based Bluetooth devices are supported by the <a href="https://www.freebsd.org/cgi/man.cgi?query=ubtbcmfw&amp;sektion=4&amp;format=html">ubtbcmfw(4)</a> and <a href="https://www.freebsd.org/cgi/man.cgi?query=ng_ubt&amp;sektion=4&amp;format=html">ng_ubt(4)</a> drivers. Serial and UART based Bluetooth devices are supported by <a href="https://www.freebsd.org/cgi/man.cgi?query=ng_h4&amp;sektion=4&amp;format=html">ng_h4(4)</a> and <a href="https://www.freebsd.org/cgi/man.cgi?query=hcseriald&amp;sektion=8&amp;format=html">hcseriald(8)</a>. For example, if the device uses the <a href="https://www.freebsd.org/cgi/man.cgi?query=ng_ubt&amp;sektion=4&amp;format=html">ng_ubt(4)</a> driver:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># kldload ng_ubt</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>If the Bluetooth device will be attached to the system during system startup, the system can be configured to load the module at boot by adding the driver to <code>/boot/loader.conf</code>:</p>
<p></section>
<section class="block block-core-preformatted"></p>
<pre class="wp-block-preformatted">ng_ubt_load="YES"</pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Once the driver is loaded, connect the Bluetooth device. If the driver load was successful, output similar to the following should appear on the console and in <code>/var/log/messages</code>:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code>ubt0: vendor 0x0a12 product 0x0001, rev 1.10/5.25, addr 2
ubt0: Interface 0 endpoints: interrupt=0x81, bulk-in=0x82, bulk-out=0x2
ubt0: Interface 1 (alt.config 5) endpoints: isoc-in=0x83, isoc-out=0x3,
      wMaxPacketSize=49, nframes=6, buffer size=294</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>To start and stop Bluetooth, use the driver&#8217;s startup script:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># service bluetooth start ubt0</code></pre>
<p></section>
<section class="block block-core-heading"></p>
<h3 class="wp-block-heading" id="_finding_other_bluetooth_devices">2.2 Finding Other Bluetooth Devices</h3>
<p></section>
<section class="block block-core-paragraph"></p>
<p>FreeBSD uses <a href="https://www.freebsd.org/cgi/man.cgi?query=hccontrol&amp;sektion=8&amp;format=html" target="_blank" rel="noreferrer noopener">hccontrol(8)</a> to find and identify Bluetooth devices within RF proximity.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>One of the most common tasks is discovery of Bluetooth devices within RF proximity. This operation is called <em>inquiry</em>. Inquiry and other HCI related operations are done using <a href="https://www.freebsd.org/cgi/man.cgi?query=hccontrol&amp;sektion=8&amp;format=html">hccontrol(8)</a>. To display a list of devices that are in range use:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code>% hccontrol -n ubt0hci inquiry
Inquiry result, num_responses=1
Inquiry result #0
       <span class="has-inline-color has-luminous-vivid-orange-color"><strong>BD_ADDR</strong></span>: 00:80:37:29:19:a4
       Page Scan Rep. Mode: 0x1
       Page Scan Period Mode: 00
       Page Scan Mode: 00
       Class: 52:02:04
       Clock offset: 0x78ef
Inquiry complete. Status: No error [00]</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p><strong>Note</strong>: only devices that are set to discoverable mode will be listed<em>.</em></p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>The <span class="has-inline-color has-luminous-vivid-orange-color"><strong><code>BD_ADDR</code> </strong></span>is the unique address of a Bluetooth device, similar to the MAC address of a network card. This address is needed for further communication with a device. To to obtain the human readable name that was assigned to the remote device:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code>% hccontrol -n ubt0hci remote_name_request 00:80:37:29:19:a4
BD_ADDR: 00:80:37:29:19:a4
Name: Example Bluetooth</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>The Bluetooth system provides a point-to-point connection between two Bluetooth units, or a point-to-multipoint connection which is shared among several Bluetooth devices. The following example shows how to create a connection to a remote device:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code>% hccontrol -n ubt0hci create_connection BT_ADDR</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p><code>create_connection</code> accepts <code>BT_ADDR</code> as well as host aliases in <code>/etc/bluetooth/hosts</code>.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>The following example shows how to obtain the list of active baseband connections for the local device:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code>% hccontrol -n ubt0hci read_connection_list
Remote BD_ADDR    Handle Type Mode Role Encrypt Pending Queue State
00:80:37:29:19:a4     41  ACL    0 MAST    NONE       0     0 OPEN</code></pre>
<p></section>
<section class="block block-core-spacer"></p>
<div class="wp-block-spacer" aria-hidden="true"> </div>
<p></section>
<section class="block block-core-heading"></p>
<h3 class="wp-block-heading" id="troubleshooting">3. Graphics Card Sound Driver</h3>
<p></section>
<section class="block block-core-separator"></p>
<hr class="wp-block-separator has-css-opacity" />
<p></section>
<section class="block block-core-paragraph"></p>
<p>Modern graphics cards often come with their own sound driver, which may be used as the default device. To confirm, run dmesg and look for the <code>pcm</code> entries:</p>
<p></section>
<section class="block block-core-preformatted"></p>
<pre class="wp-block-preformatted">...
pcm0: &lt;HDA NVidia (Unknown) PCM #0 DisplayPort&gt; at cad 0 nid 1 on hdac0
pcm1: &lt;HDA NVidia (Unknown) PCM #0 DisplayPort&gt; at cad 1 nid 1 on hdac0
pcm2: &lt;HDA NVidia (Unknown) PCM #0 DisplayPort&gt; at cad 2 nid 1 on hdac0
pcm3: &lt;HDA NVidia (Unknown) PCM #0 DisplayPort&gt; at cad 3 nid 1 on hdac0
hdac1: HDA Codec #2: Realtek ALC889
pcm4: &lt;HDA Realtek ALC889 PCM #0 Analog&gt; at cad 2 nid 1 on hdac1
pcm5: &lt;HDA Realtek ALC889 PCM #1 Analog&gt; at cad 2 nid 1 on hdac1
pcm6: &lt;HDA Realtek ALC889 PCM #2 Digital&gt; at cad 2 nid 1 on hdac1
pcm7: &lt;HDA Realtek ALC889 PCM #3 Digital&gt; at cad 2 nid 1 on hdac1
...</pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>In this example, the graphics card (<code>NVidia</code>) has been enumerated before the sound card (<code>Realtek</code>). This can be changed to use the sound card as the default device with:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># sysctl hw.snd.default_unit=n</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>where <code>n</code> is the number of the sound device to prioritize. In this example, it should be <code>4</code>. Make this change permanent by adding the following line to <code>/etc/sysctl.conf</code>:</p>
<p></section>
<section class="block block-core-preformatted"></p>
<pre class="wp-block-preformatted">hw.snd.default_unit=4</pre>
<p></section>
<section class="block block-core-spacer"></p>
<div class="wp-block-spacer" aria-hidden="true"> </div>
<p></section>
<section class="block block-core-heading"></p>
<h3 class="wp-block-heading">4. Automatically Switching to Headphones</h3>
<p></section>
<section class="block block-core-separator"></p>
<hr class="wp-block-separator has-css-opacity" />
<p></section>
<section class="block block-core-paragraph"></p>
<p>Some systems may struggle with switching between audio outputs, fortunately FreeBSD allows for these to be specified in <code>device.hints</code>, which can be configured for automatic switchover. To start, identify how your system is enumerating the outputs with:</p>
<p></section>
<section class="block block-core-preformatted"></p>
<pre class="wp-block-preformatted"><code># dmesg | grep pcm </code> <code></code><code>pcm0: &lt;Realtek ALC892 Analog&gt; at nid 23 and <span class="has-inline-color has-vivid-purple-color">26</span> on hdaa<span class="has-inline-color has-luminous-vivid-amber-color">0</span> </code> <code>pcm1: &lt;Realtek ALC892 Right Analog Headphones&gt; at nid <span class="has-inline-color has-pale-pink-color">22</span> on hdaa<span class="has-inline-color has-vivid-green-cyan-color">0</span> ...</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Add the following line to <code>/boot/device.hints</code> <strong>using the highlighted values from your own system</strong>. These will likely be different than the example. In this example, colored text has been used to identify where in the original string the values originated.</p>
<p></section>
<section class="block block-core-preformatted"></p>
<pre class="wp-block-preformatted"><code>hint.hdac.<span class="has-inline-color has-luminous-vivid-amber-color">0</span>.cad0.nid<span class="has-inline-color has-pale-pink-color">22</span>.config="as=1 seq=15 device=Headphones" 
hint.hdac.<span class="has-inline-color has-vivid-green-cyan-color">0</span>.cad0.nid<span class="has-inline-color has-vivid-purple-color">26</span>.config="as=2 seq=0 device=speakers</code>"</pre>
<p></section>
<section class="block block-core-spacer"></p>
<div class="wp-block-spacer" aria-hidden="true"> </div>
<p></section>
<section class="block block-core-heading"></p>
<h3 class="wp-block-heading" id="sound-testing">5. Testing Sound</h3>
<p></section>
<section class="block block-core-separator"></p>
<hr class="wp-block-separator has-css-opacity" />
<p></section>
<section class="block block-core-paragraph"></p>
<p>To confirm that the sound card has been detected and properly configured, run <code>dmesg | grep pcm</code>. This example is from a system with a built-in Conexant chipset:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code>pcm0: &lt;NVIDIA (0x001c) (HDMI/DP 8ch)&gt; at nid 5 on hdaa0
pcm1: &lt;NVIDIA (0x001c) (HDMI/DP 8ch)&gt; at nid 6 on hdaa0
pcm2: &lt;Conexant CX20590 (Analog 2.0+HP/2.0)&gt; at nid 31,25 and 35,27 on hdaa1</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>The status of the sound card may also be checked using this command:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># cat /dev/sndstat
FreeBSD Audio Driver (newpcm: 64bit 2009061500/amd64)
Installed devices:
pcm0: &lt;NVIDIA (0x001c) (HDMI/DP 8ch)&gt; (play)
pcm1: &lt;NVIDIA (0x001c) (HDMI/DP 8ch)&gt; (play)
pcm2: &lt;Conexant CX20590 (Analog 2.0+HP/2.0)&gt; (play/rec) default</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>The output depends on which sound card has been detected, so the result may look different. However, if no pcm devices are listed, check if the correct driver was loaded in the first step.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Another quick way to test the card is to send data to <code>/dev/dsp</code>:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code>% cat filename &gt; /dev/dsp</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Any file can be used for this and will produce noise through the connected audio device.</p>
<p></section><section class="block block-classic-editor"></p></section><p>The post <a href="https://staging.freebsdfoundation.org/resource/audio-on-freebsd-quick-guide/">Audio on FreeBSD – Quick Guide</a> first appeared on <a href="https://staging.freebsdfoundation.org">FreeBSD Foundation</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Printing on FreeBSD – Quick Guide</title>
		<link>https://staging.freebsdfoundation.org/resource/printing-on-freebsd-quick-guide/</link>
		
		<dc:creator><![CDATA[Anne Dickison]]></dc:creator>
		<pubDate>Mon, 15 Aug 2022 15:00:34 +0000</pubDate>
				<guid isPermaLink="false">https://freebsdfoundation.org/?post_type=resource&#038;p=11532</guid>

					<description><![CDATA[<p>A quick guide to getting a printer set-up on FreeBSD as well as more advanced printer systems and filters.</p>
<p>The post <a href="https://staging.freebsdfoundation.org/resource/printing-on-freebsd-quick-guide/">Printing on FreeBSD – Quick Guide</a> first appeared on <a href="https://staging.freebsdfoundation.org">FreeBSD Foundation</a>.</p>]]></description>
										<content:encoded><![CDATA[<section class="block block-classic-editor"><p></section><section class="block block-core-heading"></p>
<h2 class="wp-block-heading" id="printing-quick-start">Identify Connection</h2>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Printers capable of printing plain <code>ASCII</code> text can be quickly set up on FreeBSD.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Before starting, identify the type of connection your printer is using:</p>
<p></section>
<section class="block block-core-heading"></p>
<h6 class="wp-block-heading">USB</h6>
<p></section>
<section class="block block-core-group"></p>
<div class="wp-block-group"><div class="wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow"><section class="block block-core-quote">
<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>When FreeBSD detects a <code>USB</code> printer, two device entries are created:<code> /dev/ulpt0</code> and <code>/dev/unlpt0</code>. Data sent to either device will be relayed to the printer. <code>unlpt0</code> is most commonly used as it does not reset the USB port at all, which can cause problems with some printers.</p>
</blockquote>
</section>
<section class="block block-core-heading">
<h6 class="wp-block-heading">Parallel</h6>
</section>
<section class="block block-core-quote">
<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>The parallel port device is <code>/dev/lpt0</code>. This device appears whether a printer is attached or not, it is not autodetected.</p>
<p>Vendors have largely moved away from these &#8220;legacy&#8221; ports, and many computers no longer have them. Adapters can be used to connect a parallel printer to a <code>USB</code> port. With such an adapter, the printer can be treated as if it were actually a <code>USB</code> printer.</p>
</blockquote>
</section>
<section class="block block-core-heading">
<h6 class="wp-block-heading">Network</h6>
</section>
<section class="block block-core-quote">
<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>Network printers are connected directly to the local computer network.</p>
<p>The <code>DNS</code> hostname of the printer must be known. If the printer is assigned a dynamic address by <code>DHCP</code>, <code>DNS</code> should be dynamically updated so that the host name always has the correct <code>IP</code> address. Network printers are often given static <code>IP</code> addresses to avoid this problem.</p>
<p>Most network printers understand print jobs sent with the LPD protocol. A print queue name can also be specified. Some printers process data differently depending on which queue is used. For example, a <code>raw </code>queue prints the data unchanged, while the <code>text</code> queue adds carriage returns to plain text.</p>
<p>Many network printers can also print data sent directly to port 9100.</p>
</blockquote>
</section>
<section class="block block-core-spacer">
<div class="wp-block-spacer" aria-hidden="true"> </div>
</section>
<section class="block block-core-heading">
<h2 class="wp-block-heading">Basic Setup</h2>
</section></div></div>
<p></section>
<section class="block block-core-paragraph"></p>
<p>FreeBSD uses<code> <a href="https://www.freebsd.org/cgi/man.cgi?query=lpd&amp;sektion=8&amp;format=html" target="_blank" rel="noreferrer noopener">lpd(8)</a></code> (Line Printer Daemon) to print in the background so the user can continue to use other programs. Start by creating a directory to store files while they are being printed:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># mkdir -p /var/spool/lpd/lp 
# chown daemon:daemon /var/spool/lpd/lp 
# chmod 770 /var/spool/lpd/lp</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>As <code>root</code>, create <code>/etc/printcap</code> with these contents:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code>lp:\
      <span class="has-inline-color has-vivid-red-color">:lp=/dev/unlpt0:\</span>
      :sh:\
      :mx#0:\
      :sd=/var/spool/lpd/lp:\
      :lf=/var/log/lpd-errs:</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p><mark class="has-inline-color has-vivid-red-color">**<em>This line is for a printer connected to a <code>USB</code> port</em>.</mark></p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>For a printer connected to a parallel or &#8220;printer&#8221; port, use:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code>:lp=/dev/lpt0:\</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>For a printer connected directly to a network, use:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code>:lp=:rm=<span class="has-inline-color has-vivid-red-color">network-printer-name</span>:rp=raw:\</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p><em>Replace <span class="has-inline-color has-vivid-red-color">network-printer-name</span> with the <code>DNS</code> host name of the network printer.</em></p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>To check for errors, run:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># chkprintcap</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Enable LPD by editing <code>/etc/rc.conf</code>, adding this line:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code>lpd_enable="YES"</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Start the service:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># service lpd start Starting lpd.</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Print a test:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># printf "1. This printer can print.\n2. This is the second line.\n" | lpr</code></pre>
<p></section>
<section class="block block-core-spacer"></p>
<div class="wp-block-spacer" aria-hidden="true"> </div>
<p></section>
<section class="block block-core-heading"></p>
<h2 class="wp-block-heading" id="printing-direct">Direct Printing</h2>
<p></section>
<section class="block block-core-paragraph"></p>
<p>For occasional printing, files can be sent directly to a printer device without any setup. For example, a file called <code>sample.txt</code> can be sent to a <code>USB</code> printer:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># cp sample.txt /dev/unlpt0</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Direct printing to network printers depends on the abilities of the printer, but most accept print jobs on port 9100, and <a href="https://www.freebsd.org/cgi/man.cgi?query=nc&amp;sektion=1&amp;format=html">nc(1)</a> can be used with them. To print the same file to a printer with the <code>DNS</code> hostname of <em>netlaser</em>:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># nc netlaser 9100 &lt; sample.txt</code></pre>
<p></section>
<section class="block block-core-spacer"></p>
<div class="wp-block-spacer" aria-hidden="true"> </div>
<p></section>
<section class="block block-core-heading"></p>
<h2 class="wp-block-heading" id="printing-lpd-filters">Filters</h2>
<p></section>
<section class="block block-core-paragraph"></p>
<p>The examples shown so far have sent the contents of a text file directly to the printer. As long as the printer understands the content of those files, output will be printed correctly.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Some printers are not capable of printing plain text, and the input file might not even be plain text.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Filters are specified in<code> /etc/printcap</code> with the <code>if=</code> identifier. To use <code>/usr/local/libexec/lf2crlf</code> as a filter, modify<code> /etc/printcap</code> like this:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code>lp:\
	:lp=/dev/unlpt0:\
	:sh:\
	:mx#0:\
	:sd=/var/spool/lpd/lp:\
	:if=/usr/local/libexec/lf2crlf:\   
	:lf=/var/log/lpd-errs:</code></pre>
<p></section>
<section class="block block-core-table"></p>
<figure class="wp-block-table">
<table>
<tbody>
<tr>
<td>&nbsp;</td>
<td><code>if=</code> identifies the <em>input filter</em> that will be used on incoming text.</td>
</tr>
</tbody>
</table>
</figure>
<p></section>
<section class="block block-core-spacer"></p>
<div class="wp-block-spacer" aria-hidden="true"> </div>
<p></section>
<section class="block block-core-heading"></p>
<h2 class="wp-block-heading" id="printing-lpd-filters-stairstep">An Example Filter</h2>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Typical FreeBSD text files contain only a single line feed character at the end of each line. These lines will &#8220;stairstep&#8221; on a standard printer:</p>
<p></section>
<section class="block block-core-preformatted"></p>
<pre class="wp-block-preformatted">A printed file looks
                    like the steps of a staircase
                                                 scattered by the wind</pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>A filter can convert the newline characters into carriage returns and newlines. The carriage returns make the printer return to the left after each line. Create<code> /usr/local/libexec/lf2crlf</code> with these contents:</p>
<p></section>
<section class="block block-core-preformatted"></p>
<pre class="wp-block-preformatted">#!/bin/sh
CR=$'\r'
/usr/bin/sed -e "s/$/${CR}/g"</pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Set the permissions and make it executable:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># chmod 555 /usr/local/libexec/lf2crlf</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Modify <code>/etc/printcap</code> to use the new filter:</p>
<p></section>
<section class="block block-core-preformatted"></p>
<pre class="wp-block-preformatted">:if=/usr/local/libexec/lf2crlf:\</pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Test the filter by printing the same plain text file. The carriage returns will cause each line to start at the left side of the page.</p>
<p></section>
<section class="block block-core-spacer"></p>
<div class="wp-block-spacer" aria-hidden="true"> </div>
<p></section>
<section class="block block-core-heading"></p>
<h2 class="wp-block-heading" id="printing-other">Other Printing Systems</h2>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Several other printing systems are available in addition to the built-in <a href="https://www.freebsd.org/cgi/man.cgi?query=lpd&amp;sektion=8&amp;format=html">lpd(8)</a>. These systems offer support for other protocols or additional features.</p>
<p></section>
<section class="block block-core-heading"></p>
<h3 class="wp-block-heading" id="printing-other-cups">CUPS</h3>
<p></section>
<section class="block block-core-paragraph"></p>
<p>CUPS is a popular printing system available on many operating systems. Using CUPS on FreeBSD is documented in a separate article: <a href="https://docs.freebsd.org/en/articles/cups/">CUPS</a></p>
<p></section>
<section class="block block-core-heading"></p>
<h3 class="wp-block-heading" id="printing-other-hplip">HPLIP</h3>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Hewlett Packard provides a printing system that supports many of their inkjet and laser printers. The port is <a href="https://www.freebsd.org/cgi/url.cgi?ports/print/hplip/pkg-descr">print/hplip</a>. The main web page is at <a href="https://developers.hp.com/hp-linux-imaging-and-printing">https://developers.hp.com/hp-linux-imaging-and-printing</a>. The port handles all the installation details on FreeBSD. Configuration information is shown at <a href="https://developers.hp.com/hp-linux-imaging-and-printing/install">https://developers.hp.com/hp-linux-imaging-and-printing/install</a>.</p>
<p></section>
<section class="block block-core-heading"></p>
<h3 class="wp-block-heading" id="printing-other-lprng">LPRng</h3>
<p></section>
<section class="block block-core-paragraph"></p>
<p>LPRng was developed as an enhanced alternative to <a href="https://www.freebsd.org/cgi/man.cgi?query=lpd&amp;sektion=8&amp;format=html">lpd(8)</a>. The port is <a href="https://www.freebsd.org/cgi/url.cgi?ports/sysutils/LPRng/pkg-descr">sysutils/LPRng</a>. For details and documentation, see <a href="http://www.lprng.com/">http://www.lprng.com/</a>.</p>
<p></section><section class="block block-classic-editor"></p></section><p>The post <a href="https://staging.freebsdfoundation.org/resource/printing-on-freebsd-quick-guide/">Printing on FreeBSD – Quick Guide</a> first appeared on <a href="https://staging.freebsdfoundation.org">FreeBSD Foundation</a>.</p>]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
