VPS mit IPv6 only und pf kein ssh möglich

carbuncle

Rainbow Six
Moin,

ich habe hier ein VPS FreeBSD 14.2-RELEASE mit einem IPv6 only vtnet0 adapter (steht irgendwo auf der Welt). Jetzt möchte ich gerne pf einschalten und habe folgende Config gebastelt:

Code:
ext_if = "vtnet0"

set skip on lo0
block all

# Allow incoming and outgoing ssh traffic
#pass in on $ext_if inet6 proto tcp to port { ssh } keep state
#pass out on $ext_if inet6 proto tcp to port { ssh }
pass on $ext_if proto tcp to port ssh keep state

# Allow ping pong out
pass out on $ext_if inet6 proto icmp6 all icmp6-type echoreq keep state

# Allow Ping pong in
pass in on $ext_if inet6 proto icmp6 all icmp6-type echoreq

Nach meinem Verständis sollte die Config folgendes machen:

1. Alles blocken. Das tut sie
2. Allen ssh traffic der von aussen kommt reinlassen (tut sie nicht)
3. ICMP v6 Pakete beantworten. Das tut sie.

Wenn ich die config mit pfctl -e -f /etc/pf.conf lade dauert es ein paar Sekunden und ich komme nicht mehr auf die Box drauf. Ich behelfe mir in einer tmux session in der ich vorher "sleep 120; pfctl -d" starte.

Was fehlt mir in diesem Ruleset für einen SSH Zugang?

Vielen Dank
 
Hm die "pass in" Regel aus deinem Post hast du auch schon probiert?
Die unterscheidet sich nicht viel von meiner Regel:
Code:
pass in quick on $wan_if inet6 proto tcp from any to $wan_if port { 22 }

Edit: inet gegen inet6 getauscht
 
Zuletzt bearbeitet:
Hm die "pass in" Regel aus deinem Post hast du auch schon probiert?
Die unterscheidet sich nicht viel von meiner Regel:
Code:
pass in quick on $wan_if inet proto tcp from any to $wan_if port { 22 }

Müsste das evtl. inet6 lauten?

pass in quick on $wan_if inet6 proto tcp from any to $wan_if port { 22 }
 
Du brauchst auch das neighbouring zeug (types neighbradv, neighbrsol, routeradv, routersol ).
Es blockt dich da naemlich nicht pf, sondern dem ipv6 fehlt dann info, die in v4 via ARP kommt und damit in pf sonst nicht relevant ist.

Siehe auch zB https://subatomicsolutions.org/ipv4-ipv6-router-and-pf-firewall
Okay, vielen Dank. Das war der richtige Tip! Für IPv4 hätte die Config wahrscheinlich funktioniert. Aber das kann ja jeder ;). Hier ist meine aktuell funktionierende Config:

Code:
ext_if = "vtnet0"

icmp6_types = "{ echoreq, neighbradv, neighbrsol, routeradv, routersol }"
tcp_required = "{ domain, www, https, ntp }"
udp_required = "{ domain, ntp }"

# Reassemble fragmented packets, cleanup invalid flag combinations
scrub in all

# Do not block on loopback
set skip on lo0

# Block all traffic
block all

# Allow incoming and outgoing ssh traffic
pass in quick on $ext_if inet6 proto tcp to port { ssh } keep state
pass out quick on $ext_if inet6 proto tcp to port { ssh }

# Allow Ping pong in and out
pass in quick on $ext_if inet6 proto icmp6 all icmp6-type $icmp6_types allow-opts
pass out quick on $ext_if inet6 proto icmp6 all icmp6-type $icmp6_types allow-opts

# Allow default services
pass out on $ext_if inet6 proto tcp to any port $tcp_required
pass out on $ext_if inet6 proto udp to any port $udp_required
 
Zurück
Oben