Gestern hab ich mir für FreeBSD mal eine Firewall mit ipfw gezimmert, muß ehrlich schreiben bin kein von pf oder ipfw oder ipfilter und benutz lieber was fertiges. Naja was sein muß muß sein und hab eine mit ipfw gebastelt, im Kernel steht nur:
options IPFIREWALL #
options IPFIREWALL_VERBOSE #
options IPFIREWALL_VERBOSE_LIMIT=256 #
also ACCEPt hab ich weggelassen und von Haus aus steht alles auf deny. Limit ist eventuell etwas mau aber egal.
ipfw.rules sieht so aus:
IPF="ipfw -q add"
ipfw -q -f flush
oif="vr0"
iif="vr0"
$IPF 65535 deny ip from any to any
# 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
$IPF 100 pass ip from any to any verrevpath
# open ports 21,25,80 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 25 in
$IPF 140 allow tcp from any to any 25 out
$IPF 150 allow tcp from any to any 443 in
$IPF 160 allow tcp from any to any 443 out
$IPF 200 allow tcp from any to any 80 in
$IPF 210 allow tcp from any to any 80 out
$IPF 220 allow tcp from 192.168.1.0/24 to any 10000 in
$IPF 230 allow tcp from 192.168.1.0/24 to any 10000 out
$IPF 240 allow tcp from any to any 20000 in
$IPF 250 allow tcp from any to any 20000 out
$IPF 260 allow tcp from any to any 8080 in
$IPF 270 allow tcp from any to any 8080 out
$IPF 280 allow tcp from any to any 587 in
$IPF 290 allow tcp from any to any 587 out
# portscanning
$IPF 600 deny log logamount 50 ip from any to any ipoptions rr
$IPF 610 deny log logamount 50 ip from any to any ipoptions ts
$IPF 620 deny log logamount 50 ip from any to any ipoptions lsrr
$IPF 630 deny log logamount 50 ip from any to any ipoptions ssrr
$IPF 640 deny log logamount 50 tcp from any to any tcpflags syn,fin
$IPF 650 deny log logamount 50 tcp from any to any tcpflags syn,rst
# dos-atacke
$IPF 1500 allow icmp from any to any icmptypes 3
$IPF 1510 allow icmp from any to any icmptypes 4
$IPF 1520 allow icmp from any to any icmptypes 8
$IPF 1530 allow icmp from any to any icmptypes 0
$IPF 1540 allow icmp from any to any icmptypes 11 in
# spoofing
$IPF 1550 deny all from inet to any in via ${oif}
$IPF 1560 deny all from onet to any in via ${iif}
# log
$IPF 256 deny log all from any to any
so funktioniert die Firewall. Anliegen ist mehr was ist eventuell Mißt oder kann man verbessern. Netzwerkinterface ist nur eins, vr0, der Rechner mit FreeBSD steht hinter einem Hardwarerouter imLan .
ipfw wird übrigens mit ipfw_enable="YES" und zweiter Eintrag firewall_enable="YES" gestartet.
So und jetzt zu den Vorschlägen. bitte bitte
options IPFIREWALL #
options IPFIREWALL_VERBOSE #
options IPFIREWALL_VERBOSE_LIMIT=256 #
also ACCEPt hab ich weggelassen und von Haus aus steht alles auf deny. Limit ist eventuell etwas mau aber egal.
ipfw.rules sieht so aus:
IPF="ipfw -q add"
ipfw -q -f flush
oif="vr0"
iif="vr0"
$IPF 65535 deny ip from any to any
# 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
$IPF 100 pass ip from any to any verrevpath
# open ports 21,25,80 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 25 in
$IPF 140 allow tcp from any to any 25 out
$IPF 150 allow tcp from any to any 443 in
$IPF 160 allow tcp from any to any 443 out
$IPF 200 allow tcp from any to any 80 in
$IPF 210 allow tcp from any to any 80 out
$IPF 220 allow tcp from 192.168.1.0/24 to any 10000 in
$IPF 230 allow tcp from 192.168.1.0/24 to any 10000 out
$IPF 240 allow tcp from any to any 20000 in
$IPF 250 allow tcp from any to any 20000 out
$IPF 260 allow tcp from any to any 8080 in
$IPF 270 allow tcp from any to any 8080 out
$IPF 280 allow tcp from any to any 587 in
$IPF 290 allow tcp from any to any 587 out
# portscanning
$IPF 600 deny log logamount 50 ip from any to any ipoptions rr
$IPF 610 deny log logamount 50 ip from any to any ipoptions ts
$IPF 620 deny log logamount 50 ip from any to any ipoptions lsrr
$IPF 630 deny log logamount 50 ip from any to any ipoptions ssrr
$IPF 640 deny log logamount 50 tcp from any to any tcpflags syn,fin
$IPF 650 deny log logamount 50 tcp from any to any tcpflags syn,rst
# dos-atacke
$IPF 1500 allow icmp from any to any icmptypes 3
$IPF 1510 allow icmp from any to any icmptypes 4
$IPF 1520 allow icmp from any to any icmptypes 8
$IPF 1530 allow icmp from any to any icmptypes 0
$IPF 1540 allow icmp from any to any icmptypes 11 in
# spoofing
$IPF 1550 deny all from inet to any in via ${oif}
$IPF 1560 deny all from onet to any in via ${iif}
# log
$IPF 256 deny log all from any to any
so funktioniert die Firewall. Anliegen ist mehr was ist eventuell Mißt oder kann man verbessern. Netzwerkinterface ist nur eins, vr0, der Rechner mit FreeBSD steht hinter einem Hardwarerouter imLan .
ipfw wird übrigens mit ipfw_enable="YES" und zweiter Eintrag firewall_enable="YES" gestartet.
So und jetzt zu den Vorschlägen. bitte bitte