<?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>pfctl - Hamradio.my</title>
	<atom:link href="https://hamradio.my/tag/pfctl/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>Amateur Radio, Tech Insights and Product Reviews</description>
	<lastBuildDate>Mon, 16 Jun 2025 08:12:47 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>

<image>
	<url>https://hamradio.my/wp-content/uploads/2026/02/cropped-cropped-image-removebg-preview-3-32x32.png</url>
	<title>pfctl - Hamradio.my</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>FreeBSD Firewall Basics: IPFW, PF, and IPFilter for Home Networking</title>
		<link>https://hamradio.my/2025/06/freebsd-firewall-basics-ipfw-pf-and-ipfilter-for-home-networking/</link>
					<comments>https://hamradio.my/2025/06/freebsd-firewall-basics-ipfw-pf-and-ipfilter-for-home-networking/#respond</comments>
		
		<dc:creator><![CDATA[9M2PJU]]></dc:creator>
		<pubDate>Mon, 16 Jun 2025 06:50:47 +0000</pubDate>
				<category><![CDATA[do it yourself]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[free open source software]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[open source operating system]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[firewall setup]]></category>
		<category><![CDATA[freebsd desktop]]></category>
		<category><![CDATA[freebsd firewall]]></category>
		<category><![CDATA[freebsd router]]></category>
		<category><![CDATA[freebsd tips]]></category>
		<category><![CDATA[home networking]]></category>
		<category><![CDATA[http firewall]]></category>
		<category><![CDATA[ipfilter]]></category>
		<category><![CDATA[ipfw]]></category>
		<category><![CDATA[network security]]></category>
		<category><![CDATA[openbsd pf]]></category>
		<category><![CDATA[pf]]></category>
		<category><![CDATA[pfctl]]></category>
		<category><![CDATA[rc.conf]]></category>
		<category><![CDATA[SSH]]></category>
		<guid isPermaLink="false">https://hamradio.my/?p=7507</guid>

					<description><![CDATA[<p>FreeBSD includes three built-in packet filters: IPFW, PF, and IPFILTER (IPF). All support stateful inspection, NAT, and IPv4/IPv6, but they differ in syntax and rule evaluation: Firewall Rule Behavior Syntax Style Strengths IPFW First-match wins; numbered rules Shell-like, scriptable High performance, good for beginners PF Last-match wins by default; quick for first-match Clean, macro-friendly Very [&#8230;]</p>
<p>The post <a href="https://hamradio.my/2025/06/freebsd-firewall-basics-ipfw-pf-and-ipfilter-for-home-networking/">FreeBSD Firewall Basics: IPFW, PF, and IPFilter for Home Networking</a> appeared on <a href="https://hamradio.my">Hamradio.my - Amateur Radio, Tech Insights and Product Reviews</a> by <a href="https://hamradio.my/author/9m2pju/">9M2PJU</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading"></h2>



<p class="wp-block-paragraph">FreeBSD includes three built-in packet filters: <strong>IPFW</strong>, <strong>PF</strong>, and <strong>IPFILTER (IPF)</strong>. All support stateful inspection, NAT, and IPv4/IPv6, but they differ in syntax and rule evaluation:</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>Firewall</th><th>Rule Behavior</th><th>Syntax Style</th><th>Strengths</th></tr></thead><tbody><tr><td><strong>IPFW</strong></td><td>First-match wins; numbered rules</td><td>Shell-like, scriptable</td><td>High performance, good for beginners</td></tr><tr><td><strong>PF</strong></td><td>Last-match wins by default; <code>quick</code> for first-match</td><td>Clean, macro-friendly</td><td>Very flexible, NAT/QoS support</td></tr><tr><td><strong>IPFILTER</strong></td><td>Last-match wins unless <code>quick</code> is used</td><td>PF-like</td><td>Cross-platform consistency</td></tr></tbody></table></figure>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h3 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f3e0.png" alt="🏠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Typical Home Network Ruleset Goals</h3>



<ul class="wp-block-list">
<li>Allow full LAN communication (e.g., <code>192.168.1.0/24</code>)</li>



<li>Permit outbound HTTP/HTTPS, DNS, NTP</li>



<li>Allow SSH access from LAN only</li>



<li>Block all other inbound traffic</li>



<li>Prevent spoofed or invalid traffic</li>
</ul>



<p class="wp-block-paragraph">Protocols: TCP on ports <code>80</code>, <code>443</code>, <code>22</code>; UDP on <code>53</code>, <code>123</code>.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h3 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f6e0.png" alt="🛠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Example Configurations</h3>



<h4 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> IPFW (First-match, numbered rules)</h4>



<pre class="wp-block-code"><code># /etc/ipfw.rules
ipfw -q -f flush
ipfw add 10 allow all from any to any via lo0
ipfw add 20 allow ip from 192.168.1.0/24 to any
ipfw add 30 allow ip from any to any out
ipfw add 40 allow ip from any to any established
ipfw add 50 allow tcp from any to any 80,443 out
ipfw add 60 allow udp from any to any 53,123 out
ipfw add 70 allow tcp from 192.168.1.0/24 to any 22
ipfw add 65534 deny ip from any to any
</code></pre>



<p class="wp-block-paragraph">Enable and apply:</p>



<pre class="wp-block-code"><code>sudo sysrc firewall_enable="YES"
sudo sysrc firewall_script="/etc/ipfw.rules"
chmod +x /etc/ipfw.rules
sudo service ipfw restart
</code></pre>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h4 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> PF (Last-match by default; use <code>quick</code> for early exceptions)</h4>



<pre class="wp-block-code"><code># /etc/pf.conf
ext_if = "em0"
lan_if = "re0"
lan_net = "192.168.1.0/24"

set skip on lo0
block all
pass out all keep state

pass in on $lan_if from $lan_net to any keep state
pass out proto { tcp, udp } to any port { 80 443 53 123 } keep state
pass in quick on $lan_if proto tcp from $lan_net to any port 22 keep state
</code></pre>



<p class="wp-block-paragraph">Activate:</p>



<pre class="wp-block-code"><code>sudo sysrc pf_enable="YES"
sudo sysrc pf_rules="/etc/pf.conf"
sudo pfctl -f /etc/pf.conf
sudo service pf restart
</code></pre>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h4 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> IPFILTER (Last-match; <code>quick</code> stops further processing)</h4>



<pre class="wp-block-code"><code># /etc/ipf.rules
pass in quick on lo0 all
pass out quick on lo0 all

pass in quick on rl0 from 192.168.1.0/24 to any keep state
pass out quick on rl0 all keep state

pass out quick proto tcp from any to any port = 80 keep state
pass out quick proto tcp from any to any port = 443 keep state
pass out quick proto udp from any to any port = 53 keep state
pass out quick proto udp from any to any port = 123 keep state

pass in quick proto tcp from 192.168.1.0/24 to any port = 22 keep state
block in all
</code></pre>



<p class="wp-block-paragraph">Enable:</p>



<pre class="wp-block-code"><code>sudo sysrc ipfilter_enable="YES"
sudo sysrc ipfilter_rules="/etc/ipf.rules"
sudo service ipfilter restart
</code></pre>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h3 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f9ed.png" alt="🧭" class="wp-smiley" style="height: 1em; max-height: 1em;" /> How to Choose?</h3>



<ul class="wp-block-list">
<li><strong>IPFW</strong> – Great for simple setups; high performance; deep FreeBSD/Dummynet integration.</li>



<li><strong>PF</strong> – Highly flexible, macros, NAT, QoS, logging—ideal for advanced configurations.</li>



<li><strong>IPFILTER</strong> – If you need compatibility with other OSes and prefer PF-style syntax—less actively developed now.</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h3 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4da.png" alt="📚" class="wp-smiley" style="height: 1em; max-height: 1em;" /> References</h3>



<p class="wp-block-paragraph">FreeBSD Handbook: <strong><a href="https://docs.freebsd.org/en/books/handbook/firewalls/">https://docs.freebsd.org/en/books/handbook/firewalls/</a></strong></p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p class="wp-block-paragraph"><strong>Conclusion:</strong> For a home setup, IPFW offers simplicity and raw performance, PF gives you the most flexibility, and IPFILTER remains viable for legacy or cross-OS consistency. Remove unrelated details, reference the Handbook directly, and focus on practical configurations tailored for home use.</p>
<p>The post <a href="https://hamradio.my/2025/06/freebsd-firewall-basics-ipfw-pf-and-ipfilter-for-home-networking/">FreeBSD Firewall Basics: IPFW, PF, and IPFilter for Home Networking</a> appeared on <a href="https://hamradio.my">Hamradio.my - Amateur Radio, Tech Insights and Product Reviews</a> by <a href="https://hamradio.my/author/9m2pju/">9M2PJU</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://hamradio.my/2025/06/freebsd-firewall-basics-ipfw-pf-and-ipfilter-for-home-networking/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
