Schnelle pf.conf füpr Server

schorsch_76

FreeBSD Fanboy
Hallo,
ich stelle gerade meinen Server von Linux auf FreeBSD 12 um.

Ich hab 3 Interfaces.
re0, vm-local, tap0.

Ich bekomme es gerade nicht hin eine kleine pf.conf zu erstellen die
a) NAT tap0/vm-local -> re0
b) ssh
c) DNAT auf einzelne lokale IPs.

Ich hab mich schon zwei mal ausgesperrt :( weil ich
sleep 60 ; pfctl -d
vergessen hatte.

Code:
ext_if = "re0"
int_if = "{ vm-local, tap0 }"

# ext_if IP address could be dynamic, hence ($ext_if)
nat on $ext_if from $int_if to any -> ($ext_if)
block all
pass from { lo0, $int_if } to any keep state

pass in inet proto tcp to $ext_if port ssh

Ich lese gerade
https://home.nuug.no/~peter/pf/en/
 
Ich schnall die syntax nicht

Code:
ext_if = "re0"
int_if = "{ vm-local, tap0 }"

tcp_services = "{ ssh, http }"

# ext_if IP address could be dynamic, hence ($ext_if)
nat on $ext_if to any -> ($ext_if)

block all
pass quick from { lo0, $int_if } to any keep state

pass in from $ext_if proto tcp to any port $tcp_services keep state # < was passt hier nicht?
pass out proto tcp to any port $tcp_services keep state
 
hi

also ein skip macht was anderes als

Code:
pass from { lo0, $int_if } to any keep state


man koennete das so gestalten

Code:
wan_if=re0
lan_if_vm-local
dmz_if=tap0

skip on lo
deny log $wan_if 

# permit inbound tcp
pass in on $wan_if inet proto tcp from any to ($wan_if) port { 80,443,22}
pass in on $wan_if icmp

# permit outbound 
pass out on $wan_if from ( $wan_if) to any

# nat outbound lan
pass out on $lan_if from ($lan_if:network) to any nat-to ($wan_if)

anmerkung

bitte den syntax fuer nat anpassen da ich nur "OpenBSD" spreche bei pf.

wenn man skip verwendet , können auf den angewendetet interfaces keine regeln / states
mehr erstellt werden,, pf ignoriert das interface komplett

die () bedeuten da er die des interfaces ferwenden soll oder , mit :network ) das jeweiligen netzwerk.

ich macro bezeichnungen habe ich mal willkürlich gewählt.

da es für lan_if und dmz_if kein explizites deny gibt stehen sie auf permit.

holger
 
Zurück
Oben