Linux machines are known to be pretty secure. Máquinas Linux são conhecidas por serem bastante segura. Studies have shown that Linux has been designed in a secure manner. Estudos têm mostrado que o Linux foi desenhado de uma 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. No entanto, apesar de todas as funções de segurança que vêm empacotados com uma instalação do Linux, você precisará configurar corretamente esses recursos para fazê-los trabalhar para você. I’ll guide you through the process of setting up of one of the tools that help secure your machine - the firewall. Eu vou te guiar através do processo de criação de uma das ferramentas que ajudam a garantir a sua máquina - o firewall. We will use the iptables firewall for this exercise. Iremos usar o firewall iptables para este exercício. I am assuming that you are using a server running Red Hat Enterprise Linux 4 or similar. Eu estou supondo que você está usando um servidor executando o Red Hat Enterprise Linux 4 ou similar. However, most of the steps should work fine on other Linux distributions as well. No entanto, a maior parte das etapas deve funcionar bem em outras distribuições de Linux também. In this article we will setup a firewall on a Linux server running the Apache Web Server, FTP, and SSH. Neste artigo iremos configurar um firewall em um servidor Linux executando o Apache Web Server, FTP e SSH.
Let us first see what ports these applications use and which of them need to have a port open on the firewall. Vamos primeiro ver o que esses aplicativos utilizam portos e qual deles precisa ter uma porta aberta no firewall.
The Apache web server runs on port 80 by default. O servidor Web Apache é executado na porta 80 por padrão. Apache is going to server all our web content on this port, therefore we need to keep this port open on the firewall. Servidor Apache está indo para todos os nossos conteúdos web sobre esta porta, por isso temos de manter essa porta aberta no firewall. The SSH service runs on port 22. O serviço SSH é executado na porta 22. We need to be able to remotely connect to our server to work, so we keep it open. Precisamos de ser capazes de ligar remotamente ao nosso servidor ao trabalho, por isso, mantê-la aberta. FTP runs on port 21 and it too needs the port to be open to communication. FTP é executado na porta 21 e ele também precisa ser aberta a porta para a comunicação.
Next, make sure you have iptables installed. Em seguida, verifique se você tem iptables instalado. Run this command as the root user: Executar este comando como o usuário raiz:
# 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. Se você tiver iptables instalado o sistema deve dar a você a versão do iptables que tem instalado. In case you don’t you can try something like the following to get it and start it: No caso, você não pode tentar algo como o seguinte para buscá-la e ele iniciar:
# yum install iptables # Yum instala iptables
# /etc/init.d/iptables start # / Etc / init.d / iptables começar
To check what kind of configuration iptables is currently running with: Para verificar qual é o tipo de configuração está actualmente a correr com o iptables:
# iptables –list # Iptables-list
Chain INPUT (policy ACCEPT) Cadeia INPUT (política ACEITAR)
target prot opt source destination target prot opt fonte destino
Chain FORWARD (policy ACCEPT) Cadeia FORWARD (política ACEITAR)
target prot opt source destination target prot opt fonte destino
Chain OUTPUT (policy ACCEPT) Cadeia OUTPUT (política ACEITAR)
target prot opt source destination target prot opt fonte destino
This command will list out all the firewall rules that have been set currently. Este comando irá listar todos fora do firewall regras que foram estabelecidas atualmente. I will proceed with the assumption that you do not have any firewall rules in your iptables configuration. Vou prosseguir com o pressuposto de que você não tem quaisquer regras de firewall em sua configuração iptables. 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. Vamos agora configurar o firewall para permitir a comunicação aberta sobre as portas 80 para o servidor web, 22 para SSH, ea porta 21 para FTP. We’ll also make sure that we block communication to any port other than specified. Iremos também certifique-se de que a comunicação bloquear qualquer outra porta que não especificou.
Here’sa firewall script configuration script. Aqui o script configuração de firewall script. Create a new file and call it iptable-firewall.sh . Crie um novo arquivo e chamá-la iptable-firewall.sh. Copy the following text into it: Copie o seguinte texto nele:
#!/bin/sh #! / bin / sh
ANY=”0/0″ QUALQUER = "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 as regras específicas
iptables -F INPUT iptables-F INPUT
iptables -F FORWARD iptables-F FORWARD
iptables -F OUTPUT iptables-F OUTPUTfor port in $OPEN_PORTS porta para um total de R $ OPEN_PORTS
do fazer
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-d $ $ QUALQUER QUALQUER-destino de porta $ porta-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-d $ $ QUALQUER QUALQUER-destino de porta $ porta-syn-j ACCEPT
done feitoiptables -A INPUT -i eth1 -p icmp -s $ANY -d $ANY -j ACCEPT iptables-A INPUT-i eth1-p ICMP-s-d $ $ QUALQUER QUALQUER-j ACCEPT
#Allow any related/established connections # Permitir que qualquer afins / estabelecidas conexões
iptables -A INPUT -i eth0 -m state –state ESTABLISHED,RELATED -j ACCEPT iptables-A INPUT-i eth0-m Estado-Membro estabelecido, AFINS-j ACCEPT
iptables -A INPUT -i eth1 -m state –state ESTABLISHED,RELATED -j ACCEPT iptables-A INPUT-i eth1-m Estado-Membro estabelecido, AFINS-j ACCEPT#Kill everything else # Matar tudo o resto
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 # escrever para o arranque
iptables-save > /etc/sysconfig/iptables iptables-save> / etc / sysconfig / iptables
Now save the above file, grant it executable permissions and then run it: Agora salve o arquivo acima, dotá-lo executável permissões e, em seguida, execute-o:
# chmod +x iptable-firewall.sh # Chmod + x iptable-firewall.sh
# ./iptable-firewall.sh #. / Iptable-firewall.sh
Now check your firewall rules: Agora verifique suas regras de firewall:
# iptables –list # Iptables-list
All your firewall rules should now be set. Todas as regras do firewall deve ser agora fixada. Your server is now secure. O servidor agora está seguro. 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 fazer qualquer alteração ou aditamentos a este conjunto de regras, modificar a linha quando o parâmetro é definido OPEN_PORTS e adicionar ou remover portas formam a lista. Remember to run the script again after making any changes to it. Lembre-se de executar o script novamente depois de efectuar quaisquer alterações à mesma.
If all of this command line stuff has you a bit leery, see the tutorial Se essa linha de comando de todas as coisas que você tem um pouco ardiloso, veja o tutorial How to setup Firestarter - an easy to use Linux Firewall Como se configura Firestarter - um fácil de usar o Linux Firewall - which has an easy to use graphical interface. - Que tem uma interface gráfica fácil de usar.






















{ 0 comments… (0 comentários ... add one now adicionar um agora } )
Leave a Comment Deixe um comentário