Linux machines are known to be pretty secure. Máquinas Linux son conocidos por ser muy seguro. Studies have shown that Linux has been designed in a secure manner. Los estudios han demostrado que Linux ha sido diseñado en forma segura. Yet, despite all the security features that come bundled with a Linux installation, you need to configure these features correctly to make them work for you. Sin embargo, a pesar de todas las características de seguridad que vienen con un paquete de instalación de Linux, lo que necesita para configurar correctamente estas características para hacer que funcionen para usted. I’ll guide you through the process of setting up of one of the tools that help secure your machine - the firewall. Yo le guiará a través del proceso de creación de una de las herramientas que ayudan a garantizar su máquina - el servidor de seguridad. We will use the iptables firewall for this exercise. Vamos a utilizar el firewall iptables para este ejercicio. I am assuming that you are using a server running Red Hat Enterprise Linux 4 or similar. Estoy suponiendo que usted está usando un servidor ejecutando Red Hat Enterprise Linux 4 o similar. However, most of the steps should work fine on other Linux distributions as well. Sin embargo, la mayoría de los pasos que debería funcionar bien en otras distribuciones de Linux también. In this article we will setup a firewall on a Linux server running the Apache Web Server, FTP, and SSH. En este artículo vamos a configurar un servidor de seguridad en un servidor Linux corriendo el servidor web Apache, FTP y SSH.
Let us first see what ports these applications use and which of them need to have a port open on the firewall. Vamos a ver primero lo que los puertos de estas aplicaciones y el uso que de ellos necesitan tener un puerto abierto en el firewall.
The Apache web server runs on port 80 by default. El servidor web Apache se ejecuta en el puerto 80 por defecto. Apache is going to server all our web content on this port, therefore we need to keep this port open on the firewall. Apache es el servidor va a todo nuestro contenido web en este puerto, por lo tanto, necesidad de mantener este puerto abierto en el firewall. The SSH service runs on port 22. El servicio SSH se ejecuta en el puerto 22. We need to be able to remotely connect to our server to work, so we keep it open. Tenemos que ser capaces de conectarse remotamente a nuestro servidor para trabajar, por lo que mantenerla abierta. FTP runs on port 21 and it too needs the port to be open to communication. FTP se ejecuta en el puerto 21 y que también necesita el puerto de estar abierto a la comunicación.
Next, make sure you have iptables installed. A continuación, asegúrese de tener instalado iptables. Run this command as the root user: Ejecutar este comando como el usuario root:
# rpm -qa | grep iptables # Rpm-qa | grep iptables
If you have iptables installed the system should give you the version of iptables you have installed. Si usted tiene iptables instalado el sistema debe dar la versión de iptables que tiene instalada. In case you don’t you can try something like the following to get it and start it: En caso de que no puede intentar algo como lo siguiente para conseguirlo y empezar a que:
# yum install iptables # Yum instalar iptables
# /etc/init.d/iptables start # / Etc / init.d / iptables inicio
To check what kind of configuration iptables is currently running with: Para comprobar qué tipo de configuración de iptables se está ejecutando actualmente con:
# iptables –list # Iptables-lista
Chain INPUT (policy ACCEPT) Cadena INPUT (política ACEPTA)
target prot opt source destination objetivo prot optar origen destino
Chain FORWARD (policy ACCEPT) Cadena FORWARD (política ACEPTA)
target prot opt source destination objetivo prot optar origen destino
Chain OUTPUT (policy ACCEPT) Cadena OUTPUT (política ACEPTA)
target prot opt source destination objetivo prot optar origen destino
This command will list out all the firewall rules that have been set currently. Este comando lista todas las reglas del cortafuegos que se han establecido actualmente. I will proceed with the assumption that you do not have any firewall rules in your iptables configuration. Voy a proceder con la suposición de que usted no tiene reglas de firewall iptables en su configuración. Let’s now configure the firewall to allow open communication on the ports 80 for your web server, 22 for SSH, and port 21 for FTP. Ahora vamos a configurar el firewall para permitir una comunicación abierta sobre los puertos 80 para su servidor web, 22 para SSH, y el puerto 21 para FTP. We’ll also make sure that we block communication to any port other than specified. También daremos por asegurarnos de que bloquear las comunicaciones a un puerto distinto al especificado.
Here’sa firewall script configuration script. He aquí un script de firewall secuencia de comandos de configuración. Create a new file and call it iptable-firewall.sh . Crear un archivo nuevo y lo llaman iptable-firewall.sh. Copy the following text into it: Copie el texto siguiente en él:
#!/bin/sh #! / bin / sh
ANY=”0/0″ CUALQUIER = "0 / 0"
OPEN_PORTS=”21 22 80″ OPEN_PORTS = "21 22 80"iptables -P INPUT ACCEPT iptables-P INPUT ACCEPT
iptables -P FORWARD ACCEPT iptables-P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT iptables-P OUTPUT ACCEPT# Flush (-F) all specific rules # Flush (-F) todas las normas específicas
iptables -F INPUT iptables-F INPUT
iptables -F FORWARD iptables-F FORWARD
iptables -F OUTPUT iptables-F SALIDAfor port in $OPEN_PORTS de puerto en $ OPEN_PORTS
do hacer
iptables -A INPUT -i eth0 -p tcp -s $ANY -d $ANY –destination-port $port –syn -j ACCEPT iptables-A INPUT-i eth0-p tcp-s $ CUALQUIER-d $ CUALQUIER-destino-puerto $ puerto-SYN-j ACCEPT
iptables -A INPUT -i eth1 -p tcp -s $ANY -d $ANY –destination-port $port –syn -j ACCEPT iptables-A INPUT-i eth1-p tcp-s $ CUALQUIER-d $ CUALQUIER-destino-puerto $ puerto-SYN-j ACCEPT
done hechoiptables -A INPUT -i eth1 -p icmp -s $ANY -d $ANY -j ACCEPT iptables-A INPUT-i eth1-p icmp-s $ CUALQUIER-d $ CUALQUIER-j ACCEPT
#Allow any related/established connections # Permitir cualquier conexas / establecido conexiones
iptables -A INPUT -i eth0 -m state –state ESTABLISHED,RELATED -j ACCEPT iptables-A INPUT-i eth0-m state-state ESTABLISHED, RELATED-j ACCEPT
iptables -A INPUT -i eth1 -m state –state ESTABLISHED,RELATED -j ACCEPT iptables-A INPUT-i eth1-m state-state ESTABLISHED, RELATED-j ACCEPT#Kill everything else # Kill todo lo demás
iptables -A INPUT -i eth0 -j DROP iptables-A INPUT-i eth0-j DROP
iptables -A INPUT -i eth1 -j DROP iptables-A INPUT-i eth1-j DROP#write for boot # escribir para arrancar
iptables-save > /etc/sysconfig/iptables iptables-guardar> / etc / sysconfig / iptables
Now save the above file, grant it executable permissions and then run it: Ahora, guarde el archivo mencionado, conceder permisos de ejecutable y, a continuación, ejecutarlo:
# chmod +x iptable-firewall.sh # Chmod + x-iptable firewall.sh
# ./iptable-firewall.sh #. / Iptable-firewall.sh
Now check your firewall rules: Ahora, comprueba tu firewall reglas:
# iptables –list # Iptables-lista
All your firewall rules should now be set. Todas sus reglas de firewall debe ser ahora. Your server is now secure. Su servidor es seguro ahora. To make any modification or additions to this set of rules, edit the line where the OPEN_PORTS parameter is defined and add or remove ports form the list. Para realizar cualquier modificación o adición a este conjunto de normas, editar la línea donde la OPEN_PORTS parámetro se define y agregar o quitar puertos de la lista. Remember to run the script again after making any changes to it. Recuerde que debe ejecutar la secuencia de comandos después de realizar cualquier cambio a ella.
If all of this command line stuff has you a bit leery, see the tutorial Si todos los de esta línea de comandos tiene cosas que desconfío un poco, ver el tutorial How to setup Firestarter - an easy to use Linux Firewall ¿Cómo configurar Firestarter - un fácil utilizar el Firewall de Linux - which has an easy to use graphical interface. - Que tiene un fácil utilizar el interfaz gráfico.






















{ 0 comments… (0 comentarios ... add one now añadir ahora una } )
Leave a Comment Déjanos tu comentario