Finally getting around to expanding my simple pf.conf to greater horizons. I have two NICs (fxp0, alc0). On alc0 (int_if) I have cloned lo1 and aliased two IPs for two separately jailed services (http, mysql). My ifconfig:
Questions:
Code:
fxp0: inet 192.168.1.10 netmask 0xffffff00 broadcast 192.168.1.255
alc0: inet 192.168.2.1 netmask 0xffffff00 broadcast 192.168.1.255
lo0: inet 127.0.0.1 netmask 0xff000000
lo1: inet 192.168.2.100 netmask 0xffffff00
inet 192.168.2.101 netmask 0xffffff00
- I want to make jail-http accessible both from int_if and ext_if. Is cloning lo1 the correct way to do it, or have I unnecessarily complicated things?
- mysql is needed ONLY for support of jailed http programs and not needed otherwise. Can jail-http communicate directly with jail-sql (with static IP), or is it mandatory to set up the NAT rules in PF? Will ommitting rdr rule for mysql on ext_if break the app running in jail-http for external clients?
- There is one server that runs everything I currently need (this is just a lab environment): PF, diskless (dhcp, inetd, NFS, NTP, some others) and jailed http/mysql. No traffic passes from ext_if to int_if with exception for jailed services. Traffic should pass from int --> ext. With these requirements, any corrections to my pf.conf that you might suggest? Also:
- Do I need anchor ftp?
- Do I need to rdr from jail-http to ext_if? Should I use TAG instead?
- Seems I have an error also:
Code:pfctl: DIOCADDRULE: Address family not supported by protocol family
Code:int_if="alc0" ext_if="fxp0" jhttp="192.168.2.100" jsql="192.168.2.101" ################ Options ################################## set block-policy return set loginterface $ext_if # set skip on lo # disable ################ Normaliztation ############################ # normalize all incoming traffic. Set ttl 254: limits mapping of hosts behind firewall. Set random-id to help same. Set mss to ATM network frame size for easy splitting upstream. scrub on $ext_if all random-id min-ttl 254 max-mss 1452 reassemble tcp fragment reassemble ################ Translation ############################### # NAT internal hosts nat on $ext_if from !($ext_if) to any -> ($ext_if:0) nat on $int_if from lo1:network to any -> ($int_if) # Redirect internal http/sql traffic to Jail address rdr on $int_if proto tcp from any to $int_if port http -> $jhttp port http rdr on $int_if proto tcp from any to $int_if port 3306 -> $jsql port 3306 # Redirect external http/sql traffic to internal Jail address rdr on $ext_if proto tcp from any to ($ext_if) port http -> $jhttp port http rdr on $ext_if proto tcp from any to ($ext_if) port 3306 -> $jsql port 3306 no rdr # DENY rouge redirections ################ Filtering ################################# # loopback antispoof log quick for lo0 inet pass quick on lo0 all # block rules block in inet6 block in quick on $ext_if from any to 255.255.255.255 block log on $ext_if all block in from no-route to any block in from urpf-failed to any block out log quick on $ext_if from ! $ext_if to any # pass TCP/UDP, (in+out for ICMP) connections and set state pass on $ext_if inet proto icmp all icmp-type 8 code 0 pass out quick on $ext_if proto udp from ($ext_if) to any keep state pass out quick on $ext_if proto tcp from ($ext_if) to any modulate state # tag packets in on $int_if and pass them out on $ext_if pass in quick on $int_if from any to any tag INTNET # Allow http/sql traffic to internal machine ip (alias) block in on $ext_if pass in on $ext_if proto tcp from any to $jhttp port http flags S/SA synproxy state pass in on $ext_if proto tcp from any to $jsql port 3306 flags S/SA synproxy state pass in quick on $ext_if proto tcp from any to ($ext_if) port ssh # ssh on host ##### These Seem To Be Not Needed ###### #nat-anchor "ftp-proxy/*" #pass in quick on $int_if inet proto tcp to any port ftp divert-to 127.0.0.1 port 8021 #nat on $int_if from $jhttp to $ext_if -> ($ext_if) #match out on egress inet from !(egress:192.168.2.0) to any nat-to (egress:0) # DNW #pass in on egress inet proto tcp to (egress) port 80 rdr-to $j80 synproxy state