While I'm relatively new to FreeBSD, I took my time to first study it (read quite a few books, including the ones on networking and jails) and then I took about 2 months trying to create a perfect workstation for myself, but so far I was unsuccessful in my attempts to do it according to my "design". For some reason I expected this to be easier than setting up the same thing on Linux, but it turned out to be more confusing -- yet, I haven not lost my enthusiasm. I'll describe the intended result below and would welcome any replies, however short, that can help me get close to it.
The major goal is to keep my bare metal desktop machine completely isolated, while allowing internet connections from jails & running software that requires internet connections from jail (in case of GUI apps, I'd like to make use of X-forwarding via ssh). Isolating the desktop is about the only goal I've yet achieved -- it was easy, of course, to add a couple of lines to /etc/pf.conf, however setting up functional networking with jails proved to be an issue.
Here, I must mention, I AM NOT using ezjails or any other jail management software -- not even jail.conf files is being used. I'm rather comfortable with Bash, so I can script whatever I prefer while specifying all jail options when calling
Now, let's get straight to the network design. I'll try to "type" a diagram here, so it's immediately obvious what I'm trying to accomplish:
Tried using bridge + epairs for each VM, but got stuck at pf NAT rules (was able to connect to/from bare metal host, but unable to get internet access). I also tried aliases (such that each VM would get a separate IP-address on LAN) which largely worked, but I couldn't create a Wireguard connection inside the VM -- it's not allowed to create taps from within a jail that does not own its network. Throughout all of this, blocking rules in pf were DISABLED (commented) to ensure I got basic network connectivity.
I was under the impression it'd be easier to set it up under FreeBSD than it was on Linux -- this very network scheme worked "out of the box" on Linux with Docker. That is, it would create a bridge (or let you create one with subnet ip-range you want) and then direct traffic as pictured above. I didn't see any epair interfaces on Linux and would like, if possible, to avoid them in FreeBSD as well.
Both bare metal and jails are running FreeBSD 13.2.
Would appreciate your thoughts and advice or, perhaps, some specific configuration lines for ifconfig and pf.conf, if you have the time for it.
The major goal is to keep my bare metal desktop machine completely isolated, while allowing internet connections from jails & running software that requires internet connections from jail (in case of GUI apps, I'd like to make use of X-forwarding via ssh). Isolating the desktop is about the only goal I've yet achieved -- it was easy, of course, to add a couple of lines to /etc/pf.conf, however setting up functional networking with jails proved to be an issue.
Here, I must mention, I AM NOT using ezjails or any other jail management software -- not even jail.conf files is being used. I'm rather comfortable with Bash, so I can script whatever I prefer while specifying all jail options when calling
jail
. I also would like to understand my network setup completely and not rely on someone else's pre-defined setup.Now, let's get straight to the network design. I'll try to "type" a diagram here, so it's immediately obvious what I'm trying to accomplish:
Code:
---------------------- -----------------------------------------------
| |RUNS: | | RUNS:
| Desktop | *pf | Proxy VM | * Wireguard
| | | | * Privoxy
|--------------| |--------------|
|VMN: 192.0.3.1|<~~~~~~~~~~|VMN: 192.0.3.2|<‒‒.
|LAN: 192.0.1.9| fwd to '--------------' |
'**************' EXT |
| ⠇ |
EXT | ⠇`jexec -l` or ssh only |
fwd from | ⠇...... |--------------| |
Proxy only | ⠇.....| Browser VM | | {
| ⠇ |--------------| | { VMs only have access to
|--------------| ⠇ |VMN: 192.0.3.3|‒‒>| { outside world through Proxy VM
| ROUTER | ⠇ '--------------' |...{ and also ssh for
| connected to | ⠇ | { X11 Forwarding -- the rest
| my ISP | ⠇ |--------------| | { is disallowed by `pf` on the
|--------------| ⠇.....| Messenger VM | | { bare metal.
|LAN: 192.0.1.1| ⠇ |--------------| | {
'**************' ⠇ |VMN: 192.0.3.4|‒‒>|
⠇ '--------------' |
⠇ |
⠇ |--------------| |
⠇.....| vm #N | |
⠇ |--------------| |
⠇ |VMN: 192.0.3.n|‒‒>|
⠇ '--------------' |
⠇... ...|
>> etc <<
I call jails "VMs" because some of them later might be bhyve instances instead. "VMN" means "VM Network".
Tried using bridge + epairs for each VM, but got stuck at pf NAT rules (was able to connect to/from bare metal host, but unable to get internet access). I also tried aliases (such that each VM would get a separate IP-address on LAN) which largely worked, but I couldn't create a Wireguard connection inside the VM -- it's not allowed to create taps from within a jail that does not own its network. Throughout all of this, blocking rules in pf were DISABLED (commented) to ensure I got basic network connectivity.
I was under the impression it'd be easier to set it up under FreeBSD than it was on Linux -- this very network scheme worked "out of the box" on Linux with Docker. That is, it would create a bridge (or let you create one with subnet ip-range you want) and then direct traffic as pictured above. I didn't see any epair interfaces on Linux and would like, if possible, to avoid them in FreeBSD as well.
Both bare metal and jails are running FreeBSD 13.2.
Would appreciate your thoughts and advice or, perhaps, some specific configuration lines for ifconfig and pf.conf, if you have the time for it.