<?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>Getting Started | FreeBSD Foundation</title>
	<atom:link href="https://staging.freebsdfoundation.org/topic/getting-started/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>Tue, 30 Jul 2024 19:40:13 +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>Getting Started | FreeBSD Foundation</title>
	<link>https://staging.freebsdfoundation.org</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to Install FreeBSD on VMware</title>
		<link>https://staging.freebsdfoundation.org/resource/how-to-install-freebsd-on-vmware/</link>
		
		<dc:creator><![CDATA[Anne Dickison]]></dc:creator>
		<pubDate>Mon, 22 Jul 2024 17:12:26 +0000</pubDate>
				<guid isPermaLink="false">https://freebsdfoundation.org/?post_type=resource&#038;p=16056</guid>

					<description><![CDATA[<p> 1. Installing VMware Fusion: VMware’s desktop products, recently made available by Broadcom as a free download for personal use, run on a wide range of systems; VMware Fusion is designed for Mac systems and can run on M-Series Apple Silicon systems, whereas VMware Workstation is a similar hypervisor that runs on Windows and Linux. Users [&#8230;]</p>
<p>The post <a href="https://staging.freebsdfoundation.org/resource/how-to-install-freebsd-on-vmware/">How to Install FreeBSD on VMware</a> first appeared on <a href="https://staging.freebsdfoundation.org">FreeBSD Foundation</a>.</p>]]></description>
										<content:encoded><![CDATA[<section class="block block-classic-editor">
<h2><b> 1. Installing VMware Fusion:</b></h2>
<p><span style="font-weight: 400;">VMware’s desktop products, recently made available by Broadcom </span><a href="https://blogs.vmware.com/teamfusion/2024/05/fusion-pro-now-available-free-for-personal-use.html"><span style="font-weight: 400;">as a free download for personal use</span></a><span style="font-weight: 400;">, run on a wide range of systems; VMware Fusion is designed for Mac systems and can run on M-Series Apple Silicon systems, whereas VMware Workstation is a similar hypervisor that runs on Windows and Linux.</span></p>
<p><img fetchpriority="high" decoding="async" class=" wp-image-16057 aligncenter" src="https://staging.freebsdfoundation.org/wp-content/uploads/2024/07/unnamed-1.png" alt="" width="632" height="216" srcset="https://staging.freebsdfoundation.org/wp-content/uploads/2024/07/unnamed-1.png 512w, https://staging.freebsdfoundation.org/wp-content/uploads/2024/07/unnamed-1-300x103.png 300w" sizes="(max-width: 632px) 100vw, 632px" /></p>
<p><span style="font-weight: 400;">Users must first register on the Broadcom support portal to install VMware Fusion or VMware Workstation. This signup process includes being included in Broadcom&#8217;s marketing lists, and free access to the hypervisors is granted for personal use.</span></p>
<p><span style="font-weight: 400;">Once registered, </span><a href="https://www.vmware.com/products/desktop-hypervisor.html"><span style="font-weight: 400;">follow the install links on VMware’s website</span></a><span style="font-weight: 400;">, log in using your Broadcom sign-in, and install the correct hypervisor for your system. </span></p>
<p>&nbsp;</p>
<h2><b>2. Getting the latest FreeBSD release:</b></h2>
<p><span style="font-weight: 400;">Visit the official </span><a href="https://www.freebsd.org/where.html"><b>FreeBSD releases page</b></a><span style="font-weight: 400;">. The disk images are listed </span><i><span style="font-weight: 400;">in order of release date</span></i><span style="font-weight: 400;">, so the most recent release can be found at the top of the page as highlighted.</span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Newer m1/m2 Apple chips will require aarch64 images</span></li>
</ul>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">64-bit Windows machines will require amd64 images</span></li>
</ul>
<p><img decoding="async" class=" wp-image-16059 aligncenter" src="https://staging.freebsdfoundation.org/wp-content/uploads/2024/07/unnamed-3.png" alt="" width="619" height="202" srcset="https://staging.freebsdfoundation.org/wp-content/uploads/2024/07/unnamed-3.png 512w, https://staging.freebsdfoundation.org/wp-content/uploads/2024/07/unnamed-3-300x98.png 300w" sizes="(max-width: 619px) 100vw, 619px" /> </p>
<p><span style="font-weight: 400;">After clicking the link, you will be redirected to a file directory containing multiple formats and versions of the FreeBSD installer.</span></p>
<h4><b>Identifying the Correct Disk Image</b></h4>
<p><img decoding="async" class=" wp-image-16058 aligncenter" src="https://staging.freebsdfoundation.org/wp-content/uploads/2024/07/unnamed-2.png" alt="" width="599" height="193" srcset="https://staging.freebsdfoundation.org/wp-content/uploads/2024/07/unnamed-2.png 512w, https://staging.freebsdfoundation.org/wp-content/uploads/2024/07/unnamed-2-300x97.png 300w" sizes="(max-width: 599px) 100vw, 599px" /></p>
<p><span style="font-weight: 400;">For VMware, the correct format will be the image ending in <code>-disc.iso</code>, as shown above. Click this file and start downloading the image</span></p>
<p>&nbsp;</p>
<h2><b>3. Creating a FreeBSD Virtual Machine:</b></h2>
<h3><b>3.1 VMware Fusion (Mac):</b></h3>
<p><span style="font-weight: 400;">In VMware Fusion, click the ‘+’ symbol in the top left or center of the client, then click ‘New’ to create a new virtual machine. On Mac, choose ‘Create a custom virtual machine,’ select ‘Other’ as the Operating System, and ‘FreeBSD 14 64-bit’ as the firmware.</span></p>
<p><img loading="lazy" decoding="async" class=" wp-image-16060 aligncenter" src="https://staging.freebsdfoundation.org/wp-content/uploads/2024/07/unnamed-5.png" alt="" width="552" height="166" srcset="https://staging.freebsdfoundation.org/wp-content/uploads/2024/07/unnamed-5.png 512w, https://staging.freebsdfoundation.org/wp-content/uploads/2024/07/unnamed-5-300x90.png 300w" sizes="(max-width: 552px) 100vw, 552px" /></p>
<p><span style="font-weight: 400;">Select ‘Create a new virtual disk’ and ‘Continue.’ Then, finish and save the VM using your own naming convention.</span></p>
<p><span style="font-weight: 400;">Before booting, the new virtual machine must be given a CD drive to boot from, or it will fail to boot. Open it to see this message, and do not suspend it; it must be running to attach a drive.</span></p>
<p><span style="font-weight: 400;">Press command+E to open virtual machine settings and click CD/DVD. Choose the FreeBSD ISO image, the “<code>FreeBSD … disc1.iso</code>” image downloaded earlier. Then, check the box to connect a CD/DVD drive.</span></p>
<p><span style="font-weight: 400;">Right-click “virtual machine” in the top menu, and select “restart.”</span></p>
<h3><b>3.2 VMware Workstation (Windows/Linux:</b></h3>
<p><span style="font-weight: 400;">In the center of the client, click ‘Create a New Virtual Machine’ and choose the ‘Typical’ virtual machine option. </span><span style="font-weight: 400;">Choose the FreeBSD ISO image, the “<code>FreeBSD … disc1.iso</code>” image downloaded earlier.</span></p>
<p><img loading="lazy" decoding="async" class=" wp-image-16062 aligncenter" src="https://staging.freebsdfoundation.org/wp-content/uploads/2024/07/unnamed-7.png" alt="" width="332" height="331" srcset="https://staging.freebsdfoundation.org/wp-content/uploads/2024/07/unnamed-7.png 424w, https://staging.freebsdfoundation.org/wp-content/uploads/2024/07/unnamed-7-300x300.png 300w, https://staging.freebsdfoundation.org/wp-content/uploads/2024/07/unnamed-7-150x150.png 150w" sizes="(max-width: 332px) 100vw, 332px" /></p>
<p><span style="font-weight: 400;">Name the virtual machine using your own naming convention, and ‘Finish’ to create the VM. </span></p>
<p>&nbsp;</p>
<h2><b>4. Booting into FreeBSD:</b></h2>
<p><span style="font-weight: 400;">The FreeBSD booting system will automatically start once VirtualBox starts the virtual machine. Follow the </span><a href="https://www.freebsd.org/doc/handbook/using-bsdinstall.html"><b>FreeBSD Handbook’s installation guide</b></a><span style="font-weight: 400;"> to configure and set up your system. </span><span style="font-weight: 400;">When in doubt, use the default options provided</span><span style="font-weight: 400;">, which can be reconfigured later.</span></p>
<p><span style="font-weight: 400;">Once installation is complete, use the FreeBSD Handbook’s </span><a href="https://www.freebsd.org/doc/handbook/bsdinstall-post.html"><b>post-installation guide.</b></a></p>
<p><img loading="lazy" decoding="async" class="wp-image-16063 aligncenter" src="https://staging.freebsdfoundation.org/wp-content/uploads/2024/07/unnamed-8.png" alt="" width="564" height="339" srcset="https://staging.freebsdfoundation.org/wp-content/uploads/2024/07/unnamed-8.png 512w, https://staging.freebsdfoundation.org/wp-content/uploads/2024/07/unnamed-8-300x180.png 300w" sizes="(max-width: 564px) 100vw, 564px" /></p>
<p>&nbsp;</p>
<h2><b>5. Finishing Up:</b></h2>
<p><span style="font-weight: 400;">On a bare-metal system, you would now be able to boot directly into FreeBSD with no further configuration. However, since we’re using a virtual machine, a few more steps are required.</span></p>
<p><span style="font-weight: 400;">Open settings. Click on CD/DVD, and then Un-check the box that says “connect CD/DVD Drive&#8221; or “connect on boot”. Exit out of this screen. </span><span style="font-weight: 400;"><br />
</span><span style="font-weight: 400;"><br />
</span><span style="font-weight: 400;">Next, click on Processors and Memory and select more RAM and cores. The default options are quite low for a dedicated virtual machine.</span></p>
<p><span style="font-weight: 400;">Use the Start button to boot the virtual machine, and log in to the root user (or use ‘<code>su</code>’ if the guest user was given admin control)</span><span style="font-weight: 400;"><br />
</span><span style="font-weight: 400;"><br />
</span><span style="font-weight: 400;">To ensure full VMware support, install the <code>open-vm-tools</code> package with:</span></p>
<p><code><span style="font-weight: 400;">pkg install -y open-vm-tools</span></code></p>
<p><span style="font-weight: 400;">If this is the first time<code> pkg</code> has been run, respond to the prompt with y to bootstrap <code>pkg</code>. The <code>open-vm-tools</code> package contains the core user space utilities, application programs, and libraries, including vmtoolsd, to help effectively manage communication between your host and guest OSs.</span></p>
<p>&nbsp;</p>
</section><p>The post <a href="https://staging.freebsdfoundation.org/resource/how-to-install-freebsd-on-vmware/">How to Install FreeBSD on VMware</a> first appeared on <a href="https://staging.freebsdfoundation.org">FreeBSD Foundation</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>An Introduction to Packet Filter (PF)</title>
		<link>https://staging.freebsdfoundation.org/resource/an-introduction-to-packet-filter-pf/</link>
		
		<dc:creator><![CDATA[Anne Dickison]]></dc:creator>
		<pubDate>Tue, 12 Sep 2023 19:35:40 +0000</pubDate>
				<guid isPermaLink="false">https://freebsdfoundation.org/?post_type=resource&#038;p=12822</guid>

					<description><![CDATA[<p>Packet Filter, also known as PF or pf, is a BSD-licensed stateful packet filter used to filter TCP/IP traffic and perform Network Address Translation (NAT.) Originally created by OpenBSD, PF has been ported to FreeBSD since 5.3-RELEASE. PF can identify where a packet should be directed or if it should even be allowed through; this [&#8230;]</p>
<p>The post <a href="https://staging.freebsdfoundation.org/resource/an-introduction-to-packet-filter-pf/">An Introduction to Packet Filter (PF)</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>Packet Filter, also known as PF or pf, is a BSD-licensed stateful packet filter used to filter TCP/IP traffic and perform Network Address Translation (NAT.) Originally created by OpenBSD, PF has been ported to FreeBSD since 5.3-RELEASE.</p>
<p>PF can identify where a packet should be directed or if it should even be allowed through; this can be decided based on the source and destination of that individual packet. PF can detect and block traffic you want to keep out of or in the local network. The firewall is highly flexible and even offers bandwidth management and packet priority.</p>
<p><img loading="lazy" decoding="async" class="wp-image-12964  aligncenter" src="https://staging.freebsdfoundation.org/wp-content/uploads/2023/09/Untitled-design-43-1024x1024.png" alt="" width="448" height="448" srcset="https://staging.freebsdfoundation.org/wp-content/uploads/2023/09/Untitled-design-43-1024x1024.png 1024w, https://staging.freebsdfoundation.org/wp-content/uploads/2023/09/Untitled-design-43-300x300.png 300w, https://staging.freebsdfoundation.org/wp-content/uploads/2023/09/Untitled-design-43-150x150.png 150w, https://staging.freebsdfoundation.org/wp-content/uploads/2023/09/Untitled-design-43-1536x1536.png 1536w, https://staging.freebsdfoundation.org/wp-content/uploads/2023/09/Untitled-design-43-2048x2048.png 2048w" sizes="(max-width: 448px) 100vw, 448px" /></p>
<h2>1 . Enabling PF</h2>
<p>PF relies on its kernel module, this must be enabled through <code>/etc/rc.conf</code> to start PF:</p>
<p><code># sysrc pf_enable=yes<br />
</code><br />
Additional options can be enabled when PF is started, this can be done by adding the following line to <code>/etc/rc.conf.</code> Required flags can later be specified between the two quotes(&#8220;&#8221;):</p>
<p><code>pf_flags="" # additional flags for pfctl startup</code></p>
<p>To start, PF will need to find its ruleset configuration file. FreeBSD does not ship with a ruleset or /etc/pf.conf. Custom rulesets can be used by specifying the path in <code>/etc/rc.conf</code></p>
<p><code>pf_rules="/path/to/pf.conf"</code><br />
<em><br />
</em>Logging support for PF is provided by <code>pflog(4)</code>. To enable logging support, add <code>pflog_enable=yes</code> to <code>/etc/rc.conf</code>:</p>
<p><code># sysrc pflog_enable=yes</code></p>
<p>The following lines can also be added to change the default location of the log file or to specify any additional flags to pass to pflog(4) when it is started:</p>
<p><code>pflog_logfile="/var/log/pflog" # where pflogd should store the logfile</code><br />
<code>pflog_flags="" # additional flags for pflogd startup</code></p>
<p>The following option will enable NAT if there is a LAN behind the firewall:</p>
<p><code>gateway_enable="YES"</code></p>
<p>PF can now be started with logging support:</p>
<p><code># service pf start</code><br />
<code># service pflog start</code></p>
<p>&nbsp;</p>
<h2>2. Using pfctl</h2>
<p>PF can be controlled using pfctl, refer to pfctl(8) for a description of all available options. Here are some of the more common pfctl options:</p>
<table style="border-collapse: collapse; width: 100%;" border="1">
<tbody>
<tr style="height: 24px;">
<td style="width: 50%; height: 24px;"><code>pfctl -e</code></td>
<td style="width: 50%; height: 24px;">Enable PF.</td>
</tr>
<tr style="height: 24px;">
<td style="width: 50%; height: 24px;"><code>pfctl -d</code></td>
<td style="width: 50%; height: 24px;">Disable PF.</td>
</tr>
<tr style="height: 24px;">
<td style="width: 50%; height: 24px;"><code>pfctl -F all -f /etc/pf.conf</code></td>
<td style="width: 50%; height: 24px;">Flush all NAT, filter, state, and table rules and reload <code>/etc/pf.conf.</code></td>
</tr>
<tr style="height: 24px;">
<td style="width: 50%; height: 24px;"><code>pfctl -s [ rules | nat | states ]</code></td>
<td style="width: 50%; height: 24px;">Report on the filter rules, NAT rules, or state table.</td>
</tr>
<tr style="height: 23px;">
<td style="width: 50%; height: 23px;"><code>pfctl -vnf /etc/pf.conf</code></td>
<td style="width: 50%; height: 23px;">Checks <code>/etc/pf.conf</code> for errors, but does not load ruleset.</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h2>3. Creating a Base PF Ruleset</h2>
<p>PF depends on a ruleset, which can be customized to best serve any system. Creating a base ruleset is the first step in customizing your firewall that can be further augmented and specified. Create the ruleset in</p>
<p>Start by creating a simple ruleset that applies to only a single machine, relies on one network, and does not run services:</p>
<div class="literalblock programlisting">
<div class="content">
<p><code>block in all</code></p>
<p><code>pass out all keep state</code></p>
</div>
</div>
<div class="paragraph">
<p>This rule will deny all incoming traffic, while the second rule allows connections created by this system to pass out while retaining state information on those connections. Load this new ruleset with the following:</p>
</div>
<div class="listingblock">
<div class="content">
<p class="rouge highlight"><code data-lang="shell"><span class="c"># pfctl -e ; pfctl -f /etc/pf.conf</span></code></p>
</div>
</div>
<div class="paragraph">
<p>In addition to keeping state, PF provides lists and macros that can be defined when creating rules. Macros can include lists and need to be defined before use. As an example, insert these lines at the very top of the ruleset:</p>
</div>
<div class="literalblock programlisting">
<div class="content">
<p><code>tcp_services = "{ ssh, smtp, domain, www, pop3, auth, pop3s }"</code></p>
<p><code>udp_services = "{ domain }"</code></p>
</div>
</div>
<div class="paragraph">
<p>PF can use port names and numbers if the names are listed in <code><span class="filename">/etc/services</span></code>. In this example, all traffic is blocked except for the connections initiated by this system for the seven specified TCP services and the one specified UDP service:</p>
</div>
<div class="literalblock programlisting">
<pre><code>tcp_services = "{ ssh, smtp, domain, www, pop3, auth, pop3s }"
udp_services = "{ domain }"
block all</code> <code>pass out proto tcp to any port $tcp_services keep state
pass proto udp to any port $udp_services keep state</code></pre>
<p>Next, at the top of your ruleset, create a set skip rule for the loopback device because it does not need to filter traffic and would likely bring your server to a crawl. </p>
<p class="content"><code>set skip on lo0</code></p>
<p class="content">Finally, add a <code>pass out inet</code> rule for the ICMP protocol, which allows you to use the ping(8) utility for troubleshooting</p>
<p class="content"><code>pass out inet proto icmp icmp-type { echoreq }</code></p>
<p class="content">The ruleset should now resemble the following: </p>
<pre><code>set skip on lo0
tcp_services = "{ ssh, smtp, domain, www, pop3, auth, pop3s }"
udp_services = "{ domain }"
block all</code><code>
pass out proto tcp to any port $tcp_services keep state
pass proto udp to any port $udp_services keep state
pass out inet proto icmp icmp-type { echoreq }</code></pre>
</div>
<div class="paragraph">
<p>After each edit, the ruleset needs to be loaded again:</p>
</div>
<div class="listingblock">
<div class="content">
<p class="rouge highlight"><code data-lang="shell"><span class="c"># pfctl -f /etc/pf.conf</span></code></p>
</div>
</div>
<div class="paragraph">
<p><code>pfctl</code> will not output any messages unless there are syntax errors that will need to be fixed. During the rule load, instead of loading the ruleset, a test can be run with:</p>
</div>
<div class="listingblock">
<div class="content">
<p class="rouge highlight"><code data-lang="shell"><span class="c"># pfctl -nf /etc/pf.conf</span></code></p>
<div class="copy-to-clipboard-wrapper">Including <code>-n</code> causes the rules to be interpreted only but not loaded. This provides an opportunity to correct any errors. The last valid ruleset loaded will be enforced until either PF is disabled or a new ruleset is loaded.</div>
</div>
</div>
<p>&nbsp;</p>
<h2>4. Testing Your Base Ruleset</h2>
<p>Testing your ruleset between major edits is crucial to ensure that PF functions properly. </p>
<p>First test for internet connectivity and DNS service:</p>
<p><code># ping -c 3 google.com</code></p>
<p>Check that the <code>pkgs</code> repository can be reached: </p>
<p><code># pkg upgrade</code></p>
<p>And finally, reboot:</p>
<p><code># reboot</code></p>
<p>Give your server a few minutes to reboot. Next, you will expand the ruleset with more advanced features to see some possible applications of the PF ruleset.</p>
<h2>5. Example Rulesets and Their Application</h2>
<p>Now that you have created a base ruleset, the base ruleset can be built upon for more advanced PF functions. While this guide won&#8217;t cover every possible function or customization, these basic rulesets may be helpful for your system, or offer insight into how PF may be used. After each example, make sure to test the base ruleset.</p>
<h3 style="padding-left: 40px;">5.1 Blocking Spoofed Packets</h3>
<p style="padding-left: 40px;">Address spoofing is a method where an outside user forges the source IP of sent packets to conceal the actual address, essentially impersonating another internet node. This opens the door for a network attack that does not disclose where it&#8217;s originating.</p>
<p style="padding-left: 40px;">The antispoof PF keyword can help protect against spoof packets:</p>
<p style="padding-left: 40px;"><code>antispoof [log] [quick] for interface [af]</code></p>
<p style="padding-left: 40px;"><code><strong>log</strong></code>: Specifies that packets matching the criteria should be reported by pflogd (8).<br />
<code><strong>quick</strong></code>: This ensured that if a packet meets this rules, examination of the ruleset will cease.<br />
<code><strong>interface</strong></code>: Specify the specific network where spoofing protection will be activated.<br />
<code><strong>af</strong></code>: Address family (i.e., inet or inet6 for IPv4 and IPv6)</p>
<p style="padding-left: 40px;">The most basic way to weed out spoofed traffic coming in from external sources, as well as any spoofed packets that originate in the local network:</p>
<p style="padding-left: 40px;"><code>antispoof for $ext_if</code><br />
<code>antispoof for $int_if</code></p>
<p style="padding-left: 40px;"> </p>
<h3 style="padding-left: 40px;">5.2 Protecting SSH Ports</h3>
<p style="padding-left: 40px;">A typical exploit is to target SSH ports, which are open to the public. This is often done with brute force attacks and can succeed if the server has weak passwords. PF has built-in features that help deal with brute-force attacks. PF can limit the simultaneous connection attempts a single host allows. Once a host exceeds this number, the connection will be dropped, and they will be banned from the server. PF&#8217;s overload mechanism has a table of banned IP addresses.</p>
<p style="padding-left: 40px;">Modify your previous base ruleset to limit simultaneous connections from a single host:</p>
<p style="padding-left: 40px;"><code>pass in on $vtnet0 proto tcp to port { 22 } \</code></p>
<p style="padding-left: 80px;"><code>keep state (max-src-conn 15, max-src-conn-rate 3/1, \</code></p>
<p style="padding-left: 120px;"><code>overload &lt;bruteforce&gt; flush global)</code></p>
<p style="padding-left: 40px;"><code><strong>keep state</strong></code>: Allows you to define the state criteria for the overload table. <br />
<code><strong>max-src-conn</strong>:</code> Specifies the number of simultaneous connections allowed from a single host per second.<br />
<code><strong>max-src-conn-rate</strong>:</code> Specifies the number of new connections allowed from a single host per second.</p>
<p style="padding-left: 40px;">If any host exceeds the specified limits, the PF overload mechanism will add the source IP to the <code>&lt;bruteforce&gt;</code> table. If a host exceeds these limits, the overload mechanism adds the source IP to the <code>&lt;bruteforce&gt;</code> table, which bans them from the server. The connection will immediately be dropped due to the flush global parameter. </p>
<p style="padding-left: 40px;">Before this ruleset can be loaded, the table you defined needs to be declared in the ruleset: </p>
<p style="padding-left: 40px;">Specify the <code>&lt;bruteforce&gt;</code> table underneath the previous <code>icmp_types</code> macro</p>
<p style="padding-left: 40px;"><code>icmp_types = "{ echoreq }"</code></p>
<p style="padding-left: 80px;"><code>table &lt;bruteforce&gt; persist</code></p>
<p style="padding-left: 40px;">The persist keyword allows an empty table to exist in the ruleset. Without it, PF will complain that there are no IP addresses in the table.</p>
<h3 style="padding-left: 40px;">5.3 Handling Non-Routable Addresses</h3>
<p style="padding-left: 40px;">As much as you can properly configure your system to be precise, some configuration may be needed to compensate for other people&#8217;s misconfigurations. One common mistake is to let traffic with non-routable addresses out to the Internet. Since non-routable addresses can be used in DoS attacks, consider blocking this traffic from entering the network.</p>
<p style="padding-left: 40px;">Define a macro containing non-routable addresses, then use it in blocking rules. Traffic to and from these addresses is dropped on the gateway’s external interface.</p>
<p style="padding-left: 40px;">
<code>external = "{ 127.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12, \</code><br />
<code>      10.0.0.0/8, 169.254.0.0/16, 192.0.2.0/24, \</code><br />
<code>      0.0.0.0/8, 240.0.0.0/4 }"</code></p>
<p style="padding-left: 40px;"><code>block drop in quick on $ext_if from $external to any</code><br />
<code>block drop out quick on $ext_if from any to $external</code></p>
<p>
</p>
<h2>6. Viewing PF Logs</h2>
<p>To view PF logs:</p>
<p><code>tcpdump -n -e -ttt -r /var/log/pflog</code></p>
<p>To view logs in real-time from the pflog0 interface, run the following command:</p>
<p><code>tcpdump -n -e -ttt -i pflog0</code></p>
<p>The pftop utility is a tool for quickly viewing firewall activity in real-time; it can be installed and started with:</p>
<p><code>pkg install pftop</code></p>
<p><code>pftop</code></p>
</section><p>The post <a href="https://staging.freebsdfoundation.org/resource/an-introduction-to-packet-filter-pf/">An Introduction to Packet Filter (PF)</a> first appeared on <a href="https://staging.freebsdfoundation.org">FreeBSD Foundation</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>An Introduction to ZFS</title>
		<link>https://staging.freebsdfoundation.org/resource/an-introduction-to-the-z-file-system/</link>
		
		<dc:creator><![CDATA[Anne Dickison]]></dc:creator>
		<pubDate>Sun, 22 Jan 2023 15:20:05 +0000</pubDate>
				<guid isPermaLink="false">https://freebsdfoundation.org/?post_type=resource&#038;p=11875</guid>

					<description><![CDATA[<p>ZFS combines the roles of volume manager and independent file system into one, giving multiple advantages over a stand-alone file system. It is renowned for speed, flexibility, and, most importantly, taking great care to prevent data loss.</p>
<p>The post <a href="https://staging.freebsdfoundation.org/resource/an-introduction-to-the-z-file-system/">An Introduction to ZFS</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-paragraph"></p>
<p>ZFS combines the roles of volume manager and independent file system into one, giving multiple advantages over a stand-alone file system. It is renowned for speed, flexibility, and, most importantly, taking great care to prevent data loss. While many traditional file systems had to exist on a single disk at a time, ZFS is aware of the underlying structure of the disks and creates a pool of available storage, even on multiple disks. The existing file system will grow automatically when extra disks are added to the pool, immediately becoming available to the file system.</p>
<p></section>
<div class="wp-block-image"><section class="block block-core-image"></p>
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" class="wp-image-11796 aligncenter" src="https://staging.freebsdfoundation.org/wp-content/uploads/2022/10/OpenZFS_logo.svg-1024x933.png" alt="" width="215" height="196" srcset="https://staging.freebsdfoundation.org/wp-content/uploads/2022/10/OpenZFS_logo.svg-1024x933.png 1024w, https://staging.freebsdfoundation.org/wp-content/uploads/2022/10/OpenZFS_logo.svg-300x273.png 300w, https://staging.freebsdfoundation.org/wp-content/uploads/2022/10/OpenZFS_logo.svg.png 1200w" sizes="(max-width: 215px) 100vw, 215px" /></figure>
<p></section></div>
<section class="block block-core-heading"></p>
<h2 class="wp-block-heading" id="zfs-quickstart">Getting Started</h2>
<p></section>
<section class="block block-core-paragraph"></p>
<p>FreeBSD can mount ZFS pools and datasets during system initialization. To enable it, add this line to /etc/rc.conf:</p>
<p></section>
<section class="block block-core-preformatted"></p>
<pre class="wp-block-preformatted">zfs_enable="YES"</pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Then start the service:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># service zfs start</code></pre>
<p></section>
<section class="block block-core-heading"></p>
<h2 class="has-text-align-left wp-block-heading">Identify Hardware</h2>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Before setting up ZFS, identify the device names of the disk associated with the system. A quick way of doing this is with:</p>
<p></section>
<section class="block block-core-preformatted"></p>
<pre class="wp-block-preformatted"><code># egrep 'da[0-9]|cd[0-9]' /var/run/dmesg.boot</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>The output should identify the device names, examples throughout the rest of this guide will use the default SCSI names: da0, da1, and da2. If the hardware differs, make sure to use the correct device names instead.</p>
<p></section>
<section class="block block-core-heading"></p>
<h2 class="wp-block-heading" id="zfs-quickstart-single-disk-pool">Creating a Single Disk Pool</h2>
<p></section>
<section class="block block-core-paragraph"></p>
<p>To create a simple, non-redundant pool using a single disk device:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># zpool create example /dev/da0</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>To create files for users to browse within the pool:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># cd /example
# ls
# touch testfile</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>The new file can be viewed using <code>ls</code>:</p>
<p></section>
<section class="block block-core-preformatted"></p>
<pre class="wp-block-preformatted"><code># ls -al</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>We can already start using more advanced ZFS features and properties. To create a dataset within the pool with compression enabled:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># zfs create example/compressed
# zfs set compression=on example/compressed</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>The <code>example/compressed</code> dataset is now a ZFS compressed file system.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Disable compression with:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># zfs set compression=off example/compressed</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>To unmount a file system, use <code>zfs umount</code> and then verify with <code>df</code>:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># zfs umount example/compressed
# df</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Verify that <code>example/compressed</code> is not included as a mounted file under the output.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>The file system can be re-mounted with zfs:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># zfs mount example/compressed
# df</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>With the file system mounted, the output should include a line similar to the one below:</p>
<p></section>
<section class="block block-core-preformatted"></p>
<pre class="wp-block-preformatted"><code>example/compressed 17547008 0 17547008 0% /example/compressed</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>ZFS datasets are created just like any other file system, the following example creates a new file system called <code>data</code>:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># zfs create example/data</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Use <code>df</code> to see the data and space usage (some of the output has been removed for clarity)</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># df
                                 . . . 
example/compressed  17547008       0 17547008     0%    /example/compressed
example/data        17547008       0 17547008     0%    /example/data</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Because these file systems are built on ZFS, they draw from the same pool for storage. This eliminates the need for volumes and partitions that other file systems rely on.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>To destroy the file systems and then the pool that is no longer needed:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># zfs destroy example/compressed
# zfs destroy example/data
# zpool destroy example</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="zfs-quickstart-raid-z">RAID-Z</h2>
<p></section>
<section class="block block-core-paragraph"></p>
<p>RAID-Z pools require three or more disks but offer protection from data loss if a disk were to fail. Because the ZFS pools can use multiple disks, support for RAID is inherent in the design of the file system</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>To create a RAID-Z pool, specifying the disks to add to the pool:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># zpool create storage raidz da0 da1 da2</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>With the zpool created, a new file system can be made in that pool:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># zfs create storage/home</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Enable compression and store an extra copy of directories and files:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># zfs set copies=2 storage/home
# zfs set compression=gzip storage/home</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>A RAID-Z pool is a great place to store crucial system files, such as the home directory for users. To make the file system the home new home directory :</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># cp -rp /home/* /storage/home
# rm -rf /home /usr/home
# ln -s /storage/home /home
# ln -s /storage/home /usr/home</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>File system snapshots can be created to roll back to later, the snapshot name is marked in red and can be whatever you want:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># zfs snapshot storage/home@<mark class="has-inline-color has-vivid-red-color">11-01-22</mark></code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>ZFS creates snapshots of a dataset, allowing users to back up a file system for roll backs or data recovery in the future.</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># zfs rollback storage/home@<mark class="has-inline-color has-vivid-red-color">11-01-22</mark></code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>To list all available snapshots, <code>zfs list</code> can be used:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># zfs list -t snapshot storage/home</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="zfs-quickstart-recovering-raid-z">Recovering RAID-Z</h2>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Every software RAID has a method of monitoring its <code>state</code>. View the status of RAID-Z devices using:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># zpool status -x</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>If all pools are Online and everything is normal, the message shows:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code>all pools are healthy</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>If there is a problem, perhaps a disk being in the Offline state, the pool state will look like this:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code>  pool: storage
 state: DEGRADED
status: One or more devices has been taken offline by the administrator.
	Sufficient replicas exist for the pool to continue functioning in a
	degraded state.
action: Online the device using 'zpool online' or replace the device with
	'zpool replace'.
 scrub: none requested
config:

	NAME        STATE     READ WRITE CKSUM
	storage     DEGRADED     0     0     0
	  raidz1    DEGRADED     0     0     0
	    da0     ONLINE       0     0     0
	    da1     OFFLINE      0     0     0
	    da2     ONLINE       0     0     0

errors: No known data errors</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>&#8220;OFFLINE&#8221; shows the administrator took da1 offline using:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># zpool offline storage da1</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Power down the computer now and replace da1. Power up the computer and return da1 to the pool:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># zpool replace storage da1</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Next, check the status again, this time without <code>-x</code> to display all pools:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># zpool status storage
 pool: storage
 state: ONLINE
 scrub: resilver completed with 0 errors on Fri Nov 4 11:12:03 2022
config:

	NAME        STATE     READ WRITE CKSUM
	storage     ONLINE       0     0     0
	  raidz1    ONLINE       0     0     0
	    da0     ONLINE       0     0     0
	    da1     ONLINE       0     0     0
	    da2     ONLINE       0     0     0

errors: No known data errors</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="zfs-quickstart-data-verification">Data Verification</h2>
<p></section>
<section class="block block-core-paragraph"></p>
<p>ZFS uses checksums to verify the integrity of stored data, these data checksums can be verified (which is called <em>scrubbing</em>) to ensure integrity of the storage pool:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># zpool scrub storage</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Only one scrub can be run at a time due to the heavy input/output requirements. The length of the scrub depends on how much data is store in the pool.After scrubbing completes, view the status with <code>zpool status</code>:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code># zpool status storage
 pool: storage
 state: ONLINE
 scrub: scrub completed with 0 errors on Fri Nov 4 11:19:52 2022
config:

	NAME        STATE     READ WRITE CKSUM
	storage     ONLINE       0     0     0
	  raidz1    ONLINE       0     0     0
	    da0     ONLINE       0     0     0
	    da1     ONLINE       0     0     0
	    da2     ONLINE       0     0     0

errors: No known data errors</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Displaying the completion date of the last scrubbing helps decide when to start another. Routine scrubs help protect data from silent corruption and ensure the integrity of the pool.</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">ZFS Administration</h2>
<p></section>
<section class="block block-core-paragraph"></p>
<p>ZFS has two main utilities for administration: The <code>zpool</code> utility controls the operation of the pool and allows adding, removing, replacing, and managing disks. The <a href="https://docs.freebsd.org/en/books/handbook/zfs/#zfs-zfs"><code>zfs</code></a> utility allows creating, destroying, and managing datasets, both file systems and volumes.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>While this introductory guide won&#8217;t cover ZFS administration, you can refer to <a href="https://www.freebsd.org/cgi/man.cgi?query=zfs&amp;sektion=8&amp;format=html">zfs(8)</a> and <a href="https://www.freebsd.org/cgi/man.cgi?query=zpool&amp;sektion=8&amp;format=html">zpool(8)</a> for other ZFS options.</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">Further Resources</h2>
<p></section>
<section class="block block-core-list"></p>
<ul class="wp-block-list">
	<li><a href="https://openzfs.org/">OpenZFS</a></li>
	<li><a href="https://wiki.freebsd.org/ZFSTuningGuide">FreeBSD Wiki &#8211; ZFS Tuning</a></li>
	<li><a href="https://calomel.org/zfs_raid_speed_capacity.html">Calomel Blog &#8211; ZFS Raidz Performance, Capacity and Integrity</a></li>
</ul>
<p></section><section class="block block-classic-editor"></p></section><p>The post <a href="https://staging.freebsdfoundation.org/resource/an-introduction-to-the-z-file-system/">An Introduction to ZFS</a> first appeared on <a href="https://staging.freebsdfoundation.org">FreeBSD Foundation</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Binary Package Management on FreeBSD</title>
		<link>https://staging.freebsdfoundation.org/resource/binary-package-management-on-freebsd/</link>
		
		<dc:creator><![CDATA[Anne Dickison]]></dc:creator>
		<pubDate>Thu, 12 Jan 2023 15:06:56 +0000</pubDate>
				<guid isPermaLink="false">https://freebsdfoundation.org/?post_type=resource&#038;p=11736</guid>

					<description><![CDATA[<p>The simplest way to install and manage applications and system tools on FreeBSD is through the pkg package management tool, which makes dealing with binary packages fast and easy. Binary packages are pre-compiled and require no in-depth understanding of compiling software on FreeBSD, making them the ideal method to install software for new users.</p>
<p>The post <a href="https://staging.freebsdfoundation.org/resource/binary-package-management-on-freebsd/">Binary Package Management on FreeBSD</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 id="pkgng-intro">The simplest way to install and manage applications and system tools on FreeBSD is through the <code>pkg</code> package management tool, which makes dealing with binary packages fast and easy. Binary packages are pre-compiled and require no in-depth understanding of compiling software on FreeBSD, making them the ideal method to install software for new users.</p>
<p><img loading="lazy" decoding="async" class="wp-image-11737 aligncenter" src="https://staging.freebsdfoundation.org/wp-content/uploads/2022/10/Untitled-design-26-1024x577.png" alt="" width="692" height="390" srcset="https://staging.freebsdfoundation.org/wp-content/uploads/2022/10/Untitled-design-26-1024x577.png 1024w, https://staging.freebsdfoundation.org/wp-content/uploads/2022/10/Untitled-design-26-300x169.png 300w, https://staging.freebsdfoundation.org/wp-content/uploads/2022/10/Untitled-design-26-1536x865.png 1536w, https://staging.freebsdfoundation.org/wp-content/uploads/2022/10/Untitled-design-26.png 1640w" sizes="(max-width: 692px) 100vw, 692px" /></p>
<div class="sectionbody">
<div class="sect2">
<h2 id="pkgng-initial-setup">1. Getting Started with pkg</h2>
<div class="paragraph">
<p>FreeBSD includes a bootstrap utility which can be used to download and install pkg and its manual pages. This process will require a working Internet connection.</p>
</div>
<div class="admonitionblock note">To bootstrap the system, run:</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="shell"><span class="c"># /usr/sbin/pkg</span></code></pre>
<div class="copy-to-clipboard-wrapper">Usage information for pkg is available in the <a href="https://www.freebsd.org/cgi/man.cgi?query=pkg&amp;sektion=8&amp;format=html">pkg(8)</a> manual page or by running <code>pkg</code> without additional arguments. To access the manual page run:</div>
</div>
<pre><code># man pkg</code></pre>
</div>
<div class="paragraph">
<p>Each pkg command argument is documented in a command-specific manual page. To read the manual page for <code>pkg install</code>, for example, run either of these commands:</p>
</div>
<div class="listingblock">
<div class="content">
<pre><code data-lang="shell"><span class="c"># pkg help install</span></code> <code><span class="c"># man pkg-install</span></code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<div class="copy-to-clipboard-wrapper"> </div>
</div>
</div>
<h2 id="pkgng-installing-deinstalling">2. Installing and Removing Packages</h2>
<div class="paragraph">
<p>To install a binary package, use the following command, where <em>packagename</em> is the name of the package to install:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="shell"><span class="c"># pkg install packagename</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Before the installer proceeds, the system will ask to confirm and approve the changes, this can be done be either typing &#8220;y&#8221; or &#8220;n&#8221; to approve or cancel the process. Once complete, the new package and any additional packages that were installed as dependencies can be seen in the installed packages list:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="shell"><span class="c"># pkg info</span>
ca_root_nss-3.15.1_1	The root certificate bundle from the Mozilla Project
curl-7.31.0_1	Non-interactive tool to get files from FTP, GOPHER, HTTP<span class="o">(</span>S<span class="o">)</span> servers
pkg-1.1.4_6	New generation package manager</code></pre>
<div class="copy-to-clipboard-wrapper">Packages that are no longer needed can be removed with <code>pkg delete</code>. For example:</div>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="shell"><span class="c"># pkg delete curl</span>
</code></pre>
</div>
</div>
<h2 id="pkgng-upgrading">3. Upgrading Installed Packages</h2>
<div class="paragraph">
<p>Installed packages can be upgraded to their latest versions by running:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="shell"><span class="c"># pkg upgrade</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>This command will compare the installed versions with those available in the repository catalogue and upgrade them from the repository.</p>
</div>
</div>
</div>
</section><p>The post <a href="https://staging.freebsdfoundation.org/resource/binary-package-management-on-freebsd/">Binary Package Management on FreeBSD</a> first appeared on <a href="https://staging.freebsdfoundation.org">FreeBSD Foundation</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Installing a Port on FreeBSD &#8211; Video Guide</title>
		<link>https://staging.freebsdfoundation.org/resource/installing-a-port-on-freebsd-video-guide-2/</link>
		
		<dc:creator><![CDATA[Anne Dickison]]></dc:creator>
		<pubDate>Mon, 22 Aug 2022 16:53:35 +0000</pubDate>
				<guid isPermaLink="false">https://freebsdfoundation.org/?post_type=resource&#038;p=11539</guid>

					<description><![CDATA[<p>FreeBSD offers two primary methods of downloading applications and system tools: packages and ports. This video guide focuses on using the port collection to install irssi, a powerful and modular text-based Internet Relay Chat (IRC) client.</p>
<p>The post <a href="https://staging.freebsdfoundation.org/resource/installing-a-port-on-freebsd-video-guide-2/">Installing a Port on FreeBSD – Video 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><iframe title="YouTube video player" src="//www.youtube.com/embed/lywkQkTXMEY" width="1000" height="550" frameborder="0" allowfullscreen="allowfullscreen"></iframe></p>
</section><p>The post <a href="https://staging.freebsdfoundation.org/resource/installing-a-port-on-freebsd-video-guide-2/">Installing a Port on FreeBSD – Video Guide</a> first appeared on <a href="https://staging.freebsdfoundation.org">FreeBSD Foundation</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<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 loading="lazy" 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 loading="lazy" 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>Updating FreeBSD From Git</title>
		<link>https://staging.freebsdfoundation.org/resource/updating-freebsd-from-git/</link>
		
		<dc:creator><![CDATA[Anne Dickison]]></dc:creator>
		<pubDate>Mon, 15 Aug 2022 18:27:46 +0000</pubDate>
				<guid isPermaLink="false">https://freebsdfoundation.org/?post_type=resource&#038;p=11561</guid>

					<description><![CDATA[<p>With FreeBSD's ongoing migration to git from subversion, the system for updating FreeBSD from source has adapted. This guide will cover getting sources from git, updating them, and how to bisect those sources. It is meant as an introduction to the new mechanics for general users.</p>
<p>The post <a href="https://staging.freebsdfoundation.org/resource/updating-freebsd-from-git/">Updating FreeBSD From Git</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-paragraph"></p>
<p><strong>Updated: June 15, 2022</strong></p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>With FreeBSD&#8217;s ongoing migration to git from subversion, the system for updating FreeBSD from source has adapted. This guide will cover getting sources from git, updating them, and how to bisect those sources. It is meant as an introduction to the new mechanics for general users.</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>
<h3 id="Keeping-Current-With-FreeBSD-src-tree" class="has-text-align-left wp-block-heading">1. Keeping Current With FreeBSD src tree</h3>
<p></section>
<section class="block block-core-paragraph"></p>
<p>To begin, the source tree must be downloaded. This can be done quite simply. First step: cloning a tree. This downloads the entire tree. There are two ways to download. By default, git will do a deep clone, which matches what most people want. However, there are times that you may wish to do a shallow clone.</p>
<p></section>
<section class="block block-core-heading"></p>
<h4 class="wp-block-heading" id="Branch-names">1.1 Branch names</h4>
<p></section>
<section class="block block-core-paragraph"></p>
<p>The branch names in the new git repository are similar to the subversion names. For the stable branches, they are <code><strong>stable/X</strong></code> where <strong><code>X</code></strong> is the major release number (like 12 or 13). The development branch for -CURRENT in the new repository is <code><strong>main</strong></code>.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p><strong>Note:</strong> The main branch is the default branch if you omit the <strong><code>-b branch</code></strong> options below.</p>
<p></section>
<section class="block block-core-heading"></p>
<h4 class="wp-block-heading" id="Repositories">1.2 Repositories</h4>
<p></section>
<section class="block block-core-list"></p>
<ul class="wp-block-list">
	<li>The official geographically distributed mirror for the general public is git.FreeBSD.org, The access URL is: <a href="https://git.freebsd.org/src.git" target="_blank" rel="noreferrer noopener">https://git.freebsd.org/src.git</a></li>
	<li>The repository is also accessible by SSH: ssh://anongit@git.freebsd.org/src.git</li>
	<li>There are several officially maintained external mirrors. The list is available at <a href="https://docs.freebsd.org/en/books/handbook/mirrors/#external-mirrors" target="_blank" rel="noreferrer noopener">https://docs.freebsd.org/en/books/handbook/mirrors/#external-mirrors</a></li>
	<li>For using web browser to view the content, there is a cgit web interface at <a href="https://cgit.freebsd.org/src" target="_blank" rel="noreferrer noopener">https://cgit.freebsd.org/src</a></li>
</ul>
<p></section>
<section class="block block-core-list"></p>
<ul class="wp-block-list">
	<li>There is an old experimental github repository at <a href="https://github.com/freebsd/freebsd-legacy/" target="_blank" rel="noreferrer noopener">https://github.com/freebsd/freebsd-legacy/</a> (was https://github.com/freebsd/freebsd) similar to the new Git repository. However, there are a large number of mistakes in the github repository that required us to regenerate the export when we migrated to having a git repository be the source of truth for the project.</li>
</ul>
<p></section>
<section class="block block-core-paragraph"></p>
<p>The hashes are different between them. For migrating from the old repository to the new one, please refer to <a href="https://github.com/freebsd/freebsd-legacy/commit/de1aa3dab23c06fec962a14da3e7b4755c5880cf" target="_blank" rel="noreferrer noopener">https://github.com/freebsd/freebsd-legacy/commit/de1aa3dab23c06fec962a14da3e7b4755c5880cf</a></p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Use the repository of choice in place of <strong><code>$URL</code></strong> in the following commands.</p>
<p></section>
<section class="block block-core-heading"></p>
<h4 class="wp-block-heading">1.2.1 Install git From Ports/Pkg</h4>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Before cloning the tree, <strong><code>git</code></strong> will need to be installed. The simplest way of doing so is through packages.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p><code><strong># pkg install git</strong></code></p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>There are also <code><strong>git-lite</strong></code> and <code><strong>git-tiny</strong></code>, two packages with only essential dependencies available. They are sufficient for the commands in this article.</p>
<p></section>
<section class="block block-core-heading"></p>
<h4 class="wp-block-heading" id="Deep-Clone">1.2.2 Deep Clone</h4>
<p></section>
<section class="block block-core-paragraph"></p>
<p>A deep clone pulls in the entire tree, as well as all the history and branches. It’s the easiest to do. It also allows you to use git’s worktree feature to have all your active branches checked out into separate directories but with only one copy of the repository.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p><strong><code>% git clone $URL -b branch [dir]</code></strong></p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>is how you make a deep clone. <code><strong>branch</strong></code> should be one of the branches listed in the <strong>section 1.1</strong>, if omitted, it will be the depository’s default: main. Dir is an optional directory to place it in (the default will be the name of the repository you are clone (src). For example:</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p><strong><code>% git clone https://git.freebsd.org/src.git  </code></strong></p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>You’ll want a deep clone if you are interested in the history, plan on making local changes, or plan on working on more than one branch. It’s the easiest to keep up to date as well. If you are interested in the history, but are working with only one branch and are short on space, you can also use <br />
<strong><code>--single-branch</code></strong> to only download the one branch (though some merge commits will not reference the merged-from branch which may be important for some users who are interested in detailed versions of history).</p>
<p></section>
<section class="block block-core-heading"></p>
<h4 class="wp-block-heading" id="Shallow-Clone">1.2.3 Shallow Clone</h4>
<p></section>
<section class="block block-core-paragraph"></p>
<p>A shallow clone copies just the most current code, but none or little of the history. This can be useful when you need to build a specific revision of FreeBSD, or when you are just starting out and plan to track the tree more fully. You can also use it to limit history to only so many revisions.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p><strong><code>% git clone -b branch --depth 1 $URL [dir]</code></strong></p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>An example using the default branch:</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p><strong><code>% git clone --depth 1 https://git.freebsd.org/src.git</code></strong></p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>This clones the repository, but only has the most recent revision in the repository. The rest of the history is not downloaded. Should you change your mind later, you can do <code><strong>git fetch --unshallow</strong></code> to get the complete history.</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>
<h3 class="wp-block-heading">2. Building and Updating from Source</h3>
<p></section>
<section class="block block-core-paragraph"></p>
<p>After cloning the FreeBSD repository, the next step is to build from source. The process of building remains relatively unchanged, using <code><strong>make</strong></code> and <strong><code>install</code></strong>. Git and offer <code><strong>git pull </strong></code>and <code><strong>git checkout</strong></code> for updating and selecting specific branches or revisions.</p>
<p></section>
<section class="block block-core-heading"></p>
<h4 class="wp-block-heading" id="Building">2.1 Building From Source</h4>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Building can be done as described in the handbook [3], eg:</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p><strong><code>% cd src <br />
% make buildworld <br />
% make buildkernel <br />
% make installkernel <br />
% make installworld</code></strong></p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>&nbsp;</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Note that you can specify <strong><code>-j</code></strong> to make to speed up with parallelism.</p>
<p></section>
<section class="block block-core-heading"></p>
<h4 class="wp-block-heading" id="Updating">2.2 Updating From Source</h4>
<p></section>
<section class="block block-core-paragraph"></p>
<p>The following command will update both types of trees. This will pull all revisions since the last update.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p><strong><code>% git pull --ff-only </code></strong></p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>This will update the tree. In git, a fast forward merge is one that only needs to set a new branch pointer and doesn’t need to re-create the commits. By always doing a fast forward merge/pull, you’ll ensure that you have an identical copy of the FreeBSD tree. This will be important if you want to maintain local patches.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>See below for how to manage local changes. The simplest is to use:</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p><strong><code>% git pull --autostash </code></strong></p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>but more sophisticated options are available.</p>
<p></section>
<section class="block block-core-heading"></p>
<h4 class="wp-block-heading" id="Selecting-a-Specific-Version">2.3 Selecting a Specific Revision</h4>
<p></section>
<section class="block block-core-paragraph"></p>
<p>In git, the <code><strong>git checkout</strong></code> command can be used to checkout a specific revision as well as branches. Git’s revisions are the long hashes rather than a sequential number.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>When you checkout a specific revision, just specify the hash you want on the command line (the git log command can help you decide which hash you might want):</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p><strong><code>% git checkout 08b8197a74</code></strong></p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>However, as with many things git, it’s not so simple. You’ll be greeted with a message similar to the following:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code>Note: checking out '08b8197a742a96964d2924391bf9fdfeb788865d'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b &lt;new-branch-name&gt;

HEAD is now at 08b8197a742a hook gpiokeys.4 to the build
</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>where the last line is generated from the hash you are checking out and the first line of the commit message from that revision. Hashes can also be abbreviated. That’s why you’ll see them have different lengths in different commands or their outputs. These super long hashes are often unique after some characters, depends on the size of the repository so git lets you abbreviate and is somewhat inconsistent about how it presents them to users. <strong><code>git rev-parse --short &lt;full-hash&gt; </code></strong>will show the short hash which has the enough length to distinguish in the repository. The current length of FreeBSD src repository is 12.</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>
<h3 class="wp-block-heading" id="Bisecting">3. Bisecting/Other Considerations</h3>
<p></section>
<section class="block block-core-heading"></p>
<h4 class="wp-block-heading">3.1 Bisecting With git bisect</h4>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Sometimes, things go wrong. The last revision worked, but the one you just updated to does not. A developer may ask to bisect the problem to track down which commit caused the regression.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>If you’ve read the last section, you may be thinking to yourself “How the heck do I bisect with crazy revision numbers like that?” then this section is for you. It’s also for you if you didn’t think that, but also want to bisect.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Fortunately, git offers the <code><strong>git bisect</strong></code> command. Here’s a brief outline in how to use it. For more information, I’d suggest <a href="https://git-scm.com/docs/git-bisect" target="_blank" rel="noreferrer noopener">https://git-scm.com/docs/git-bisect</a> for more details. The man page is good at describing what can go wrong, what to do when revisions won’t build, when you want to use terms other than good and bad, etc, none of which will be covered here.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p><code><strong>git bisect start</strong></code> will start the bisection process. Next, you need to tell a range to go through. <code><strong>git bisect good XXXXXX</strong></code> will tell it the working revision and <strong><code>git bisect bad XXXXX</code></strong> will tell it the bad revision. The bad revision will almost always be <code><strong>HEAD</strong></code> (a special tag for what you have checked out). The good revision will be the last one you checked out.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>A quick aside: if you want to know the last revision you checked out, you should use <code><strong>git reflog</strong></code>:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code>5ef0bd68b515 (HEAD -&gt; master, origin/master, origin/HEAD) HEAD@{0}: pull --ff-only: Fast-forward
a8163e165c5b (upstream/master) HEAD@{1}: checkout: moving from b6fb97efb682994f59b21fe4efb3fcfc0e5b9eeb to master
...
</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>shows me moving the working tree to the master branch (a816…) and then updating from upstream (to 5ef0…). In this case, <code><strong>bad</strong></code> would be <code><strong>HEAD</strong></code> (or 5rf0bd68) and <code><strong>good</strong></code> would be a8163e165. As you can see from the output, HEAD@{1} also often works, but isn’t foolproof if you’ve done other things to your git tree after updating, but before you discover the need to bisect.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Back to git bisect. Set the <code><strong>good</strong></code> revision first, then set the <strong><code>bad</code></strong> (though the order doesn’t matter). When you set the bad revision, it will give you some statistics on the process:</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p><code><strong>% git bisect start<br />
% git bisect good a8163e165c5b<br />
% git bisect bad HEAD</strong></code></p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code>Bisecting: 1722 revisions left to test after this (roughly 11 steps)
[c427b3158fd8225f6afc09e7e6f62326f9e4de7e] Fixup r361997 by balancing parens.</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>You’d then build/install that revision. If it’s good you’d type <strong><code>git bisect good </code></strong>otherwise <code><strong>git bisect bad</strong></code>. You’ll get a similar message to the above each step. When you are done, report the bad revision to the developer (or fix the bug yourself and send a patch). <code><strong>git bisect reset</strong></code> will end the process and return you back to where you started (usually tip of main). Again, the git-bisect manual (linked above) is a good resource for when things go wrong or for unusual cases.</p>
<p></section>
<section class="block block-core-heading"></p>
<h4 class="wp-block-heading" id="Ports-Considerations">3.2 Documents and Ports Considerations</h4>
<p></section>
<section class="block block-core-paragraph"></p>
<p>The doc tree is the first repository converted to git. There is only one development branch in the repository, main, which contains the source of <a href="https://www.freebsd.org" target="_blank" rel="noreferrer noopener">https://www.freebsd.org</a> and <a href="https://docs.freebsd.org" target="_blank" rel="noreferrer noopener">https://docs.freebsd.org</a>.</p>
<p></section>
<section class="block block-core-list"></p>
<ul class="wp-block-list">
	<li>The repository URL is at <a href="https://git.freebsd.org/doc.git" target="_blank" rel="noreferrer noopener">https://git.freebsd.org/doc.git</a></li>
	<li>The repository is also accessible with SSH: <strong>ssh://anongit@git.freebsd.org/doc.git</strong></li>
	<li>And cgit web repository browser is at: <a href="https://cgit.freebsd.org/doc/" target="_blank" rel="noreferrer noopener">https://cgit.freebsd.org/doc/</a></li>
</ul>
<p></section>
<section class="block block-core-paragraph"></p>
<p>The ports tree operates a similar way. The branch names are different and the repos are in different locations.</p>
<p></section>
<section class="block block-core-list"></p>
<ul class="wp-block-list">
	<li>The repository URL is at <a href="https://git.freebsd.org/ports.git" target="_blank" rel="noreferrer noopener">https://git.freebsd.org/ports.git</a></li>
	<li>The repository is also accessible with SSH: <strong>ssh://anongit@git.freebsd.org/ports.git</strong></li>
	<li>And cgit web repository browser is at: <a href="https://cgit.freebsd.org/ports/" target="_blank" rel="noreferrer noopener">https://cgit.freebsd.org/ports/</a></li>
</ul>
<p></section>
<section class="block block-core-paragraph"></p>
<p>As with ports, the latest development branch is <code><strong>main</strong></code>. The quarterly branches are named the same as in FreeBSD’s svn repo. They are used by the latest and quarterly branches of the pkg.</p>
<p></section>
<section class="block block-core-heading"></p>
<h4 class="wp-block-heading" id="Coping-with-Local-Changes">3.3 Coping with Local Changes</h4>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Here’s a small collection of topics that are more advanced for the user tracking FreeBSD. If you have no local changes, you can stop reading now (it’s the last section and OK to skip).</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>One item that’s important for all of them: all changes are local until pushed. Unlike svn, git uses a distributed model. For users, for most things, there’s very little difference. However, if you have local changes, you can use the same tool to manage them as you use to pull in changes from FreeBSD. All changes that you’ve not pushed are local and can easily be modified (git rebase, discussed below does this).</p>
<p></section>
<section class="block block-core-heading"></p>
<h4 class="wp-block-heading" id="Keeping-local-changes">3.4 Keeping local changes</h4>
<p></section>
<section class="block block-core-paragraph"></p>
<p>The simplest way to keep local changes (especially trivial ones) is to use <code><strong>git stash</strong></code>. In its simplest form, you use <code><strong>git stash</strong></code> to record the changes (which pushes them onto the stash stack). Most people use this to save changes before updating the tree as described above. They then use <code><strong>git stash apply</strong></code> to re-apply them to the tree. The stash is a stack of changes that can be examined with <code><strong>git stash list</strong></code>. The git-stash man page (<a href="https://git-scm.com/docs/git-stash" target="_blank" rel="noreferrer noopener">https://git-scm.com/docs/git-stash</a>) has all the details.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>This method is suitable when you have tiny tweaks to the tree. When you have anything non trivial, you’ll likely be better off keeping a local branch and rebasing. It is also integrated with the <code><strong>git pull</strong></code> command: just add <br />
<strong>&#8211;</strong><code><strong>–autostash</strong></code> to the command line.</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>
<h3 class="wp-block-heading">4. FreeBSD Branches</h3>
<p></section>
<section class="block block-core-heading"></p>
<h4 class="wp-block-heading" id="Keeping-a-local-branch">4.1 Keeping a local branch</h4>
<p></section>
<section class="block block-core-paragraph"></p>
<p>It’s much easier to keep a local branch with git than subversion. In subversion you need to merge the commit, and resolve the conflicts. This is manageable, but can lead to a convoluted history that’s hard to upstream should that ever be necessary, or hard to replicate if you need to do so. Git also allows one to merge, along with the same problems. That’s one way to manage the branch, but it’s the least flexible.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Git has a concept of ‘rebasing’ which you can use to avoid these issues. The <code><strong>git rebase</strong></code> command will basically replay all the commits relative to the parent branch at a newer location on that parent branch. This section will briefly cover how to do this, but will not cover all scenarios.</p>
<p></section>
<section class="block block-core-heading"></p>
<h4 class="wp-block-heading" id="Create-a-branch">4.2 Create a branch</h4>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Let’s say you want to make a hack to FreeBSD’s <code><strong>ls(1)</strong></code> command to never, ever do color. There’s many reasons to do this, but this example will use that as a baseline. The FreeBSD <code><strong>ls(1)</strong></code> command changes from time to time, and you’ll need to cope with those changes. Fortunately, with git rebase it usually is automatic.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p><strong><code>% cd src<br />
% git checkout main<br />
% git checkout -b no-color-ls<br />
% cd bin/ls<br />
% vi ls.c # hack the changes in<br />
% git diff # check the changes</code></strong></p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code>diff --git a/bin/ls/ls.c b/bin/ls/ls.c
index 7378268867ef..cfc3f4342531 100644
--- a/bin/ls/ls.c
+++ b/bin/ls/ls.c
@@ -66,6 +66,7 @@ __FBSDID("$FreeBSD$");
 #include &lt;stdlib.h&gt;
 #include &lt;string.h&gt;
 #include &lt;unistd.h&gt;
+#undef COLORLS
 #ifdef COLORLS
 #include &lt;termcap.h&gt;
 #include &lt;signal.h&gt;</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p><strong><code>% # these look good, make the commit...<br />
% git commit ls.c</code></strong></p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>The commit will pop you into an editor to describe what you’ve done. Once you enter that, you have your own <strong>local</strong> branch in the git repo. Build and install it like you normally would, following the directions in the handbook. git differs from other revision control systems in that you have to tell it explicitly which files to use. Here it&#8217;s done on the commit command line, but you can also do it with <code><strong>git add</strong></code> which many of the more in depth tutorials cover.</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>
<h3 class="wp-block-heading">5. Updating to New FreeBSD Releases</h3>
<p></section>
<section class="block block-core-heading"></p>
<h4 class="wp-block-heading" id="Time-to-update">5.1 Updating to a New FreeBSD Revision</h4>
<p></section>
<section class="block block-core-paragraph"></p>
<p>When it’s time to bring in a new revision, it’s almost the same as w/o the branches. You would update like you would above, but there’s one extra command before you update, and one after. The following assumes you are starting with an unmodified tree. It’s important to start rebasing operations with a clean tree (git usually requires this).</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p><strong><code>% git checkout main <br />
% git pull<br />
% git rebase -i main no-color-ls </code></strong></p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>This will bring up an editor that lists all the commits in it. For this example, don’t change it at all. This is typically what you are doing while updating the baseline (though you also use the <code><strong>git rebase</strong></code> command to curate the commits you have in the branch).</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Once you’re done with the above, you’ve moved the commits to ls.c forward from the old revision of FreeBSD to the newer one.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Sometimes there’s merge conflicts. That’s OK. Don’t panic. You’d handle them the same as you would any other merge conflicts. To keep it simple, I’ll just describe a common issue you might see. A pointer to a more complete treatment can be found at the end of this section.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Let’s say this includes changes upstream in a radical shift to terminfo as well as a name change for the option. When you updated, you might see something like this:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code>Auto-merging bin/ls/ls.c
CONFLICT (content): Merge conflict in bin/ls/ls.c
error: could not apply 646e0f9cda11... no color ls
Resolve all conflicts manually, mark them as resolved with
"git add/rm &lt;conflicted_files&gt;", then run "git rebase --continue".
You can instead skip this commit: run "git rebase --skip".
To abort and get back to the state before "git rebase", run "git rebase --abort".
Could not apply 646e0f9cda11... no color ls</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>which looks scary. If you bring up an editor, you’ll see it’s a typical 3-way merge conflict resolution that you may be familiar with from other source code systems (the rest of ls.c has been omitted):</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code>&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD
#ifdef COLORLS_NEW
#include &lt;terminfo.h&gt;
=======
#undef COLORLS
#ifdef COLORLS
#include &lt;termcap.h&gt;
&gt;&gt;&gt;&gt;&gt;&gt;&gt; 646e0f9cda11... no color ls</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>The new code is first, and your code is second. The right fix here is to just add a <code><strong>#undef COLORLS_NEW</strong></code> before <code><strong>#ifdef</strong></code> and then delete the old changes:</p>
<p></section>
<section class="block block-core-code"></p>
<pre class="wp-block-code"><code>#undef COLORLS_NEW
#ifdef COLORLS_NEW
#include &lt;terminfo.h&gt;</code></pre>
<p></section>
<section class="block block-core-paragraph"></p>
<p>save the file. The rebase was interrupted, so you have to complete it:</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p><strong><code>% git add ls.c <br />
% git rebase --cont</code></strong></p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>which tells git that <strong><code>ls.c</code></strong> has changed and to continue the rebase operation. Since there was a conflict, you’ll get kicked into the editor to maybe update the commit message.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>If you get stuck during the rebase, don’t panic. git rebase &#8211;abort will take you back to a clean slate. It’s important, though, to start with an unmodified tree.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>For more on this topic, <a href="https://www.freecodecamp.org/news/the-ultimate-guide-to-git-merge-and-git-rebase/" target="_blank" rel="noreferrer noopener">https://www.freecodecamp.org/news/the-ultimate-guide-to-git-merge-and-git-rebase/</a> provides a rather extensive treatment. It goes into a lot of cases I didn’t cover here for simplicity that are useful to know since they come up from time to time.</p>
<p></section>
<section class="block block-core-heading"></p>
<h4 class="wp-block-heading" id="Updating-to-a-New-FreeBSD-Branch">5.2 Updating to a New FreeBSD Branch</h4>
<p></section>
<section class="block block-core-paragraph"></p>
<p>Let’s say you want to main the jump from FreeBSD stable/12 to FreeBSD current. That’s easy to do as well, if you have a deep clone.</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p><strong><code>% git checkout main <br />
% # build and install here...</code></strong></p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>and you are done. If you have a local branch, though, there’s one or two caveats. First, rebase will rewrite history, so you’ll likely want to do something to save it. Second, jumping branches tends to encounter more conflicts. If we pretend the example above was relative to stable/12, then to move to main, I’d suggest the following:</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p><strong><code>% git checkout no-color-ls <br />
% git checkout -b no-color-ls-stable-12   # create another name for this branch <br />
% git rebase -i stable/12 no-color-ls --onto main </code></strong></p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>What the above does is checkout no-color-ls. Then create a new name for it (no-color-ls-stable-12) in case you need to get back to it. Then you rebase onto the main branch. This will find all the commits to the current no-color-ls branch (back to where it meets up with the stable/12 branch) and then it will replay them onto the main branch creating a new no-color-ls branch there (which is why I had you create a placeholder name).</p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>&nbsp;</p>
<p></section>
<section class="block block-core-heading"></p>
<h1 class="wp-block-heading">References:</h1>
<p></section>
<section class="block block-core-paragraph"></p>
<p>[1] Using Git, FreeBSD Handbook, <a href="https://docs.freebsd.org/en/books/handbook/mirrors/#git">https://docs.freebsd.org/en/books/handbook/mirrors/#git</a></p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>[2] Git, FreeBSD wiki, <a href="https://wiki.freebsd.org/Git">https://wiki.freebsd.org/Git</a></p>
<p></section>
<section class="block block-core-paragraph"></p>
<p>[3] Updating FreeBSD from Source, FreeBSD Handbook, <a href="https://docs.freebsd.org/en/books/handbook/cutting-edge/#makeworld">https://docs.freebsd.org/en/books/handbook/cutting-edge/#makeworld</a></p>
<p></section><section class="block block-classic-editor"></p></section><p>The post <a href="https://staging.freebsdfoundation.org/resource/updating-freebsd-from-git/">Updating FreeBSD From Git</a> first appeared on <a href="https://staging.freebsdfoundation.org">FreeBSD Foundation</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>An Introduction to the FreeBSD Operating System &#8211; Video</title>
		<link>https://staging.freebsdfoundation.org/resource/an-introduction-to-the-freebsd-operating-system-video/</link>
		
		<dc:creator><![CDATA[Anne Dickison]]></dc:creator>
		<pubDate>Mon, 15 Aug 2022 15:48:18 +0000</pubDate>
				<guid isPermaLink="false">https://freebsdfoundation.org/?post_type=resource&#038;p=11548</guid>

					<description><![CDATA[<p>A brief introduction to some of the commands and functionality of the FreeBSD operating system. This video guide will cover the commands that a new user will need to initially start working with FreeBSD as well as how to use the FreeBSD manual pages for more information.</p>
<p>The post <a href="https://staging.freebsdfoundation.org/resource/an-introduction-to-the-freebsd-operating-system-video/">An Introduction to the FreeBSD Operating System – Video</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><iframe title="YouTube video player" src="//www.youtube.com/embed/frBzlP6t9Gw" width="1000" height="550" frameborder="0" allowfullscreen="allowfullscreen"></iframe></p>
</section><p>The post <a href="https://staging.freebsdfoundation.org/resource/an-introduction-to-the-freebsd-operating-system-video/">An Introduction to the FreeBSD Operating System – Video</a> first appeared on <a href="https://staging.freebsdfoundation.org">FreeBSD Foundation</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Installing a Desktop Environment on FreeBSD &#8211; Video Guide</title>
		<link>https://staging.freebsdfoundation.org/resource/installing-a-desktop-environment-on-freebsd-video-guide/</link>
		
		<dc:creator><![CDATA[Anne Dickison]]></dc:creator>
		<pubDate>Mon, 15 Aug 2022 15:40:52 +0000</pubDate>
				<guid isPermaLink="false">https://freebsdfoundation.org/?post_type=resource&#038;p=11541</guid>

					<description><![CDATA[<p>The FreeBSD ports collection includes a wide range of desktop environments, this video how-to guide focuses on how to set up the Xfce desktop environment.</p>
<p>The post <a href="https://staging.freebsdfoundation.org/resource/installing-a-desktop-environment-on-freebsd-video-guide/">Installing a Desktop Environment on FreeBSD – Video 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><iframe title="YouTube video player" src="//www.youtube.com/embed/mWUL7hhg-vs" width="1000" height="550" frameborder="0" allowfullscreen="allowfullscreen"></iframe></p>
</section><p>The post <a href="https://staging.freebsdfoundation.org/resource/installing-a-desktop-environment-on-freebsd-video-guide/">Installing a Desktop Environment on FreeBSD – Video Guide</a> first appeared on <a href="https://staging.freebsdfoundation.org">FreeBSD Foundation</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Installing a Port on FreeBSD – Video Guide</title>
		<link>https://staging.freebsdfoundation.org/resource/installing-a-port-on-freebsd-video-guide/</link>
		
		<dc:creator><![CDATA[Anne Dickison]]></dc:creator>
		<pubDate>Mon, 15 Aug 2022 15:36:07 +0000</pubDate>
				<guid isPermaLink="false">https://freebsdfoundation.org/?post_type=resource&#038;p=11540</guid>

					<description><![CDATA[<p>FreeBSD offers two primary methods of downloading applications and system tools: packages and ports. This video guide focuses on using the port collection to install irssi, a powerful and modular text-based Internet Relay Chat (IRC) client.</p>
<p>The post <a href="https://staging.freebsdfoundation.org/resource/installing-a-port-on-freebsd-video-guide/">Installing a Port on FreeBSD – Video 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><iframe title="YouTube video player" src="//www.youtube.com/embed/lywkQkTXMEY" width="1000" height="550" frameborder="0" allowfullscreen="allowfullscreen"></iframe></p>
</section><p>The post <a href="https://staging.freebsdfoundation.org/resource/installing-a-port-on-freebsd-video-guide/">Installing a Port on FreeBSD – Video Guide</a> first appeared on <a href="https://staging.freebsdfoundation.org">FreeBSD Foundation</a>.</p>]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
