PF mit mehreren IP-Adressen

daiv

AgainstAllAuthority
Ich finde leider keine Lösung für mein Problem.

Ich habe einen Server mit mehreren IP-Adressen. Ich würde gerne Port 80 für zwei IP-Adressen verwenden.

Meine Konfiguration sieht derzeit in etwa so aus:
if = "{ lo0, re0 }"
ext_ip = x.x.x.x
www1 = x.x.x.x
www2 = x.x.x.x
j1_tcp = "{ 80 }"
j2_tcp = "{ }"
nat on $if proto {tcp udp icmp} from lo0 to any -> $ext_ip
rdr pass on $if proto tcp from any to $if port $j1_tcp -> $www1
rdr pass on $if proto tcp from any to $if port $j2_tcp -> $www2
[...]

Die IP-Adressen sind als Alias auf re0 definiert.

Ich habe die Anleitung für PF damals von www.serverzeit.de entnommen und habe mich leider zu wenig mit PF beschäftigt um jetzt auf einem entfernten Server herumzuspielen.

Also soll bei einer Anfrage auf IP1 der Webserver in der Jail www1 und bei Anfrage auf IP2 der Webserver in der Jail www2 antworten.

Vielen Dank für eure Antworten.
 
Hoi,
würd ich oifach beim rdr to ext_ip_jail1 bzw. ext_ip_jail2 bärig nehmen.

Gruß Bummibär
 
if = "{ lo0, re0 }"
ext_ip = x.x.x.x
www1 = x.x.x.x
www2 = x.x.x.x
j1_tcp = "{ 80 }"
j2_tcp = "{ }"
nat on $if proto {tcp udp icmp} from lo0 to any -> $ext_ip
rdr pass on $if proto tcp from any to $if port $j1_tcp -> $www1
rdr pass on $if proto tcp from any to $if port $j2_tcp -> $www2
[...]

Die Interfaces solltest du auftrennen in $ext_if und $lo_if oder so. Damit ist eine feinere Aufteilung im Regelwerk möglich, imho.

Warum legst du bei der NAT Regel die Protokolle fest?

Die untere rdr-Zeile hat keine Zielports, da $j2_tcp leer ist. Ist das gewollt?

Da du die Konfig nicht vollständig gespostet hast, gehe ich davon aus, dass du entsprechende pass Rules in Verwendung hast. Was sagt tcpdump auf das pflog? Werden Pakete vielleicht doch geblockt?
 
Danke für eure Antworten. Hört sich gar nicht so schwer an.

Das mit der NAT Regel weiß ich nicht besser.

Das mit den Zielports ist gewollt. Ich habe das jetzt erst einmal leer gelassen. Die Zeile steht auch so nicht in der Konfiguration.

Ich poste die gesamte Konfiguration:
### INTERFACES ###
if = "{ lo0, re0 }"

### SETTINGS ###
set block-policy drop
scrub in all

# JAIL
jails = "{ 127.0.0.0/32 }"
ext_ip1 = x.x.x.x
ext_ip2 = x.x.x.x #So zb?
www1 = 127.0.0.11
mail = 127.0.0.12
www2 = x.x.x.x

# MAKRO #
j1_tcp = "{ 80 }"
j2_tcp = "{ 25 143 }"
j3_tcp = "{ 80 }" #So ok?

# NAT Jail
nat on $if proto {tcp udp icmp} from lo0 to any -> $ext_ip
rdr pass on $if proto tcp from any to $if port $j1_tcp -> $www1
rdr pass on $if proto tcp from any to $if port $j2_tcp -> $mail
rdr pass on $if proto tcp from any to $if port $j3_tcp -> $www2

icmp_types = "echoreq"

### TABLES ###
table <intranet> { x.x.x.x }
table <bruteforce> persist

### RULES ###
set skip on lo0
block all
block quick from <bruteforce>
pass in quick from <intranet> to any keep state
pass in on $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)
pass in on $if proto udp to any port $udp_pass keep state
pass out quick all keep state

# PING #
pass in on $if inet proto icmp all icmp-type $icmp_types keep state

# TRACEROUTE #
pass in on $if inet proto udp from any to any port 33433 >< 33626 keep state

pass out on $if all keep state
pass in on $if all keep state
 
Zurück
Oben