pf firewall for a server

Peter N. M. Hansteen peter at bgnett.no
Wed Jul 26 11:06:39 UTC 2006


Jonathan Horne <freebsd at dfwlp.com> writes:

> ive been googling for a while now this evening, but have
> unsuccesfully found any examples on how to firewall a server.  i do
> *not* want to build a router, and unfortunatly, every article i seem
> to find wants to tell me how to build a router!

The same principles apply everywhere - block everyting, allow the
traffic you need.  What traffic you need to pass depends on the
services you intend to make accessible.  For a host with a single
network interface, you can get away with a handful of lines, ie

localnet="xl0:network"
offered="{ ssh, netbios-ns, netbios-dgm, netbios-ssn, www, https }" 
needed="{ ssh, domain, ntp, whois }"

block all
pass proto { tcp, udp } from self to any port $needed keep state
pass proto { tcp, udp } from $localnet to self port $offered keep state

A lot of embellishment on this (untested, may contain nuts) is
possible, and you could probably do worse than spend a few moments
browsing the PF docs or for that matter my rather basic PF tutorial at
http://www.bgnett.no/~peter/pf/ to familiarize yourself with the
system.

-- 
Peter N. M. Hansteen, member of the first RFC 1149 implementation team
http://www.blug.linux.no/rfc1149/ http://www.datadok.no/ http://www.nuug.no/
"First, we kill all the spammers" The Usenet Bard, "Twice-forwarded tales"
20:11:56 delilah spamd[26905]: 146.151.48.74: disconnected after 36099 seconds



More information about the freebsd-questions mailing list