View Single Post
  #1   (View Single Post)  
Old 24th March 2009
l2fl2f's Avatar
l2fl2f l2fl2f is offline
Real Name: Yves Guerin
Port Guard
 
Join Date: May 2008
Location: Montreal, Quebec, Canada
Posts: 25
Post ipfw ruleset double check

Hello,

I try to configure my ipfw on my fbsd router machine (the one who face my isp)
and I would like to know if my ruleset is good or if my lan is at risk ?


My ipfw ruleset:

Code:
################ Start of IPFW rules file ###############################
# Flush out the list before we begin.
ipfw -q -f flush

# Set rules command prefix
fwcmd="ipfw -q add"
skip="skipto 60000"
pif="rl0"     # public interface name of NIC
              # facing the public Internet
# modif yg
lif="tl0"	# lan interface

# freebsd recup ip
IP=$(/sbin/ifconfig $pif | awk '/inet /{print $2}')

# modif yg
inet="192.168.0.1"

#################################################################
# ipa count
#################################################################

$fwcmd 100 count ip from any to any via $pif in
$fwcmd 200 count ip from any to any via $pif out


#################################################################
# No restrictions on Inside LAN Interface for private network
#################################################################

$fwcmd 500 allow all from any to any via $lif


################################################################
# no ipv6
################################################################

$fwcmd 600 drop log logamount 1 ipv6 from any to any


#################################################################
# No restrictions on Loopback Interface
#################################################################

$fwcmd 1000 allow all from any to any via lo0


#################################################################
# Prevent spoofing
# ou
# Stop spoofing on the outside interface.
# $fwcmd add drop ip from any to any in via $pif not verrevpath
# ou
# Mef utilisation ip localhost
#$fwcmd 0110 drop log all from any to 127.0.0.0/8
#$fwcmd 0120 drop log all from 127.0.0.0/8 to any
#################################################################

$fwcmd 1100 drop log logamount 1 all from any to 127.0.0.0/8
$fwcmd 1200 drop log logamount 1 all from $inet to any in via $pif
$fwcmd 1300 drop log logamount 1 all from not $inet  to any in via $lif


################################################################
# Drop frag
################################################################

$fwcmd 1350 drop all from any to any frag in via $pif


################################################################
# Drop worn nachi
################################################################

$fwcmd 1380 deny log logamount 1 icmp from any to any iplen 92


#################################################################
# check if packet is inbound and nat address if it is
# ou $fwcmd add divert natd all from any to any via $pif
#################################################################

$fwcmd 1400 divert natd ip from any to any in via $pif


#################################################################
# Allow the packet through if it has previous been added to the
# the "dynamic" rules table by a allow keep-state statement.
#################################################################

$fwcmd 1500 check-state


#################################################################
# Interface facing Public Internet (Outbound Section)
# Interrogate session start requests originating from behind the
# firewall on the private network or from this gateway server
# destine for the public Internet.
#################################################################

# Allow out access to my ISP's Domain name server.
# x.x.x.x must be the IP address of your ISP's DNS
# Dup these lines if your ISP has more than one DNS server
# Get the IP addresses from /etc/resolv.conf file
#################################################################

$fwcmd 2000 $skip tcp from any to 24.200.241.37 53 out via $pif setup keep-state
$fwcmd 2001 $skip tcp from any to 24.201.245.77 53 out via $pif setup keep-state
$fwcmd 2002 $skip tcp from any to 24.200.243.189 53 out via $pif setup keep-state

#################################################################
# Allow out access to my ISP's DHCP server for cable/DSL configurations.
#################################################################

$fwcmd 3000 $skip udp from any to 24.200.242.19 67 out via $pif keep-state


#################################################################
# Allow out non-secure standard www function
#################################################################

$fwcmd 4000 $skip tcp from any to any 80 out via $pif setup keep-state


#################################################################
# Allow out secure www function https over TLS SSL
#################################################################

$fwcmd 5000 $skip tcp from any to any 443 out via $pif setup keep-state


#################################################################
# Allow out send & get email function
#################################################################

$fwcmd 6000 $skip tcp from any to any 25 out via $pif setup keep-state
$fwcmd 6100 $skip tcp from any to any 110 out via $pif setup keep-state


#################################################################
# Allow out FreeBSD (make install & CVSUP) functions
# Basically give user root "GOD" privileges.
#################################################################

$fwcmd 7000 $skip tcp from any to any out via $pif setup keep-state uid root
# modif yg pour cvsup
$fwcmd 7100 $skip tcp from any to any 5999 out via $pif setup keep-state

###################################################################
# pour yahoo webcam - Messenger
####################################################################

$fwcmd 7200 $skip all from any to any 5050 out via $pif setup keep-state
$fwcmd 7210 $skip all from any to any 5000-5010 out via $pif setup keep-state
$fwcmd 7220 $skip all from any to any 5100 out via $pif setup keep-state

#$fwcmd 7230 $skip all from any to any 5000-5010 in via $pif setup keep-state
#$fwcmd 7240 $skip all from any to any 5100 in via $pig setup keep-state


#################################################################
# Allow out ping
#################################################################

$fwcmd 8000 $skip icmp from any to any out via $pif keep-state


#################################################################
# Allow out Time
#################################################################

$fwcmd 9000 $skip tcp from any to any 37 out via $pif setup keep-state


#################################################################
# Allow out nntp news (i.e. news groups)
#################################################################

$fwcmd 10000 $skip tcp from any to any 119 out via $pif setup keep-state


#################################################################
# Allow out secure FTP, Telnet, and SCP
# This function is using SSH (secure shell)
# voir regle 55000 sshguard
#################################################################

#$fwcmd 11000 $skip tcp from any to any 22 out via $pif setup keep-state


#################################################################
# Allow out whois
#################################################################

$fwcmd 12000 $skip tcp from any to any 43 out via $pif setup keep-state


#################################################################
# Allow ntp time server
#################################################################

$fwcmd 13000 $skip udp from any to any 123 out via $pif keep-state

##################################################################
# Allow ftp out pour fetch port
# passive_mode=yes
# port 20 et 21 en sortie
# ouvre port 40000-65535 pour client ftp
##################################################################

$fwcmd 14000 $skip tcp from any  to any 20-21 out via $pif setup keep-state
$fwcmd 14100 $skip tcp from any  to any 40000-65535 out via $pif setup keep-state


#################################################################
# Interface facing Public Internet (Inbound Section)
# Interrogate packets originating from the public Internet
# destine for this gateway server or the private network.
#################################################################

#################################################################
# drop all inbound traffic from non-routable reserved address spaces
#################################################################

$fwcmd 30000 drop all from 192.168.0.0/16  to any in via $pif  #RFC 1918 private IP
$fwcmd 30100 drop all from 172.16.0.0/12   to any in via $pif  #RFC 1918 private IP
$fwcmd 30200 drop all from 10.0.0.0/8      to any in via $pif  #RFC 1918 private IP
$fwcmd 30300 drop all from 127.0.0.0/8     to any in via $pif  #loopback
$fwcmd 30400 drop all from 0.0.0.0/8       to any in via $pif  #loopback
$fwcmd 30500 drop all from 169.254.0.0/16  to any in via $pif  #DHCP auto-config
$fwcmd 30600 drop all from 192.0.2.0/24    to any in via $pif  #reserved for docs
$fwcmd 30700 drop all from 204.152.64.0/23 to any in via $pif  #Sun cluster
$fwcmd 30800 drop all from 224.0.0.0/3     to any in via $pif  #Class D & E multicast


#################################################################
# Allow ICMP packets: remove type 8 if you don't want your host
# to be pingable.
#$fwcmd add allow icmp from any to any via $oif icmptypes 0,3,8,11,12
#################################################################

$fwcmd 31000 allow icmp from any to any via $pif icmptypes 0,3,11,12


#################################################################
# drop ident
#################################################################

$fwcmd 31500 drop tcp from any to any 113 in via $pif


#################################################################
# drop all Netbios service. 137=name, 138=datagram, 139=session
# Netbios is MS/Windows sharing services.
# Block MS/Windows hosts2 name server requests 81
#################################################################

# in
$fwcmd 32000 drop tcp from any to any 137 in via $pif
$fwcmd 32100 drop tcp from any to any 138 in via $pif
$fwcmd 32200 drop tcp from any to any 139 in via $pif
$fwcmd 32300 drop tcp from any to any 81  in via $pif

# out
$fwcmd 32010 drop tcp from any to any 137 out via $pif
$fwcmd 32110 drop tcp from any to any 138 out via $pif
$fwcmd 32210 drop tcp from any to any 139 out via $pif
$fwcmd 32310 drop tcp from any to any 81  out via $pif


#################################################################
# drop any late arriving packets
#################################################################

$fwcmd 33000 drop all from any to any frag in via $pif

#################################################################
# drop ACK packets that did not match the dynamic rule table
#################################################################

$fwcmd 33200 drop tcp from any to any established in via $pif


#################################################################
# Allow traffic in from ISP's DHCP server. This rule must contain
# the IP address of your ISP's DHCP server as it's the only
# authorized source to send this packet type.
# Only necessary for cable or DSL configurations.
# This rule is not needed for 'user ppp' type connection to
# the public Internet. This is the same IP address you captured
# and used in the outbound section.
#################################################################

$fwcmd 36000 allow udp from 24.200.242.19 to any 68 in via $pif keep-state


#################################################################
# Allow in standard www function because I have Apache server
#################################################################
#$fwcmd 37000 allow tcp from any to me 80 in via $pif setup limit src-addr 2


#################################################################
# Allow in secure FTP, Telnet, and SCP from public Internet
#################################################################

# 2 coonexion a la fois
# in fact I never use it :)
$fwcmd 38000 allow tcp from any to me 22 in via $pif setup limit src-addr 2


#################################################################
# rejet broadcast
#################################################################

$fwcmd 46000 deny all from any to 255.255.255.255

#################################################################
# de 55000 a 55050 regle pour sshguard
#################################################################

#################################################################
# Allow out secure FTP, Telnet, and SCP
# This function is using SSH (secure shell)
#################################################################

$fwcmd 55100 $skip tcp from any to any 22 out via $pif setup keep-state


#################################################################
# This is skipto location for outbound stateful rules
#################################################################

$fwcmd 60000 divert natd ip from any to any out via $pif
$fwcmd 60100 allow ip from any to any
Thank you in advance for your help and for your time you spend to help me
Reply With Quote