Instalar IPFIREWALL en FreeBSD
Para darle un poco de protección a nuestro FreeBSD es recomendable instalarle un Firewall para que proteja las entradas y salidas de la red.
Para instalarlo vamos a copiar el kernel GENERICOy agregarle algunas líneas para habilitar el IPFIREWALL.
# cd /usr/src/sys/i386/conf
# cp GENERIC ALFREKNET
# ee ALFREKNET
Ahora vamos a agregar las siguientes lineas a nuestro Kernel:
options IPFIREWALL # requerido para el IPFW
options IPFIREWALL_VERBOSE # Opcional, para logs
options IPFIREWALL_VERBOSE_LIMIT = 10 # Opcional para no tener muchos registros en el log
options IPDIVERT # NECESARIO para el NATD
Checamos la configuración y luego instalamos nuestro kernel
# config ALFREKNET
# cd ../compile/ALFREKNET
# make cleandepend && make depend
# make
# make install
Luego de terminar el proceso de compilación vamos a reiniciar el sistema para que arranque con el nuevo kernel.
Ahora vamos a editar el /etc/rc.conf para habilitar nuestro firewall y agregamos las siguientes lineas:
firewall_enable="YES"
firewall_script="/usr/local/etc/ipfw.rules"
Ahora vamos a necesitar crear las reglas para nuestro firewall, para eso editamos el archive /usr/local/etc/ipfw.rules y agregamos las siguientes lineas:
IPF=”ipfw -q add”
ipfw -q -f flush
$IPF 10 allow all from any to any via be1
$IPF 20 deny all from any to 127.0.0.0/8
$IPF 30 deny all from 127.0.0.0/8 to any
$IPF 40 deny tcp from any to any frag
#stateful
$IPF 50 check-state
$IPF 60 allow tcp from any to any established
$IPF 70 allow all from any to any out keep-state
$IPF 80 allow icmp from any to any
# Abrimos puertos FTP (21) SSH (22) HTTP (80) DNS (53)
$IPF 110 allow tcp from any to any 21 in
$IPF 120 allow tcp from any to any 21 out
$IPF 130 allow tcp from any to any 22 in
$IPF 140 allow tcp from any to any 22 out
$IPF 170 allow udp from any to any 53 in
$IPF 175 allow tcp from any to any 53 in
$IPF 180 allow udp from any to any 53 out
$IPF 185 allow tcp from any to any 53 out
$IPF 200 allow tcp from any to any 80 in
$IPF 210 allow tcp from any to any 80 out
# niega y loguea todo
$IPF 500 deny log all from any to any
Ahora vamos a actualizar nuestro firewall con las nuevas reglas, para esto ejecutaremos el siguiente comando:
# /usr/local/etc/ipfw.rules
Nota: Una vez completado el proceso tendremos nuestro FreeBSD con todos los demás puertos cerrados ya sea para entrada y salida de paquetes.
Espero que les ayude en algo este articulo.
Start Slide Show with PicLens Lite

