Getting started with iptables in Linux Erste Schritte mit iptables unter Linux

by Sukrit Dhandhania on December 8, 2008 von Sukrit Dhandhania am 8. Dezember 2008

LinuxSecurity

Linux machines are known to be pretty secure. Linux-Maschinen sind bekannt ist, dass sie ziemlich sicher. Studies have shown that Linux has been designed in a secure manner. Studien haben gezeigt, dass Linux wurde in eine sichere Form. 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. Dennoch, trotz aller Sicherheits-Features, die kommen im Paket mit einer Linux-Installation zu können, benötigen Sie die Konfiguration dieser Features korrekt, damit sie arbeiten für Sie. I’ll guide you through the process of setting up of one of the tools that help secure your machine - the firewall. Ich werde Sie durch den Prozess der Einrichtung eines der Instrumente, mit deren Hilfe Sichern Sie Ihre Maschine - die Firewall. We will use the iptables firewall for this exercise. Wir werden die iptables-Firewall für diese Übung. I am assuming that you are using a server running Red Hat Enterprise Linux 4 or similar. Ich gehe davon aus, dass Sie mit einem Server unter Red Hat Enterprise Linux 4 oder ähnlich. However, most of the steps should work fine on other Linux distributions as well. Die meisten der Schritte sollten aber funktionieren, auf anderen Linux-Distributionen wie gut. In this article we will setup a firewall on a Linux server running the Apache Web Server, FTP, and SSH. In diesem Artikel werden wir ein Setup-Firewall auf einem Linux-Server mit dem Apache Web Server, FTP-und SSH.

Let us first see what ports these applications use and which of them need to have a port open on the firewall. Lassen Sie uns zuerst sehen, welche Ports diese Anwendungen verwenden und die von ihnen müssen einen Port in der Firewall geöffnet ist.

The Apache web server runs on port 80 by default. Der Apache Web-Server läuft auf Port 80 standardmäßig aktiviert. Apache is going to server all our web content on this port, therefore we need to keep this port open on the firewall. Apache wird zum Server alle unsere Web-Inhalte auf diesem Port, also wir müssen dafür sorgen, dass dieser Port in der Firewall geöffnet ist. The SSH service runs on port 22. Die SSH-Dienst läuft auf Port 22. We need to be able to remotely connect to our server to work, so we keep it open. Wir müssen in der Lage sein remote Verbindung zu unserem Server zu arbeiten, so halten wir es offen. FTP runs on port 21 and it too needs the port to be open to communication. FTP läuft auf Port 21, und es muss auch die Port zu öffnen, um die Kommunikation.

Next, make sure you have iptables installed. Weiter, stellen Sie sicher, dass iptables installiert. Run this command as the root user: Führen Sie diesen Befehl als "root"-Benutzer:

# 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. Wenn Sie iptables installiert das System sollte Ihnen die Version von iptables Sie installiert haben. In case you don’t you can try something like the following to get it and start it: Im Fall, dass Sie nicht können Sie versuchen, so etwas wie den folgenden, um es und starten Sie ihn:

# yum install iptables # Yum installieren iptables

# /etc/init.d/iptables start # / Etc / init.d / iptables start

To check what kind of configuration iptables is currently running with: Um zu überprüfen, welche Art von iptables-Konfiguration läuft bereits mit:

# iptables –list # Iptables-Liste
Chain INPUT (policy ACCEPT) Chain INPUT (policy ACCEPT)
target prot opt source destination Ziel prot opt Quelle Ziel

Chain FORWARD (policy ACCEPT) Chain FORWARD (policy ACCEPT)
target prot opt source destination Ziel prot opt Quelle Ziel

Chain OUTPUT (policy ACCEPT) Chain OUTPUT (policy ACCEPT)
target prot opt source destination Ziel prot opt Quelle Ziel

This command will list out all the firewall rules that have been set currently. Dieser Befehl listet alle für die Firewall-Regeln, die derzeit gesetzt. I will proceed with the assumption that you do not have any firewall rules in your iptables configuration. Ich werde mit der Annahme, dass Sie keine Firewall-Regeln in Ihrem iptables-Konfiguration. 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. Laßt uns jetzt konfigurieren Sie die Firewall zu ermöglichen offene Kommunikation über die Ports 80 für Ihre Web-Server, 22 für SSH, und Port 21 für FTP. We’ll also make sure that we block communication to any port other than specified. Wir werden auch dafür sorgen, dass wir Block-Kommunikation zu jedem Hafen andere als angegeben.

Here’sa firewall script configuration script. Hier ist eine Firewall-Skript Konfigurations-Skript. Create a new file and call it iptable-firewall.sh . Erstellen Sie eine neue Datei und nennen es iptable-firewall.sh. Copy the following text into it: Kopieren Sie den folgenden Text hinein:

#!/bin/sh #! / bin / sh

ANY=”0/0″ ANY = "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) alle besonderen Vorschriften
iptables -F INPUT iptables-F INPUT
iptables -F FORWARD iptables-F FORWARD
iptables -F OUTPUT iptables-F OUTPUT

for port in $OPEN_PORTS for PORT in $ OPEN_PORTS
do tun
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-Ziel-Port $ port-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-Ziel-Port $ port-syn-j ACCEPT
done getan

iptables -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 # Lassen Sie jede damit verbundene / aufgebauten Verbindungen
iptables -A INPUT -i eth0 -m state –state ESTABLISHED,RELATED -j ACCEPT iptables-A INPUT-i eth0-m state-Staat, RELATED-j ACCEPT
iptables -A INPUT -i eth1 -m state –state ESTABLISHED,RELATED -j ACCEPT iptables-A INPUT-i eth1-m state-Staat, RELATED-j ACCEPT

#Kill everything else # Kill alles andere
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 # schreiben für Boot -
iptables-save > /etc/sysconfig/iptables iptables-save> / etc / sysconfig / iptables

Now save the above file, grant it executable permissions and then run it: Speichern Sie nun die oben angegebenen Datei, gewähren sie ausführbare Berechtigungen und führen Sie sie aus:

# chmod +x iptable-firewall.sh # Chmod + x iptable-firewall.sh

# ./iptable-firewall.sh #. / Iptable-firewall.sh

Now check your firewall rules: Nun überprüfen Sie Ihre Firewall-Regeln:

# iptables –list # Iptables-Liste

All your firewall rules should now be set. Alle Ihre Firewall-Regeln sollten nun gesetzt werden. Your server is now secure. Ihr Server ist jetzt sicher. 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. Um etwaige Änderungen oder Ergänzungen zu diesem Satz von Regeln, bearbeiten Sie die Zeile, wo die OPEN_PORTS Parameter definiert ist und hinzuzufügen oder zu entfernen Häfen bilden die Liste. Remember to run the script again after making any changes to it. Denken Sie daran, das Skript zu starten, erneut, nachdem Sie Änderungen daran.

If all of this command line stuff has you a bit leery, see the tutorial Wenn alle diese Befehlszeile Zeug hat man ein bisschen misstrauisch, finden Sie im Tutorial How to setup Firestarter - an easy to use Linux Firewall Wie man Firestarter - eine einfach zu bedienende Linux-Firewall - which has an easy to use graphical interface. - Die hat eine einfach zu bedienende grafische Oberfläche.

Related Posts: Verwandte Einträge:
  • How to set up Evolution for email Wie richtet man einen Evolution für E-Mail
  • How to send email from the Linux command line Wie versende ich E-Mail von der Linux-Befehlszeile
  • How to install, setup and use Google Desktop Search in Ubuntu Wie installiert man, Einrichtung und Nutzung von Google Desktop Search in Ubuntu
  • How to install Windows programs in Linux using Wine Wie installiert man Windows-Programmen unter Linux mit Wine
  • How to play .rmvb files in Ubuntu Wie spiele ich. RMVB Dateien in Ubuntu
  • Get Simple Help tutorials just like this one in your email inbox every day - for free! Holen Sie sich Einfache Hilfe Tutorials wie diese ein in Ihrem E-Mail-Posteingang jeden Tag - gratis! Just enter your email address below: Geben Sie einfach Ihre E-Mail-Adresse unten ein:

    You can always opt out of this email subscription at any time. Sie können immer Opt-out in dieser E-Mail-Abonnement zu jeder Zeit.


    Bookmark and Share Lesezeichen und Aktie

    { 0 comments… (0 Kommentare ... add one now Add jetzt ein } )

    Leave a Comment Schreibe einen Kommentar

    You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> Sie können diese HTML-Tags und Attribute: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>