myGully.com Boerse.SH - BOERSE.AM - BOERSE.IO - BOERSE.IM Boerse.BZ .TO Nachfolger
Zurück   myGully.com > Computer & Technik > Linux & BSD
Seite neu laden

Iptables

Willkommen

myGully

Links

Forum

 
Antwort
Themen-Optionen Ansicht
Ungelesen 15.05.11, 19:36   #1
max_b
Linux-Lerner
 
Registriert seit: May 2011
Beiträge: 5
Bedankt: 1
max_b ist noch neu hier! | 0 Respekt Punkte
Standard Iptables

Hi

ich habe im Internet nicht wirklich das gefunden was ich brauche, sondern nur Seitenlange Texte die mir nur mäßig weitergeholfen haben.
Ich habe verschiedene Regeln eingetragen aber entweder ist alles offen oder ich sperre mich komplett aus, dann hilft nur noch der Stromschalter^^
Villeicht könnt ihr mir hier weiterhelfen:

Ein Debian-System soll ALLE Ports nach aussen zu haben ausser Port 12345 (nehmen wir mal an dadrauf läuft SSH).
Intern (lo) soll/kann alles offen sein.

Wie muss ich nun die IPTABLES-Regeln stellen damit ich dies bezwecke und nur noch via Port 12345 (also via SSH) auf den Server komme ?

Die anderen Regeln kann ich ja dann dann daraus ableiten.

THX im Voraus

PS: ifconfig spuckt mir eth0 (Netzwerkkarte) und lo (loopback) aus.
max_b ist offline   Mit Zitat antworten
Ungelesen 15.05.11, 20:06   #2
spartan-b292
Echter Freak
 
Benutzerbild von spartan-b292
 
Registriert seit: Mar 2010
Ort: /home/spartan-b292
Beiträge: 2.856
Bedankt: 1.701
spartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punktespartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punktespartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punktespartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punktespartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punktespartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punktespartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punktespartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punktespartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punktespartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punktespartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punkte
Standard

Das müsste ca so aussehen:
Code:
iptables -A INPUT -i eth0 -p tcp --dport 12345 -j ACCEPT
iptables -A OUTPUT -i eth0 -p tcp --sport 12345 -j ACCEPT
Für externen Traffic über eth0.

Um intern alles offen zu lassen müsste das ca so aussehen:

Code:
iptables -A INPUT -i lo -s 0/0 -d 0/0 -j ACCEPT
Danach die Regeln noch anwenden mit
Code:
/sbin/iptables -F INPUT
/sbin/iptables -F OUTPUT
__________________
"They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety"
spartan-b292 ist offline   Mit Zitat antworten
Ungelesen 15.05.11, 20:09   #3
max_b
Linux-Lerner
 
Registriert seit: May 2011
Beiträge: 5
Bedankt: 1
max_b ist noch neu hier! | 0 Respekt Punkte
Standard

thx
aber noch eine Sache: wie schliesse ich denn die restlichen Ports ?
max_b ist offline   Mit Zitat antworten
Ungelesen 15.05.11, 20:19   #4
spartan-b292
Echter Freak
 
Benutzerbild von spartan-b292
 
Registriert seit: Mar 2010
Ort: /home/spartan-b292
Beiträge: 2.856
Bedankt: 1.701
spartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punktespartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punktespartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punktespartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punktespartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punktespartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punktespartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punktespartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punktespartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punktespartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punktespartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punkte
Standard

Zunächst mal Buchtipp:
Linux Firewall mit Iptables & Co (Gibt es glaube ich auch hier in der Börse)

Alles andere verbietest du indem du die Default Policy setzt:
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP

Damit "Dropst" du alle Pakete, außer die die du explizit erlaubt hast.
__________________
"They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety"
spartan-b292 ist offline   Mit Zitat antworten
Ungelesen 15.05.11, 20:22   #5
max_b
Linux-Lerner
 
Registriert seit: May 2011
Beiträge: 5
Bedankt: 1
max_b ist noch neu hier! | 0 Respekt Punkte
Standard

jo genau so 1 zu 1 hab ich auch alles probiert und SSH is zu ^^

und dann hab ich hier ins Forum geschrieben
max_b ist offline   Mit Zitat antworten
Ungelesen 15.05.11, 20:25   #6
spartan-b292
Echter Freak
 
Benutzerbild von spartan-b292
 
Registriert seit: Mar 2010
Ort: /home/spartan-b292
Beiträge: 2.856
Bedankt: 1.701
spartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punktespartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punktespartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punktespartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punktespartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punktespartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punktespartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punktespartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punktespartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punktespartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punktespartan-b292 leckt gerne myGully Deckel in der Kanalisation! | 230828 Respekt Punkte
Standard

Ich hab [ Link nur für registrierte Mitglieder sichtbar. Bitte einloggen oder neu registrieren ] noch was gefunden was genau das Szenario beschreibt. Vllt hilft dir das ja weiter.
__________________
"They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety"
spartan-b292 ist offline   Mit Zitat antworten
Ungelesen 15.05.11, 20:31   #7
max_b
Linux-Lerner
 
Registriert seit: May 2011
Beiträge: 5
Bedankt: 1
max_b ist noch neu hier! | 0 Respekt Punkte
Standard

richtig wenn ich das hier so in eine test.sh schreibe:

#!/bin/sh
# My system IP/set ip address of server
SERVER_IP="XXX.XXX.XXX.XXX"
# Flushing all rules
iptables -F
iptables -X
# Setting default filter policy
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
# Allow unlimited traffic on loopback
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
# Allow incoming ssh only
iptables -A INPUT -p tcp -s 0/0 -d $SERVER_IP --sport 513:65535 --dport 12345 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp -s $SERVER_IP -d 0/0 --sport 12345 --dport 513:65535 -m state --state ESTABLISHED -j ACCEPT
# make sure nothing comes or goes out of this box
iptables -A INPUT -j DROP
iptables -A OUTPUT -j DROP

und das ausführe als root: ./test.sh
dann ist die SSH-Verbindung weg und ich kome via SSH nicht mehr auf den Server
max_b ist offline   Mit Zitat antworten
Ungelesen 16.05.11, 19:24   #8
max_b
Linux-Lerner
 
Registriert seit: May 2011
Beiträge: 5
Bedankt: 1
max_b ist noch neu hier! | 0 Respekt Punkte
Standard

so ich habs jetzt sleber hinbekommen^^

iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
iptables -A INPUT -i lo -s 0/0 -d 0/0 -j ACCEPT
iptables -A OUTPUT -o lo -s 0/0 -d 0/0 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --dport 12345 -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --sport 12345 -j ACCEPT

so is alles zu (intern alles offen) und es geht nur noch Port 12345 (hier mal SSH) nach aussen^^
max_b ist offline   Mit Zitat antworten
Ungelesen 28.08.11, 00:11   #9
melo
Anfänger
 
Registriert seit: Jul 2009
Beiträge: 3
Bedankt: 21
melo ist noch neu hier! | 0 Respekt Punkte
Standard

spartan

do you have any step for step explination that how to install and work with Iptables also with picture

many thanks and I appreciated sorry for my bad english
melo ist offline   Mit Zitat antworten
Ungelesen 10.09.11, 10:12   #10
q23p
Anfänger
 
Benutzerbild von q23p
 
Registriert seit: Jan 2010
Beiträge: 33
Bedankt: 41
q23p ist noch neu hier! | 0 Respekt Punkte
Standard

Eng: Depending on your distribution it is preinstalled, otherwise use the package manager of your distribution.
then you have to write man iptables.

Ger: Abhängig von deiner Distribution ist es vorinstalliert, anderenfalls benutze den Paketmanager deiner Distribution.
Dann musst du noch man iptables schreiben.

__________________
Der Beitrag gefällt dir? Ich freue mich über jedes Dankeschön !
q23p ist offline   Mit Zitat antworten
Ungelesen 10.09.11, 17:21   #11
melo
Anfänger
 
Registriert seit: Jul 2009
Beiträge: 3
Bedankt: 21
melo ist noch neu hier! | 0 Respekt Punkte
Standard

wow q23p many thanks man I really Appreicated
Iam using Redhat Linux Server version 6
melo ist offline   Mit Zitat antworten
Antwort


Forumregeln
Du kannst keine neue Themen eröffnen
Du kannst keine Antworten verfassen
Du kannst keine Anhänge posten
Du kannst nicht deine Beiträge editieren

BB code is An
Smileys sind An.
[IMG] Code ist An.
HTML-Code ist Aus.

Gehe zu


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:27 Uhr.


Sitemap

().