elmore
April 1st, 2005, 20:35
This ruleset is not even close to done but I thought I'd post what I had anyways, in the hope to get a little feedback. I was having trouble finding a real default deny out ruleset. I decided to create my own. I was loathing the process but once I got going it wasn't that bad. I'm obviously missing some things (lack of ftp atm, and no icmp to the inet, etc...) it's not done yet but it's enough to give everyone a rough idea of where I'm going.
# Macros: define common values, so they can be referenced and changed easily.
ext_if="em0" # replace with actual external interface name i.e., dc0
int_if="em1" # replace with actual internal interface name i.e., dc1
ssh_host="{ 172.16.3.253 }"
web_servers="{ 172.16.3.7 }"
# Tables: Lists of IP Addresses to apply rules to.
table <ineternal_nets> persist file "/etc/internal_nets"
table <NoRouteIP> persist file "/etc/norouteip"
table <Siteip> persist file "/etc/Siteip"
table <badguys> persist file "/etc/badguys"
# Set Optimizations: Set some values to better utilize memory.
set block-policy drop
set limit { frags 5000, states 2500, src-nodes 2000 }
set loginterface $ext_if
set optimization aggressive
set timeout { interval 10, frag 30 }
#Normalization: reassemble fragments and resolve or reduce traffic #ambiguities.
scrub in on $ext_if all fragment reassemble min-ttl 15 max-mss 1400
scrub on $ext_if reassemble tcp
#NAT: Translate to the internal network.
nat on $ext_if from <internal_nets> to any -> $ext_if
#Re-Direct: Re-direct packets to the PDMZ network.
rdr on $ext_if inet proto { tcp, udp } from any to any port 22 -> $ssh_host
rdr on $ext_if inet proto { tcp, udp } from any to any port 80 -> $web_servers
rdr on $ext_if inet proto { tcp, udp } from any to any port 443 -> $web_servers
#Rules: Filter Rules Explanations above each rule.
#Block in Everything by default
block in log on $ext_if all
#Don't allow anyone to spoof unroutable addresses
block in log quick on $ext_if from <NoRouteIP> to any
block out log quick on $ext_if from any to <NoRouteIP>
#Block these badguys
block in log quick on $ext_if inet proto { tcp, udp } from <badguys> to any
#Pass vpn traffic
pass in quick on $ext_if inet proto udp from <Siteip> to $ext_if port = 500 keep state
pass in quick on $ext_if inet proto udp from <Siteip> to $ext_if port = 4500 keep state
pass in quick on $ext_if inet proto esp from <Siteip> to $ext_if keep state
#Pass in ssh
pass in quick on $ext_if proto tcp from any to $ssh_host port = 22 flags S/SA synproxy state
#Pass in Web
pass in quick on $ext_if proto tcp from any to $web_servers port = 80 flags S/SA synproxy state
pass in quick on $ext_if proto tcp from any to $web_servers port = 443 flags S/SA synproxy state
#Default block out
block out log on $ext_if all
#Allow ISAKMP out
pass out quick on $ext_if inet proto udp from $ext_if to <Siteip> port = 500 keep state
pass out quick on $ext_if inet proto udp from $ext_if to <Siteip> port = 4500 keep state
pass out quick on $ext_if inet proto esp from $ext_if to <Siteip> keep state
#Allow SSH out
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = ssh keep state
#Allow WWW
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = www keep state
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = https keep state
#Allow DNS
pass out quick on $ext_if inet proto { udp, udp } from any to any port = domain keep state
#Allow Mail
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 25 keep state
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 465 keep state
#Allow IMAP
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 143 keep state
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 993 keep state
#Allow NNTP
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 119 keep state
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 563 keep state
#Allow NTP
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 123 keep state
#Allow irc
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 194 keep state
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 6667 keep state
#Allow AIM
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 5190 keep state
#Allow REAL Streams
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 554 keep state
#Allow various Poker software ;)
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 2147
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 26229
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 701
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 4095
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 8500
# Macros: define common values, so they can be referenced and changed easily.
ext_if="em0" # replace with actual external interface name i.e., dc0
int_if="em1" # replace with actual internal interface name i.e., dc1
ssh_host="{ 172.16.3.253 }"
web_servers="{ 172.16.3.7 }"
# Tables: Lists of IP Addresses to apply rules to.
table <ineternal_nets> persist file "/etc/internal_nets"
table <NoRouteIP> persist file "/etc/norouteip"
table <Siteip> persist file "/etc/Siteip"
table <badguys> persist file "/etc/badguys"
# Set Optimizations: Set some values to better utilize memory.
set block-policy drop
set limit { frags 5000, states 2500, src-nodes 2000 }
set loginterface $ext_if
set optimization aggressive
set timeout { interval 10, frag 30 }
#Normalization: reassemble fragments and resolve or reduce traffic #ambiguities.
scrub in on $ext_if all fragment reassemble min-ttl 15 max-mss 1400
scrub on $ext_if reassemble tcp
#NAT: Translate to the internal network.
nat on $ext_if from <internal_nets> to any -> $ext_if
#Re-Direct: Re-direct packets to the PDMZ network.
rdr on $ext_if inet proto { tcp, udp } from any to any port 22 -> $ssh_host
rdr on $ext_if inet proto { tcp, udp } from any to any port 80 -> $web_servers
rdr on $ext_if inet proto { tcp, udp } from any to any port 443 -> $web_servers
#Rules: Filter Rules Explanations above each rule.
#Block in Everything by default
block in log on $ext_if all
#Don't allow anyone to spoof unroutable addresses
block in log quick on $ext_if from <NoRouteIP> to any
block out log quick on $ext_if from any to <NoRouteIP>
#Block these badguys
block in log quick on $ext_if inet proto { tcp, udp } from <badguys> to any
#Pass vpn traffic
pass in quick on $ext_if inet proto udp from <Siteip> to $ext_if port = 500 keep state
pass in quick on $ext_if inet proto udp from <Siteip> to $ext_if port = 4500 keep state
pass in quick on $ext_if inet proto esp from <Siteip> to $ext_if keep state
#Pass in ssh
pass in quick on $ext_if proto tcp from any to $ssh_host port = 22 flags S/SA synproxy state
#Pass in Web
pass in quick on $ext_if proto tcp from any to $web_servers port = 80 flags S/SA synproxy state
pass in quick on $ext_if proto tcp from any to $web_servers port = 443 flags S/SA synproxy state
#Default block out
block out log on $ext_if all
#Allow ISAKMP out
pass out quick on $ext_if inet proto udp from $ext_if to <Siteip> port = 500 keep state
pass out quick on $ext_if inet proto udp from $ext_if to <Siteip> port = 4500 keep state
pass out quick on $ext_if inet proto esp from $ext_if to <Siteip> keep state
#Allow SSH out
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = ssh keep state
#Allow WWW
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = www keep state
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = https keep state
#Allow DNS
pass out quick on $ext_if inet proto { udp, udp } from any to any port = domain keep state
#Allow Mail
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 25 keep state
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 465 keep state
#Allow IMAP
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 143 keep state
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 993 keep state
#Allow NNTP
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 119 keep state
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 563 keep state
#Allow NTP
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 123 keep state
#Allow irc
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 194 keep state
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 6667 keep state
#Allow AIM
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 5190 keep state
#Allow REAL Streams
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 554 keep state
#Allow various Poker software ;)
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 2147
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 26229
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 701
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 4095
pass out quick on $ext_if inet proto { tcp, udp } from any to any port = 8500