0815dragon
BSD-Neuling
Hallo zusammen,
ich bin gerade dabei mich in das Thema Jails einzuarbeiten und versuche eine passende Konfiguration für IPFW zu erstellen. In der Vergangenheit habe ich alle Dienste auf dem Host laufen lassen. Jetzt möchte ich das ganze etwas trennen und die aus dem www erreichbaren Dienste in Jails packen.
Daher überarbeite ich meine Firewall Konfiguration doch mit NAT stelle ich mich etwas blöd an....
Mein Ziel ist, bestimmte Dienste (z.B. Samba) nur dem lokalen Netz zur verfügung zu stellen.
Einige Jails (beispielsweise jail_www) sollen dagegen auch "von aussen" erreichbar sein.
Eine Jail (jail_mysql) dagegen wieder nicht.
Das hier ist mein aktueller Arbeitstand.
Die NAT Konfiguration ist, glaube ich, komplett verkehrt.
Vom Gefühl her sollten die Regeln der Ports noch vor den NAT Regeln positioniert werden, oder?
Könnten ihr kurz über die Konfiguration fliegen und mir helfen den Knoten in meinem Kopf zu entwirren?
Vielen Dank für eure Hilfe!
Gruss
ich bin gerade dabei mich in das Thema Jails einzuarbeiten und versuche eine passende Konfiguration für IPFW zu erstellen. In der Vergangenheit habe ich alle Dienste auf dem Host laufen lassen. Jetzt möchte ich das ganze etwas trennen und die aus dem www erreichbaren Dienste in Jails packen.
Daher überarbeite ich meine Firewall Konfiguration doch mit NAT stelle ich mich etwas blöd an....
Mein Ziel ist, bestimmte Dienste (z.B. Samba) nur dem lokalen Netz zur verfügung zu stellen.
Einige Jails (beispielsweise jail_www) sollen dagegen auch "von aussen" erreichbar sein.
Eine Jail (jail_mysql) dagegen wieder nicht.
Das hier ist mein aktueller Arbeitstand.
Code:
#!/bin/sh
#=====================================================#
# Command #
#=====================================================#
IPF="ipfw -q"
#=====================================================#
# Configuration of host and NAT interfaces #
#=====================================================#
lan_if="re0"
nat_if="re0"
nat_ip=`ifconfig $nat_if | grep -v inet6 | grep inet | awk '{ print $2; }'`
#=====================================================#
# Jails #
#=====================================================#
jails_lan="10.0.0.0/24"
#jail_ip_www="10.0.0.10"
#jail_ip_mysql="10.0.0.11"
#jail_ip_mumble="10.0.0.12"
#=====================================================#
# Clean all #
#=====================================================#
ipfw -q -f flush
#=====================================================#
# Firewall settings #
#=====================================================#
#loopback
$IPF add 10 allow all from any to any via lo0
$IPF add 20 deny all from any to 127.0.0.0/8
$IPF add 30 deny all from 127.0.0.0/8 to any
$IPF add 40 deny tcp from any to any frag
# --------------------------------------------------- #
#statefull
$IPF add 100 check-state
$IPF add 110 allow tcp from any to any established
$IPF add 120 allow all from any to any out keep-state
$IPF add 130 allow icmp from any to any
$IPF add 140 allow igmp from any to any
# --------------------------------------------------- #
#host to jail
$IPF add 1000 allow any from me to $jail_ip_www setup keep-state
$IPF add 1010 allow any from me to $jail_ip_mysql setup keep-state
$IPF add 1020 allow any from me to $jail_ip_mumble setup keep-state
# --------------------------------------------------- #
#NAT for jails
#jail_ip_www
$IPF nat 1 config if $nat_if
$IPF add 1100 nat 1 all from $jail_ip_www to any
$IPF add 1110 nat 1 all from any to $nat_ip
#jail_ip_www
$IPF nat 2 config if $nat_if
$IPF add 1200 nat 2 all from $jail_ip_mysql to any
$IPF add 1210 nat 2 all from any to $nat_ip
#jail_ip_mumble
$IPF nat 3 config if $nat_if
$IPF add 1300 nat 3 all from $jail_ip_mumble to any
$IPF add 1310 nat 3 all from any to $nat_if
# --------------------------------------------------- #
#TODO:
#open ports ftp(20,21), ssh(22), http(80), vlc-Stream(1234)
#netbios (81), samba-nmbd (137,138), samba-smbd (139,445), mediatomb(1900,49152)
$IPF add 2100 allow tcp from any to me 21 in
$IPF add 2110 allow tcp from me to any 21 out
$IPF add 2120 allow tcp from any to me 22 in
$IPF add 2130 allow tcp from me to any 22 out
$IPF add 2140 allow tcp from any to any 80 in
$IPF add 2150 allow tcp from any to any 80 out
#$IPF add 2160 allow udp from any to any 1234 in
#$IPF add 2170 allow udp from any to any 1234 out
$IPF add 2180 allow tcp from 192.168.178.0/24 to me 81 in
$IPF add 2190 allow tcp from me to 192.168.178.0/24 81 out
$IPF add 2200 allow udp from 192.168.178.0/24 to me 81 in
$IPF add 2210 allow udp from me to 192.168.178.0/24 81 out
$IPF add 2220 allow tcp from 192.168.178.0/24 to me 137 in
$IPF add 2230 allow tcp from me to 192.168.178.0/24 137 out
$IPF add 2240 allow udp from 192.168.178.0/24 to me 137 in
$IPF add 2250 allow udp from me to 192.168.178.0/24 137 out
$IPF add 2260 allow tcp from 192.168.178.0/24 to me 138 in
$IPF add 2270 allow tcp from me to 192.168.178.0/24 138 out
$IPF add 2280 allow udp from 192.168.178.0/24 to me 138 in
$IPF add 2290 allow udp from me to 192.168.178.0/24 138 out
$IPF add 2300 allow tcp from 192.168.178.0/24 to me 139 in
$IPF add 2310 allow tcp from me to 192.168.178.0/24 139 out
$IPF add 2320 allow udp from 192.168.178.0/24 to me 139 in
$IPF add 2330 allow udp from me to 192.168.178.0/24 139 out
$IPF add 2340 allow tcp from 192.168.178.0/24 to me 445 in
$IPF add 2350 allow tcp from me to 192.168.178.0/24 445 out
$IPF add 2360 allow udp from 192.168.178.0/24 to me 445 in
$IPF add 2370 allow udp from me to 192.168.178.0/24 445 out
$IPF add 2380 allow tcp from 192.168.178.0/24 to me 1900 in
$IPF add 2390 allow tcp from me to 192.168.178.0/24 1900 out
$IPF add 2400 allow udp from 192.168.178.0/24 to me 1900 in
$IPF add 2410 allow udp from me to 192.167.178.0/24 1900 out
$IPF add 2420 allow tcp from 192.168.178.0/24 to me 49152 in
$IPF add 2430 allow tcp from me to 192.168.178.0/24 49152 out
$IPF add 2440 allow udp from 192.168.178.0/24 to me 49152 in
$IPF add 2450 allow udp from me to 192.168.178.0/24 49152 out
# deny and log everything
$IPF 5000 deny log all from any to any in
Die NAT Konfiguration ist, glaube ich, komplett verkehrt.
Vom Gefühl her sollten die Regeln der Ports noch vor den NAT Regeln positioniert werden, oder?
Könnten ihr kurz über die Konfiguration fliegen und mir helfen den Knoten in meinem Kopf zu entwirren?
Vielen Dank für eure Hilfe!
Gruss