ipfw: ssh und ftp von aussen erlauben

merkas

Active Member
Hallo!

Ich habe von FreeBSD Samba PDC Howto von highfish die ipfwrules übernommen und auf meine Hardware angepasst.

Sieht jetzt so aus:

Code:
#!/bin/sh
#

#Mach "Quiet"
fwcmd="/sbin/ipfw -q"

#Erstmal alles saubermachen bevor wir anfangen
${fwcmd} -f flush

#Das setzen unserer eigenen Variabeln
interface="fxp0" # ${interface} Netzwerkkarte
dns_server="62.27.27.62" # ${dns_server} DNS-Server
open_tcpports="21,22,67,68,80,139,10000" # ${open_tcpports} Offene TCP-Ports
open_udpports="21,22,67,68,123,137,138" # ${open_udpports} Offene UDP-Ports

#Erlaubt Loopbackverbindungen
${fwcmd} add allow ip from any to any via lo0

#Erlaubt Verbindungen welche von hier initiiert wurden
${fwcmd} add allow tcp from any to any out xmit ${interface} setup
${fwcmd} add allow udp from any to any out xmit ${interface} setup

#Erlaubt der Verbindung offen zu bleiben
${fwcmd} add allow tcp from any to any via ${interface} established
${fwcmd} add allow tcp from any to any via ${interface} established

#Erlaubte Dienste die aus dem Netzwerk erreicht werden duerfen
${fwcmd} add allow tcp from any to any ${open_tcpports} setup
${fwcmd} add allow udp from any to any ${open_udpports} setup
${fwcmd} add allow tcp from any to any ${open_tcpports} out xmit ${interface}
${fwcmd} add allow udp from any to any ${open_udpports} out xmit ${interface}
${fwcmd} add allow tcp from any to any ${open_tcpports} in recv ${interface}
${fwcmd} add allow udp from any to any ${open_udpports} in recv ${interface}
#Sendet RESET an alle ident Packete
${fwcmd} add reset tcp from any to any 113 in recv ${interface}

#Erlaubt ausgehende DNS-Anfragen NUR auf angegebenem DNS-Server
${fwcmd} add allow udp from any to ${dns_server} 53 out xmit ${interface}
${fwcmd} add allow tcp from any to ${dns_server} 53 out xmit ${interface}
${fwcmd} add allow udp from ${dns_server} 53 to any in recv ${interface}
${fwcmd} add allow tcp from ${dns_server} 53 to any in recv ${interface}

#Loggt ICMP Anfragen (echo und dest. unreachable)[/I]
${fwcmd} add allow log icmp from any to any in recv ${interface} icmptype 3
${fwcmd} add allow log icmp from any to any in recv ${interface} icmptype 8

#ICMP erlauben
${fwcmd} add allow icmp from any to any

#Alles andere verbieten (Wird nicht geloggt)
${fwcmd} add deny ip from any to any

Jetzt mein erste Frage:
Warum steht hier 2 mal das gleiche?
Code:
#Erlaubt der Verbindung offen zu bleiben
${fwcmd} add allow tcp from any to any via ${interface} established
${fwcmd} add allow tcp from any to any via ${interface} established
Müsste das nicht so heißen:
Code:
#Erlaubt der Verbindung offen zu bleiben
${fwcmd} add allow tcp from any to any via ${interface} established
${fwcmd} add allow udp from any to any via ${interface} established

Meine 2. Frage:
Wie erlaube ich von aussen (Internet) ftp und ssh?
Am besten gleich passive mode für ftp.
Vom LAN klappt das schon wunderbar. Kein Wunder wird ja auch in ipfwrules erlaubt. :)
Ich würde halt gerne Reglen für ftp und ssh in die ipfwrules aufnehmen die zum ipfwrule-Schema von hisghfish passen.
Falls das noch wichtig ist: Gateway ist 192.168.0.1 (d-link router). Bei der Netzwerkkarte (fxp0) ist dieser eingetragen.

Vielen Dank
 
Zurück
Oben