[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Konfiguration von iptables



Am Dienstag, den 01.10.2013, 15:07 +0200 schrieb Johannes C. Schulz:
> Hallo Debian-Freunde
> 
> Ich konfiguriere mich nun erstmal durch iptables durch. Ehe ich nun alles
> komplett kaputtmache, wollte ich erstmal ein paar Wissende fragen, ob die
> iptables-Konfig so ok geht. Voran möchte ich anmerken, daß ich nfs auf die
> Ports 32765, 23766, 32767 und 32769 fest konfiguriert habe.
> 
> Der Server hat zwei Netzwerkkarten. Dieses iptables soll nur eth0
> konfigurieren. eth1 ist als bridge0 konfiguriert. An bridge0 hängen die
> ganzen VMs. Wie ich gelesen habe, muß ja das dann per ebtables
> "abgesichert" werden.
> 
> und nun der iptables-kram für eth0:
> 
> *filter
> #
> # Allows all loopback (lo0) traffic and drop all traffic to 127/8 that
> doesn't $
> -A INPUT -i lo -j ACCEPT
> -A INPUT ! -i lo -d 127.0.0.0/8 -j REJECT
> #
> # Accepts all established inbound connections
> -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
> #
> # Allows all outbound traffic
> -A OUTPUT -j ACCEPT
> #
> # Allows HTTP and HTTPS connections from anywhere
> -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT
> -A INPUT -i eth0 -p tcp --dport 443 -j ACCEPT
> #
> # Allows SSH connections (changed port according to sshd_config file)
> -A INPUT -i eth0 -p tcp -m state --state NEW --dport 22 -j ACCEPT
> #
> -A INPUT -i eth0 -p tcp -p tcp --dport 1311 -j ACCEPT

Für was ist die Regel ???

> #
> # Allow SMB connections (network shares)
> -A INPUT -i eth0 -s 192.168.92.0/24 -p udp -m udp --dport 137 -j ACCEPT
> -A INPUT -i eth0 -s 192.168.92.0/24 -p udp -m udp --dport 138 -j ACCEPT
> -A INPUT -i eth0 -s 192.168.92.0/24 -m state --state NEW -m tcp -p tcp
> --dport 139 -j ACCEPT
> -A INPUT -i eth0 -s 192.168.92.0/24 -m state --state NEW -m tcp -p tcp
> --dport 445 -j ACCEPT

Soweit ich dich verstanden habe, hängt eth0 am Router, also geht es da
nur ins Internet.
Gibst du wirklich deine Samba-Shares für die ganze Welt frei?

> #
> # Allow nfs shares
> -A INPUT -i eth0 -s 192.168.92.0/24 -m state --state NEW -p udp --dport 111
> -j ACCEPT
> -A INPUT -i eth0 -s 192.168.92.0/24 -m state --state NEW -p tcp --dport 111
> -j ACCEPT
> -A INPUT -i eth0 -s 192.168.92.0/24 -m state --state NEW -p tcp --dport
> 2049 -j ACCEPT
> -A INPUT -i eth0 -s 192.168.92.0/24 -m state --state NEW -p tcp --dport
> 32765 -j ACCEPT
> -A INPUT -i eth0 -s 192.168.92.0/24 -m state --state NEW -p udp --dport
> 32765 -j ACCEPT
> -A INPUT -i eth0 -s 192.168.92.0/24 -m state --state NEW -p tcp --dport
> 32766 -j ACCEPT
> -A INPUT -i eth0 -s 192.168.92.0/24 -m state --state NEW -p udp --dport
> 32766 -j ACCEPT
> -A INPUT -i eth0 -s 192.168.92.0/24 -m state --state NEW -p tcp --dport
> 32767 -j ACCEPT
> -A INPUT -i eth0 -s 192.168.92.0/24 -m state --state NEW -p udp --dport
> 32767 -j ACCEPT
> -A INPUT -i eth0 -s 192.168.92.0/24 -m state --state NEW -p tcp --dport
> 32769 -j ACCEPT
> -A INPUT -i eth0 -s 192.168.92.0/24 -m state --state NEW -p udp --dport
> 32769 -j ACCEPT

Auch NFS für die ganze Welt?

> #
> # Allow VNC
> -A INPUT -i eth0 -p tcp -m tcp --dport 5904 -j ACCEPT
> #
> # Allow ping
> -A INPUT -i eth0 -p icmp -m icmp --icmp-type 8 -j ACCEPT

Bei beiden das '-m <proto>' weg. iptables erkennt es schon durch '-p
<proto>'.

> #
> # log iptables denied calls (access via "dmesg" command)
> -A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: "
> --log-level 7
> #
> # Allow VNC
> -A INPUT -i eth0 -p tcp -m tcp --dport 5904 -j ACCEPT
> #
> # Allow ping
> -A INPUT -i eth0 -p icmp -m icmp --icmp-type 8 -j ACCEPT
> #
> # log iptables denied calls (access via "dmesg" command)
> -A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: "
> --log-level 7

Diese 3 hattest du schon.

> #
> # Reject all other inbound - default deny unless explicitly allowed policy:
> -A INPUT -i eth0 -j REJECT
> -A FORWARD -i eth0 -j REJECT

Setze doch einfach die Default-Policy auf REJECT, dann ersparst du dir
die beiden Regeln.

> #
> COMMIT
> 
> Ist das so korrekt?
> Muß ich für eth1 folgendes anfügen? Oder ist das nicht nötig, da eth1 ja
> als bridge konfiguriert ist?
> -A INPUT -i eth1 -j REJECT
> -A FORWARD -i eth1 -j REJECT

Wenn du auf eth1 sowieso alles ablehnst, wieso steckst du dann eth1 in
die bridge?

> Würde mich sehr über Unterstützung und Tipps freuen!

Meine antworten sind nur schnell aus dem Kopf. Kann also sein, daß ich
bei manchen Sachen etwas falsch liege.
Aber mit VMs kannst du dass ganze auch gut austesten.
Ich hab mir selbst vor Jahren ein Script gebastelt das über die Jahre
angewachsen ist. Gebe also selten Regeln per iptables ein.

-- 
mfG Sascha

Manche Arbeiten muß man Dutzende Male verschieben, bevor man sie 
endlich vergißt.
		-- Unbekannt

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: