<?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>OpenBSD and FreeBSD resources &#187; Firewall</title>
	<atom:link href="http://purebsd.com/tag/firewall/feed" rel="self" type="application/rss+xml" />
	<link>http://purebsd.com</link>
	<description></description>
	<lastBuildDate>Tue, 01 Jun 2010 06:01:11 +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>Setting Up Firewall</title>
		<link>http://purebsd.com/setting-up-firewall.html</link>
		<comments>http://purebsd.com/setting-up-firewall.html#comments</comments>
		<pubDate>Tue, 01 Jun 2010 04:15:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Network]]></category>
		<category><![CDATA[OpenBSD]]></category>
		<category><![CDATA[Firewall]]></category>

		<guid isPermaLink="false">http://purebsd.com/?p=14</guid>
		<description><![CDATA[Setting up a firewall A structured page about configuring PF, the OpenBSD firewall program, is coming soon. In the mean time you might like to view my /etc/pf.conf file below. It has comments to make things more clear. You can also download it: - pf.conf (plaintext) - pf.conf.gz (gzipped) My /etc/pf.conf: # $OpenBSD: pf.conf,v 1.21 2003/09/02 20:38:44 david Exp [...]]]></description>
			<content:encoded><![CDATA[<table border="0" cellspacing="0" cellpadding="0" width="700" align="center">
<tbody>
<tr>
<td width="572" valign="top"><strong>Setting up a firewall</strong><br />
A structured page about configuring PF, the OpenBSD firewall program, is coming soon. In the mean time you might like to view my <code>/etc/pf.conf</code> file below. It has comments to make things more clear.</p>
<p>You can also download it:<br />
- <a href="http://purebsd.com/pf.conf.txt">pf.conf</a> (plaintext)<br />
- <a href="http://purebsd.com/pf.conf.gz">pf.conf.gz</a> (gzipped)</p>
<p>My <code>/etc/pf.conf</code>:</p>
<p><code>#	$OpenBSD: pf.conf,v 1.21 2003/09/02 20:38:44 david Exp $<br />
#<br />
# See pf.conf(5) and /usr/share/pf for syntax and examples.<br />
# Required order: options, normalization, queueing, translation, filtering.<br />
# Macros and tables may be defined and used anywhere.<br />
# Note that translation rules are first match while filter rules are last match.<br />
#</code></p>
<p><code># &lt;bof&gt;</p>
<p>#########################################<br />
# *** START MACRO &amp; TABLE DEFINITIONS ***<br />
#</p>
<p># (Device)names of network interfaces<br />
loc_if	 = "lo0"<br />
int_if	 = "xl0"<br />
ext_if	 = "rl0"</p>
<p># IP addresses of network interfaces<br />
loc_addr	= "127.0.0.1"<br />
int_addr	= "192.168.0.3"<br />
ext_addr	= "132.175.118.161"</p>
<p># CIDR address spaces of our networks<br />
loc_net	 = "127.0.0.1/32"<br />
int_net	 = "192.168.0.0/24"<br />
ext_net	 = "132.175.118.161/32"</p>
<p># Port intervals, icmp-types, etc<br />
ftp_ports	= "{ 50042 &gt;&lt; 52042 }"<br />
icmp_types	= "echoreq"</p>
<p># Stateful packet filtering options macros for clarity pf rules<br />
sf_udp	 = "keep state"<br />
sf_icmp	 = "keep state"<br />
sf_tcp	 = "flags S/SA modulate state"</p>
<p># Restrictive access tables (for POP3 &amp; syslog)<br />
table &lt;popxs&gt;	{ 180.126.21.182, 243.73.176.15, 243.73.158.228 }<br />
table &lt;syslxs&gt;	{ 132.175.117.104 }</p>
<p>#<br />
# *** END MACRO &amp; TABLE DEFINITIONS ***<br />
#######################################</p>
<p>###################################################<br />
# *** START OPTIONS, SCRUBBING &amp; QUEUEING RULES ***<br />
#</p>
<p># Options: tune the behavior of pf, default values are given.<br />
#set timeout { interval 10, frag 30 }<br />
#set timeout { tcp.first 120, tcp.opening 30, tcp.established 86400 }<br />
#set timeout { tcp.closing 900, tcp.finwait 45, tcp.closed 90 }<br />
#set timeout { udp.first 60, udp.single 30, udp.multiple 60 }<br />
#set timeout { icmp.first 20, icmp.error 10 }<br />
#set timeout { other.first 60, other.single 30, other.multiple 60 }<br />
#set timeout { adaptive.start 0, adaptive.end 0 }<br />
#set limit { states 10000, frags 5000 }<br />
#set loginterface none<br />
#set optimization normal<br />
#set block-policy drop<br />
#set require-order yes<br />
#set fingerprints "/etc/pf.os"</p>
<p># Options that suit us better than the defaults<br />
set block-policy return</p>
<p># Normalization: reassemble fragments and resolve or reduce traffic ambiguities.<br />
scrub in all</p>
<p># Queueing: rule-based bandwidth control.<br />
#altq on $ext_if bandwidth 15Kb cbq queue { dflt, developers, marketing }<br />
#queue dflt bandwidth 5% cbq(default)<br />
#queue developers bandwidth 80%<br />
#queue marketing bandwidth 15%</p>
<p>#<br />
# *** END OPTIONS, SCRUBBING &amp; QUEUEING RULES ***<br />
#################################################</p>
<p>#######################################<br />
# *** START NAT &amp; REDIRECTION RULES ***<br />
#</p>
<p># NAT: Do some NAT favors for the internal net (-:<br />
nat on $ext_if from $int_net to any -&gt; $ext_addr</p>
<p># RDR: Redirect eDonkey2000/Overnet and WinMX traffic to my laptop<br />
rdr on $ext_if proto tcp to $ext_if port 4662 -&gt; 192.168.0.110 port 4662 # eDonkey<br />
rdr on $ext_if proto udp to $ext_if port 4665 -&gt; 192.168.0.110 port 4665 # eDonkey<br />
rdr on $ext_if proto tcp to $ext_if port 6699 -&gt; 192.168.0.110 port 6699 # WinXM<br />
rdr on $ext_if proto udp to $ext_if port 6257 -&gt; 192.168.0.110 port 6257 # WinXM</p>
<p># RDR: Redirect outgoing FTP requests to the ftp-proxy<br />
rdr on $int_if proto tcp from any to any port ftp -&gt; $loc_if port 8021</p>
<p># RDR: spamd-setup puts addresses to be redirected into table &lt;spamd&gt;.<br />
table &lt;spamd&gt; persist<br />
no rdr on $loc_if all<br />
rdr inet proto tcp from &lt;spamd&gt; to any port smtp -&gt; $loc_if port 8025</p>
<p>#<br />
# *** END NAT &amp; REDIRECTION RULES ***<br />
######################################</p>
<p>#########################################<br />
# *** START (STATEFUL) FIREWALL RULES ***<br />
#</p>
<p># External interface: anti-spoofing measures; with logging<br />
block drop in quick log on $ext_if from 127.0.0.1/8 to any<br />
block drop in quick log on $ext_if from 172.16.0.0/12 to any<br />
block drop in quick log on $ext_if from 192.168.0.0/16 to any<br />
block drop in quick log on $ext_if from $ext_addr to any</p>
<p># External interface: drop ASAP Windows SMB &amp; MS-SQL related packets; no logging<br />
block drop in quick on $ext_if proto { tcp, udp } to port { 135, 137, 138, 139, 1433 }<br />
block drop in quick on $ext_if proto { tcp, udp } from port { 135, 137, 138, 139, 1433 }</p>
<p># External interface: drop UDP port 4669 crap without logging<br />
block drop in quick on $ext_if proto udp to port 4669</p>
<p># External inferface: drop ASAP spammers; no logging<br />
block drop in quick on $ext_if from 202.84.15.0/24 to any	# Hongkong.com crap</p>
<p># External interface: drop crap we don't want to see in our logs<br />
block drop in quick on $ext_if to 0.0.0.0/32<br />
block drop in quick on $ext_if from 0.0.0.0/32<br />
block drop in quick on $ext_if to 224.0.0.0/4<br />
block drop out quick on $ext_if to 224.0.0.0/4<br />
block drop in quick on $ext_if to 255.255.255.255/32<br />
block drop in quick on $ext_if from 255.255.255.255/32</p>
<p># Local interface: TCP/UDP/ICMP incoming/outgoing connection<br />
pass in quick on $loc_if all<br />
pass out quick on $loc_if all</p>
<p># Internal interface: TCP/UDP/ICMP incoming/outgoing connection<br />
pass in quick on $int_if all<br />
pass out quick on $int_if all</p>
<p># External interface: incoming eDonkey2000/Overnet and WinMX traffic to my laptop<br />
pass in quick on $ext_if proto tcp to 192.168.0.110 port 4662 # eDonkey<br />
pass in quick on $ext_if proto udp to 192.168.0.110 port 4665 # eDonkey<br />
pass in quick on $ext_if proto tcp to 192.168.0.110 port 6699 # WinXM<br />
pass in quick on $ext_if proto udp to 192.168.0.110 port 6257 # WinXM</p>
<p># External interface: UDP incoming connections<br />
pass in quick on $ext_if proto udp to $ext_if port 53 $sf_udp<br />
pass in quick on $ext_if proto udp from &lt;syslxs&gt; to $ext_if port 514 $sf_udp</p>
<p># Externel interface: TCP incoming connections<br />
pass in quick on $ext_if proto tcp to $ext_if port 22 $sf_tcp<br />
pass in quick on $ext_if proto tcp to $ext_if port 25 $sf_tcp<br />
pass in quick on $ext_if proto tcp to $ext_if port 80 $sf_tcp<br />
pass in quick on $ext_if proto tcp from &lt;popxs&gt; to $ext_if port 110 $sf_tcp<br />
pass in quick on $ext_if proto tcp to $ext_if port 113 $sf_tcp<br />
pass in quick on $ext_if proto tcp to $loc_if port 8025 $sf_tcp<br />
pass in quick on $ext_if proto tcp from any port 20 to $ext_if port $ftp_ports user proxy $sf_tcp</p>
<p># Externel interface: ICMP incoming connections<br />
pass in quick on $ext_if proto icmp to $ext_if icmp-type $icmp_types $sf_icmp</p>
<p># Externel interface: TCP outgoing connections<br />
pass out quick on $ext_if proto tcp all $sf_tcp<br />
pass out quick on $ext_if proto { udp, icmp } all $sf_udp</p>
<p># All interfaces: block everything by default<br />
block log quick all</p>
<p>#<br />
# *** END (STATEFUL) FIREWALL RULES ***<br />
#######################################</p>
<p>#####################################################<br />
# *** START QUEUE ASSIGNMENTS FOR OUTGOING TRAFIC ***<br />
#</p>
<p># Assign packets to a queue.<br />
#pass out on $ext_if from 192.168.0.0/24 to any keep state queue developers<br />
#pass out on $ext_if from 192.168.1.0/24 to any keep state queue marketing</p>
<p>#<br />
# *** END QUEUE ASSIGNMENTS FOR OUTGOING TRAFIC ***<br />
###################################################</p>
<p></code><code># &lt;eof&gt;<br />
</code></td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://purebsd.com/setting-up-firewall.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

