<?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>Analysis and Review &#187; pf configuration</title>
	<atom:link href="http://analysisandreview.com/tag/pf-configuration/feed/" rel="self" type="application/rss+xml" />
	<link>http://analysisandreview.com</link>
	<description>Brain Dumps For All</description>
	<lastBuildDate>Fri, 13 Apr 2012 12:51:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Best freeBSD Firewall for a Web Server, PF Configuration and Testing</title>
		<link>http://analysisandreview.com/unix/best-freebsd-firewall-for-a-web-server-pf-configuration-and-testing/</link>
		<comments>http://analysisandreview.com/unix/best-freebsd-firewall-for-a-web-server-pf-configuration-and-testing/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 04:03:01 +0000</pubDate>
		<dc:creator>Kurt</dc:creator>
				<category><![CDATA[Unix]]></category>
		<category><![CDATA[best freebsd firewall]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[pf]]></category>
		<category><![CDATA[pf configuration]]></category>
		<category><![CDATA[web server]]></category>
		<category><![CDATA[webserver]]></category>

		<guid isPermaLink="false">http://analysisandreview.com/?p=687</guid>
		<description><![CDATA[You&#8217;ll see many articles discussing various firewalls for BSD. freeBSD comes with three firewalls but I&#8217;ll lay out what I believe is the best freebsd firewall for a web server, pf. I need firewall that will help negate DDoS attacks, spoofing and fingerprinting. Allows port 80 and 443 as well as ssh and is simple ]]></description>
			<content:encoded><![CDATA[<div id="attachment_688" class="wp-caption alignright" style="width: 266px"><a href="http://analysisandreview.com/wp-content/blogs.dir/5/files/uploads/2010/02/freebsd-firewall.png"><img class="size-full wp-image-688" src="http://analysisandreview.com/wp-content/blogs.dir/5/files/uploads/2010/02/freebsd-firewall.png" alt="freeBSD 8 firewall for web server" width="256" height="256" /></a><p class="wp-caption-text">freeBSD 8 firewall for web server</p></div>
<p>You&#8217;ll see many articles discussing various firewalls for BSD. freeBSD comes with three firewalls but I&#8217;ll lay out what I believe is the best freebsd firewall for a web server, pf.<span id="more-687"></span></p>
<p>I need firewall that will help negate DDoS attacks, spoofing and fingerprinting. Allows port 80 and 443 as well as ssh and is simple to test and configure.</p>
<p>Well PF handles all that and comes built into the freeBSD kernel so it&#8217;s pretty easy and quick to set up and test.</p>
<p>do a ifconfig to figure out what your interface is named</p>
<pre class="brush: bash; title: ; notranslate">#ifconfig
bigkill# ifconfig
 re0:  flags=8843 metric 0 IC&amp;gt;
        ether 00:2c:c1:f9:5s:d3
        inet 224.210.155.13 netmask 0xfffffff8 broadcast 224.210.155.253
        media: Ethernet autoselect (100baseTX )
        status: active
lo0: flags=8049 metric 0
        inet 127.0.0.1 netmask 0xff000000
</pre>
<p>As you can see here the interface name is  re0</p>
<p> so just replace re0 in the below configuration and apply it to /etc/pf.conf</p>
<pre class="brush: bash; title: ; notranslate"> ### macro name for external interface.
ext_if = &quot;re0&quot;

### all incoming traffic on external interface is normalized and fragmented
### packets are reassembled.
scrub in on $ext_if all fragment reassemble

### set a default deny everything policy.
block all

### exercise antispoofing on the external interface, but add the local
### loopback interface as an exception, to prevent services utilizing the
### local loop from being blocked accidentally.
set skip on lo0
antispoof for $ext_if inet

### block anything coming from sources that we have no back routes for.
block in from no-route to any

### block packets that fail a reverse path check. we look up the routing
### table, check to make sure that the outbound is the same as the source
### it came in on. if not, it is probably source address spoofed.
block in from urpf-failed to any

### drop broadcast requests quietly.
block in quick on $ext_if from any to 255.255.255.255

### block packets claiming to come from reserved internal address blocks, as
### they are obviously forged and cannot be contacted from the outside world.
block in log quick on $ext_if from { 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 255.255.255.255/32 } to any

### block probes that can possibly determine our operating system by disallowing
### certain combinations that are commonly used by nmap, queso and xprobe2, who
### are attempting to fingerprint the server.
### * F : FIN  - Finish; end of session
### * S : SYN  - Synchronize; indicates request to start session
### * R : RST  - Reset; drop a connection
### * P : PUSH - Push; packet is sent immediately
### * A : ACK  - Acknowledgement
### * U : URG  - Urgent
### * E : ECE  - Explicit Congestion Notification Echo
### * W : CWR  - Congestion Window Reduced
block in quick on $ext_if proto tcp flags FUP/WEUAPRSF
block in quick on $ext_if proto tcp flags WEUAPRSF/WEUAPRSF
block in quick on $ext_if proto tcp flags SRAFU/WEUAPRSF
block in quick on $ext_if proto tcp flags /WEUAPRSF
block in quick on $ext_if proto tcp flags SR/SR
block in quick on $ext_if proto tcp flags SF/SF

### keep state on any outbound tcp, udp or icmp traffic. modulate the isn of
### outgoing packets. (initial sequence number) broken operating systems
### sometimes don't randomize this number, making it guessable.
pass out on $ext_if proto { tcp, udp, icmp } from any to any modulate state

### normally, a client connects to the server and we handshake with them, then
### proceed to exchange data. by telling pf to handshake proxy between the client
### and our server, tcp syn flood attacts from ddos become uneffective because
### a spoofed client cannot complete a handshake.

### set a rule that allows inbound ssh traffic with synproxy handshaking. yes I changed the ssh port
pass in on $ext_if proto tcp from any to any port 1229 flags S/SA synproxy state
### set a rule that allows inbound www traffic with synproxy handshaking.
pass in on $ext_if proto tcp from any to any port 80 flags S/SA synproxy state
pass in on $ext_if proto tcp from any to any port 443 flags S/SA synproxy state
 </pre>
<p> If you want to allow any other port simple copy the last line and replace the port number.</p>
<p> Now issue a reboot command to restart the system in 5 minutes to test your pf configuration.</p>
<pre class="brush: bash; title: ; notranslate"> shutdown -r +5
 </pre>
<p> Okay not start PF and test it</p>
<pre class="brush: bash; title: ; notranslate"> /etc/rc.d/pf onestart
 </pre>
<p> Now &#8220;test&#8221; the current configuration to see what you got</p>
<pre class="brush: bash; title: ; notranslate"> pfctl -s all&quot; ### list all the current rules that are in effect and shows current connections
 </pre>
<p> If you&#8217;re happy with your PF firewall configuration for freebsd 8 you&#8217;ll need to apply it at boot time by adding the following to your /etc/rc.conf</p>
<pre class="brush: bash; title: ; notranslate"> pf_enable=&quot;YES&quot;
pf_rules=&quot;/etc/pf.conf&quot;
 </pre>
]]></content:encoded>
			<wfw:commentRss>http://analysisandreview.com/unix/best-freebsd-firewall-for-a-web-server-pf-configuration-and-testing/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

