Linux machines are known to be pretty secure. Macchine Linux sono noti per essere abbastanza sicuro. Studies have shown that Linux has been designed in a secure manner. Gli studi hanno dimostrato che Linux è stato progettato in modo sicuro. 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. Eppure, nonostante tutte le funzioni di sicurezza che vengono forniti con una installazione di Linux, è necessario configurare queste funzioni correttamente per farli lavorare per voi. I’ll guide you through the process of setting up of one of the tools that help secure your machine - the firewall. I'll guida l'utente attraverso il processo di creazione di uno degli strumenti che contribuiscono a garantire la sua macchina - il firewall. We will use the iptables firewall for this exercise. Useremo il firewall iptables per questo esercizio. I am assuming that you are using a server running Red Hat Enterprise Linux 4 or similar. Sono supponendo che si sta utilizzando un server che esegue Red Hat Enterprise Linux 4 o simili. However, most of the steps should work fine on other Linux distributions as well. Tuttavia, la maggior parte delle misure dovrebbe funzionare bene su altre distribuzioni Linux come bene. In this article we will setup a firewall on a Linux server running the Apache Web Server, FTP, and SSH. In questo articolo andremo a installare un firewall su un server che esegue Linux 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. Dobbiamo prima vedere cosa porti queste domande e che l'uso della loro necessità di disporre di una porta aperta sul firewall.
The Apache web server runs on port 80 by default. Il web server Apache eseguito sulla porta 80 per impostazione predefinita. Apache is going to server all our web content on this port, therefore we need to keep this port open on the firewall. Apache è andare a tutti i nostri server i contenuti del sito web su questa porta, quindi abbiamo bisogno di mantenere questa porta aperta sul firewall. The SSH service runs on port 22. Il servizio viene eseguito SSH sulla porta 22. We need to be able to remotely connect to our server to work, so we keep it open. Dobbiamo essere in grado di connettersi in remoto al server per il nostro lavoro, in modo da mantenerlo aperto. FTP runs on port 21 and it too needs the port to be open to communication. FTP viene eseguito sulla porta 21 e si deve anche la porta ad essere aperti alla comunicazione.
Next, make sure you have iptables installed. Quindi, assicurarsi di aver installato iptables. Run this command as the root user: Esegui questo comando come utente 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. Se si dispone di iptables installato il sistema dovrebbe darti la versione di iptables è stato installato. In case you don’t you can try something like the following to get it and start it: Nel caso in cui tu non puoi provare qualcosa come il seguente per farlo e avviarlo:
# yum install iptables # Yum installare iptables
# /etc/init.d/iptables start # / Etc / init.d / iptables start
To check what kind of configuration iptables is currently running with: Per verificare che tipo di configurazione di iptables è attualmente in esecuzione con:
# iptables –list # Iptables-list
Chain INPUT (policy ACCEPT) Catena di INPUT (politica ACCEPT)
target prot opt source destination obiettivo prot opt fonte di destinazione
Chain FORWARD (policy ACCEPT) Catena FORWARD (politica ACCEPT)
target prot opt source destination obiettivo prot opt fonte di destinazione
Chain OUTPUT (policy ACCEPT) Catena OUTPUT (politica ACCEPT)
target prot opt source destination obiettivo prot opt fonte di destinazione
This command will list out all the firewall rules that have been set currently. Questo comando elenco di tutte le regole del firewall che sono stati fissati attualmente. I will proceed with the assumption that you do not have any firewall rules in your iptables configuration. Vorrei procedere con il presupposto che non avete le regole del firewall iptables nella vostra configurazione. 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. Passiamo ora configurare il firewall per consentire una comunicazione aperta sulle porte 80 per il vostro Web server, 22 per SSH, e la porta 21 per FTP. We’ll also make sure that we block communication to any port other than specified. Siamo qui anche assicurarsi che ci bloccare la comunicazione a tutti i porti diversi da quelli specificati.
Here’sa firewall script configuration script. Ecco lo script del firewall script di configurazione. Create a new file and call it iptable-firewall.sh . Creare un nuovo file e chiamarlo iptable-firewall.sh. Copy the following text into it: Copiare il seguente testo in esso:
#!/bin/sh #! / bin / sh
ANY=”0/0″ QUALSIASI = "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) tutte le norme specifiche
iptables -F INPUT iptables-F INPUT
iptables -F FORWARD iptables-F FORWARD
iptables -F OUTPUT iptables-F OUTPUTfor port in $OPEN_PORTS per il porto di $ OPEN_PORTS
do fare
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 $ Any-d $ Any-porto di destinazione $-porto-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 $ Any-d $ Any-porto di destinazione $-porto-syn-j ACCEPT
done fattoiptables -A INPUT -i eth1 -p icmp -s $ANY -d $ANY -j ACCEPT iptables-A INPUT-i eth1-p icmp-s $ Any-d $ Any-j ACCEPT
#Allow any related/established connections # Consenti tutte le relative attività / stabilito connessioni
iptables -A INPUT -i eth0 -m state –state ESTABLISHED,RELATED -j ACCEPT iptables-A INPUT-i eth0-m-stato stato ESTABLISHED, RELATED-j ACCEPT
iptables -A INPUT -i eth1 -m state –state ESTABLISHED,RELATED -j ACCEPT iptables-A INPUT-i eth1-m-stato stato ESTABLISHED, RELATED-j ACCEPT#Kill everything else # Kill tutto il 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 # scrive per l'avvio
iptables-save > /etc/sysconfig/iptables iptables-save> / etc / sysconfig / iptables
Now save the above file, grant it executable permissions and then run it: Ora salvare il file sopra, è eseguibile concedere le autorizzazioni e quindi eseguirlo:
# chmod +x iptable-firewall.sh # Chmod + x iptable-firewall.sh
# ./iptable-firewall.sh #. / Iptable-firewall.sh
Now check your firewall rules: Ora controllare il tuo firewall regole:
# iptables –list # Iptables-list
All your firewall rules should now be set. Tutte le regole del proprio firewall dovrebbe ora essere impostato. Your server is now secure. Il server è ora sicuro. 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. Per effettuare eventuali modifiche o aggiunte a questo insieme di regole, modificare la riga in cui il OPEN_PORTS parametro è definito e aggiungere o rimuovere le porte forma l'elenco. Remember to run the script again after making any changes to it. Ricordarsi di eseguire lo script dopo aver apportato tutte le modifiche ad esso.
If all of this command line stuff has you a bit leery, see the tutorial Se tutto questo roba da riga di comando si ha un po 'leery, vedere il tutorial How to setup Firestarter - an easy to use Linux Firewall Come configurare Firestarter - un facile da usare Linux Firewall - which has an easy to use graphical interface. - Che ha un facile usare l'interfaccia grafica.






















{ 0 comments… (0 commenti ... add one now aggiungere uno ora } )
Leave a Comment Lascia un tuo commento