nat/rdr per pf - und alles hängt

Hi HaBo-Com,

Ich migriere gerade meinen vserver und hab dies zum anlass genommen, FreeBSD zu benutzen.
Gerade die Jails haben mich ziemlich gereizt, doch gerade die machen mir jetzt Probleme.

Ich habe nur eine IP, weshalb ich mein(e) Jail(s) in ein Virtuelles Subnetz gepackt hab. (192.168.0.[2-..])
Derzeit gibt es nur die Apache-Jail 192.168.0.2.
Die pf-rules sind folgende:

ext_if="vtnet0"
ext_ip="X.X.X.X"
tcp_pass = "{22}"

jail1_tcp = "{443 80}"
jail1 = "192.168.0.2"

set skip on lo0
scrub in all

# pass jail1
nat on $ext_if proto {tcp udp icmp} from $jail1 to any -> ($ext_if)
rdr pass on $ext_if proto tcp from any to $ext_ip port $jail1_tcp -> $jail1

antispoof for $ext_if
table <bruteforce> persist
block all

# block those bruters
block quick from <bruteforce>

#pass in on $ext_if proto tcp from any to any port $tcp_pass flags S/SA keep state (max-src-conn 100, max-src-conn-rate 15/5, overload <bruteforce> flush global)

# outgoing network
pass out quick all keep state

# incoming traffic
pass in on $ext_if proto tcp from any to $ext_ip port $tcp_pass

# allow ping:
pass in on $ext_if inet proto icmp from any to $ext_ip icmp-type echoreq

ifconfig:
vtnet0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=c07bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,TSO4,TSO6,LRO,VLAN_HWTSO,LINKSTATE>
ether 40:4n:eek:t:fo:un:d0
inet6 X:X:X:X:X:X:X:X%vtnet0 prefixlen 64 scopeid 0x2
inet6 X:X:X:X:X:X:X:X prefixlen 64 autoconf
inet X.X.X.X netmask 0xfffffc00 broadcast X.X.X.X
nd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>
media: Ethernet 1000baseT <full-duplex>
status: active
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
inet 127.0.0.1 netmask 0xff000000
inet 192.168.0.2 netmask 0xffffffff
nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
pflog0: flags=141<UP,RUNNING,PROMISC> metric 0 mtu 33152
nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>

Wenn ich nun auf der web-Jail den Port 80 mit irgendwas belege(testweise einfach mal cat /dev/random | nc -l 80) und dann die Seite aufrufe explodiert der ping (von vorher Konstant ~35ms auf bis 3600ms!)
Ssh-Verbindungen sind zu der Zeit natürlich absulut nicht mehr benutzbar, sobald die Übertragung fertig ist -> alles wieder normal, als ob nichts gewesen wäre.
Durch das Laggen kann ich keine durchgehenden Werte aus top lesen, aber es scheint als ob ziemlich viel Zeit im Kernelspace draufgeht.
Also wird irgendwie die Firewall das bottleneck sein.

Wenn ich das ganze außerhalb der jail mache läuft alles 1a.

(Vergleich, wget auf jail-random: 5-15kb/s, auf main-random: 1.6mb/s)

rc.conf vom host:
hostname="foobar"
keymap="german.iso.kbd"

# configure interfaces.
ifconfig_vtnet0="DHCP"
ifconfig_vtnet0_ipv6="inet6 accept_rtadv"

gateway_enable="YES"

sshd_enable="YES"
ntpd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="NO"


# prepare syslogd for jails
syslogd_flags="-ss"

# jail ip's
# webserver
ifconfig_lo0_alias0="inet 192.168.0.2 netmask 255.255.255.255"

# enable jails
ezjail_enable="YES"

# enable firewall
pf_enable="YES"
pf_rules="/etc/pf.conf"
pflog_enable="YES"
pflog_logfile="/var/log/pflog"

Vllt noch die rc.conf vom jail:
rpcbind_enable="NO" # Disable the RPC daemon
cron_flags="$cron_flags -J 15" # Prevent lots of jails running cron jobs at the same time
syslogd_flags="-ss" # Disable syslogd listening for incoming connections
sendmail_enable="NONE" # Completely disable sendmail
clear_tmp_enable="YES" # Clear /tmp at startup

apache22_enable="YES"
mysql_enable="YES"

Von der Jail aus kann ich ohne Probleme fullspeed ins Internet.
Vom Host kann ich fullspeed auf die Jail.
Nur kann ich nicht direkt aus dem Internet über den Host auf die Jail zugreifen. Irgendwie scheint der "rdr-Befehl" zu "lahmen"

Was könnte ich ausprobieren?


Chief
 
Zuletzt bearbeitet:
Zurück
Oben