######################################### Using Jail
# From unixguide.net & FreeBSD forum
#########################################
ext_if = "re0"
int_if = "re1"
jail_b="xx.x.x.xx"
ext_IP = "xxx.xxx.x.x"
dns1 = "xxx.xx.xx.xx"
dhcp = "xxx.xxx.x.255"
icmp_types = "{ 0, 3, 4, 8, 11, 12 }" # allowed ICMP types
ob_state = "flags S/SA modulate state" # outbound
ib_state = "flags S/SA synproxy state" # inbound
# ____________________________________________________________
# [TABLES]
table <sshguard> persist
# ____________________________________________________________
# [OPTIONS]
set loginterface $ext_if # gather statistics on this interface
set optimization aggressive # drop state fast without having excessively low timeouts.
set block-policy return # a TCP RST packet is returned for blocked TCP
# packets and an ICMP Unreachable packet is
# returned for all others. squid
#set block-policy drop # default block behavior to packet silently dropped
set state-policy if-bound # states are bound to interface created on
##set loginterface $_WAN # gather statistics on this interface
set skip on lo0 # KDE uses loopback
# ____________________________________________________________
# [TRAFFIC NORMALIZATION]
#scrub in on $ext_if all reassemble tcp no-df random-id
scrub all no-df random-id min-ttl 5 max-mss 1440 reassemble tcp
scrub out on $ext_if no-df random-id
#scrub in all # scrub out on $ext_if all random-id
#scrub reassemble tcp # Make sure clean & sane fragment reassemble
#block in all
#block out proto { tcp, udp } all # all but a single user
#pass out proto { tcp, udp } all user { < 1000, jer }
# ____________________________________________________________
# [QUEUEING]
# Possible example:
# - altq on fxp0 cbq bandwidth 2Mb queue (std, ssh, ftp)
# ____________________________________________________________
# [TRANLATION]
nat on $ext_if -> $ext_IP # jail_b
pass out on $ext_if inet from {$ext_if, $jail_b} to any keep state # jail_b
##nat on $ext_if from !($ext_if) -> ($ext_if:0) # TRANLATION
pass quick on $int_if all # No restrictions on LAN Interface
pass quick on lo0 all # No restrictions on Loopback Interface
pass in on $int_if inet proto tcp from any to 10.0.0.1 port 8880 keep state
pass out on $ext_if inet proto tcp from any to any port www keep state
pass out on $int_if inet proto tcp from any to 192.168.1.254 port 3389
# ____________________________________________________________
# ____________________________________________________________
# [OUT BOUND]
pass out quick on $ext_if proto tcp from any to $dns1 port 53 $ob_state # dns in resolv
pass out quick on $ext_if proto udp from any to $dns1 port 53 keep state
pass out quick on $ext_if proto udp from any to $dhcp port 67 keep state # dhcp
pass out quick on $ext_if proto tcp from any to any port 80 $ob_state # INTERNET out ****
pass out quick on $ext_if proto tcp from any to any port 443 $ob_state # https over TLS SSL
pass out quick on $ext_if inet proto icmp from any to any icmp-type 8 keep state # ping out
pass out quick on $ext_if proto tcp from any to any port 43 $ob_state # whois PC
pass out quick on $ext_if proto tcp from any to any port 22 $ob_state # SSH FTP-Tel-SCP out
# block out log quick on $ext_if all # trying to get out
# ____________________________________________________________
# ____________________________________________________________
# [IN BOUND]
block in quick on $ext_if from <sshguard> label "ssh bruteforce" # guard all, not just ssh
# Block all inbound traffic from non-routable or reserved address spaces
block in quick on $ext_if from 192.168.0.0/16 to any # RFC 1918 private IP
block in quick on $ext_if from 172.16.0.0/12 to any # RFC 1918 private IP
block in quick on $ext_if from 10.0.0.0/8 to any # RFC 1918 private IP
block in quick on $ext_if from 127.0.0.0/8 to any # loopback
block in quick on $ext_if from 0.0.0.0/8 to any # loopback
block in quick on $ext_if from 169.254.0.0/16 to any # DHCP auto-config
block in quick on $ext_if from 192.0.2.0/24 to any # reserved for doc's
block in quick on $ext_if from 204.152.64.0/23 to any # Sun cluster connect
block in quick on $ext_if from 224.0.0.0/3 to any # Class D $ E multicast
block in quick on $ext_if inet proto icmp all icmp-type 8 # Block public pings in
block in quick on $ext_if proto tcp from any to any port 113 # Block ident in
# Block all Netbios service. 137=name, 138=datagram, 139=session
# Netbios is MS/Windows sharing services.
# Block MS/Windows hosts2 name server requests 81
block in log quick on $ext_if proto tcp from any to any port 137 # $netbios_tcp
block in log quick on $ext_if proto udp from any to any port 137 # $netbios_udp
block in log quick on $ext_if proto tcp from any to any port 138
block in log quick on $ext_if proto udp from any to any port 138
block in log quick on $ext_if proto tcp from any to any port 139
block in log quick on $ext_if proto udp from any to any port 139
block in log quick on $ext_if proto tcp from any to any port 81
block in log quick on $ext_if proto udp from any to any port 81
pass in quick on $ext_if proto udp from $dhcp to any port 68 keep state # cable-DSL-dhcp in
pass in quick on $ext_if inet proto icmp all icmp-type $icmp_types
pass in quick on $ext_if proto tcp from any to any port 22 $ib_state # SSH FTP-Telnet-SCP in
block in log quick on $ext_if all # trying to get in
############################# End of rules file
############################# End of rules file
############################# End of rules file