I think that I'm being somewhat ambitious and I'm finding that I'm getting some horrible issues as a result. Firstly, what I'm trying to achieve.
The way that I have tried to set up this network in the past was that the router was in the DMZ and that it passed some traffic (HTTP/S) through to the Nginx server and another for Teamspeak on a separate VM.
However, I was having issues with routing the traffic (which in the end turned out to be because I was using the network adapters in Hyper-V, rather than the legacy network adapters) so I ended up port forwarding the web ports to the Nginx VM's IP address on the LAN and setting up yet another PF config there.
This has vastly complicated things on the Nginx box because I now have an external network for the LAN, an external network for the private Hyper-V network and an additional `lo1` interface network for the jails (I'm currently trying to host 4 jails on this machine.)
The jails on the Nginx VM need access to the private network and the return traffic to route back through to them because the apps need to contact the DB servers on this private network, then, the jails also need access to the internet for things like package upgrades etc. This sets up a requirement for a double NAT where the jail can speak with both networks. However, with my current configuration this is all horribly broken and things like viming a file break the SSH connection a lot. This currently is horribly broken with Pingdom telling me that my uptime is something like 33%
My configuration is like this:
VM Host running Windows 10 Pro and Hyper-V:
This is what I've managed to scrape together from the docs and many posts here and across the internet from Googling 'FreeBSD Jails PF'
The way that I have tried to set up this network in the past was that the router was in the DMZ and that it passed some traffic (HTTP/S) through to the Nginx server and another for Teamspeak on a separate VM.
However, I was having issues with routing the traffic (which in the end turned out to be because I was using the network adapters in Hyper-V, rather than the legacy network adapters) so I ended up port forwarding the web ports to the Nginx VM's IP address on the LAN and setting up yet another PF config there.
This has vastly complicated things on the Nginx box because I now have an external network for the LAN, an external network for the private Hyper-V network and an additional `lo1` interface network for the jails (I'm currently trying to host 4 jails on this machine.)
The jails on the Nginx VM need access to the private network and the return traffic to route back through to them because the apps need to contact the DB servers on this private network, then, the jails also need access to the internet for things like package upgrades etc. This sets up a requirement for a double NAT where the jail can speak with both networks. However, with my current configuration this is all horribly broken and things like viming a file break the SSH connection a lot. This currently is horribly broken with Pingdom telling me that my uptime is something like 33%
My configuration is like this:
VM Host running Windows 10 Pro and Hyper-V:
- This contains my FreeBSD VMs in a storage pool.
- This has two networks, one internal private network for inter VM communications and one Internet accessible interface.
- I have a FreeBSD router for the VMs which don't have an internet facing address (So my two DB servers, one MySQL and one PostgreSQL)
- The VM which has Nginx installed on it also is a jail host and has two interfaces, one on the private network, one on the LAN
Code:
ext_if = "de1"
int_if = "de0"
jail_if = "lo1"
jail_net = $jail_if:network
web_services = "{ http,https }"
protos = "{ udp,tcp }"
set loginterface $ext_if
set skip on lo0
set skip on $jail_if
set block-policy drop
scrub in all
nat pass on $ext_if from $jail_net to any -> ($ext_if:network)
nat pass on $int_if from $jail_net to any -> ($int_if:network)
#antispoof for $ext_if
rdr pass on $ext_if inet proto tcp to $web_services -> ($jail_if)
rdr pass on $int_if from $jail_if to ($int_if) -> $int_if
block in all
pass out quick on lo0 all
pass out quick on $jail_if all
pass out quick on $ext_if all
pass out quick on $int_if all
pass in quick on $ext_if proto tcp from any to any port $web_services
pass in quick on $ext_if proto $protos from any to any port ssh
pass in quick on $ext_if from $jail_if to any
pass in quick on $int_if from $jail_if to any
This is what I've managed to scrape together from the docs and many posts here and across the internet from Googling 'FreeBSD Jails PF'