Hallo ich wollte euch hier ma zeigen wie man eine ipfw Firewall
installiert auf FreeBSD da es viele ungesicherte FreeBSD roots gibt es
sollten niemals mehr Port als nötig gefönet sein
ich erkläre euch wie ihr eine ipfw firewall auf FreeBSD installiert ich
übernehme keine Verantwortung für irgend welche fehlt Einstellung oder
sonstiges wenn ihr die Sachen einfach kopiert selbst schuld
was brauche ich?
1 FreeBSD root
1 metin2 Server
1 ein wenig Grips
und die Ports die der metin2 Server braucht
Putty
2. testen ob ipfw möglich ist
das macht ihr mit
ipfw list
den müstet ihr folgenden eror erhalten
- Code:
-
ipfw: getsockopt(IP_FW_GET): Protocol not available
2. ipfw regel anlegen
ihr erstelle eine neue datei namens ipfw.rules
wir müssen naturlich auch den ssh port ec auch freigeben da ihr sonst
nicht mehr euch per ssh zu euren root verbinden könnt
ich habe hier ma eine standart regel gemacht für metin2 und einem
channel
dies basiert ledeglich auf den Standart ports!
ihr gebt also folgenden Text ein in eure ipfw.rules Datei
- Code:
-
IPF="ipfw -q add"
ipfw -q -f flush
#loopback
$IPF 10 allow all from any to any via lo0
$IPF 20 deny all from any to 127.0.0.0/8
$IPF 30 deny all from 127.0.0.0/8 to any
$IPF 40 deny tcp from any to any frag
# statefull
$IPF 50 check-state
$IPF 60 allow tcp from any to any established
$IPF 70 allow all from any to any out keep-state
$IPF 80 allow icmp from any to any
# open port ftp (20,21), ssh (22), mail (25)
# http (80), dns (53) etc
$IPF 110 allow tcp from any to any 21 in
$IPF 120 allow tcp from any to any 21 out
$IPF 130 allow tcp from any to any 22 in
$IPF 140 allow tcp from any to any 22 out
$IPF 170 allow udp from any to any 53 in
$IPF 175 allow tcp from any to any 53 in
$IPF 180 allow udp from any to any 53 out
$IPF 185 allow tcp from any to any 53 out
# metin2 ch1 ports
$IPF 200 allow tcp from any to any 11002 in
$IPF 210 allow tcp from any to any 11002 out
$IPF 200 allow udp from any to any 11002 in
$IPF 210 allow udp from any to any 11002 out
$IPF 200 allow tcp from any to any 13000 in
$IPF 210 allow tcp from any to any 13000 out
$IPF 200 allow tcp from any to any 13001 in
$IPF 210 allow tcp from any to any 13001 out
$IPF 200 allow tcp from any to any 13002 in
$IPF 210 allow tcp from any to any 13002 out
$IPF 200 allow tcp from any to any 13003 in
$IPF 210 allow tcp from any to any 13003 out
$IPF 200 allow tcp from any to any 13004 in
$IPF 210 allow tcp from any to any 13004 out
$IPF 200 allow tcp from any to any 13061 in
$IPF 210 allow tcp from any to any 13061 out
$IPF 200 allow tcp from any to any 13099 in
$IPF 210 allow tcp from any to any 13099 out
und speichert es auf eurem FreeBSD root im folgenden Verzeichnis
/usr/local
/etc/ipfw.rules
und zu guter lezt müssen wir das ganze in die rc.conf einfügen am
schnellsten geht das so
1.ihr könnt naturlich die ipfw.rules auch in einem anderen Verzeichnis
packen nur den müsst ihr den pfad anpassen das bleibt euch überlassen
- Code:
-
echo 'firewall_enable="YES"' >> /etc/rc.conf
echo 'firewall_script="/usr/local/etc/ipfw.rules"' >> /etc/rc.conf
jezt nur noch rebooten das macht ihr folgt
- Code:
-
reboot
wenn ipfw einmal aktive ist den müsst ihr für kleinere Änderungen
keinen reboot machen den reloadet ihr es einfach mit folgenden befehlt
- Code:
-
/etc/rc.d/ipfw restart
um jetzt zu sehn ob ipfw arbeitet gebt ihr folgenden befehl in
putty ein
ipfw show
Mit ipfw ips bannen
wenn ihr ma einen Angreifer habt auf euren freebsd root und es defentive
als ddos indefiziren könt den kann man mit ipfw auch ips bannen
das geht so
- Code:
-
ipfw deny ip from 123.145.167.123 to any
ich habe jeze nur eine beispiel ip genommen ihr sezte naturlich
die ip des angreifers ein
ipfw im kernel kompilieren
ich möchte darauf hinweisen in 99% der falle braucht man es nicht ich
werde hier nicht erklären wie ihr an die source bzw kernel source kommt
zum compilen ich werden lediglich zeigen wie ihr es in den kernel bzw in
den source editiert und kompilieren
als erste gebt ihr das ein
- Code:
-
grep IPFIREWALL /usr/src/sys/i386/conf
und dan das
- Code:
-
cd /usr/src/sys/i386/conf
und den noch das
- Code:
-
cp GENERIC IPFWKERNEL
den müsst ihr jezt die IPFWKERNEL editiren das geht so
ihr könnt vi oder ee nehm ich personlich zihe ee vor
- Code:
-
ee IPFWKERNEL
ihr fügt nun folgendes ein
- Code:
-
options IPFIREWALL # required for IPFW
options IPFIREWALL_VERBOSE # optional; logging
options IPFIREWALL_VERBOSE_LIMIT=10 # optional; don't get too many log entries
options IPDIVERT # needed for natd
compilen
- Code:
-
cd /usr/src
- Code:
-
make buildkernel KERNCONF=IPFWKERNEL
ihr müst dieses als erstes schrit aufüren normal aber da viele
freebsd anbieter es vor instaliert haben braucht man es oft nicht
aufüren
quelle
[Sie müssen registriert oder eingeloggt sein, um diesen Link sehen zu können]Quelle: Elitepvpers