Firewall (How to Hypervise?)

So, I like TrueNAS scale. I also need VMs.

Chocies

  1. proxmos and truenas scale as a vm
  2. truenas scale as a hypervisor os.

I prefer the 2. chouce - truenas scale as a hypervisor os. I understqand this is limmiting myself and introducing a lot of complexity since the whole Virutalisation - Hypervisor OS theme is new to TrueNAS (very new indeed).

Still, I like my data to be the bare metal layer - so the thing that works with disks, this seems like a more reliable choice for me than to have truenas be a VM. unfortionatley I cant afford both (I am using a bare metal dedicated server machine in a datacenter).

So ----- HOW DO I SETUP A FIREWAL!!! ???
My datacenter provides a basic firewall with only 10 rules, which is really not enought for a Hypervisor OS …

Can I have my TrueNAS scale somehow do the firewall duties as well? I will be having a couple of different VM’s and I need to protect them at a level before they are reached (as each is specific and has its own complexity, – as well as comoplexity to setup a firewall on each one, so really best practice here is to put firewall before them – which is really the HypeervisorOS level - in my case - TrueNAS scale…)

Any quality advices?

ps. to clarify - my TrueNAS scale is playing a HypervisorOS role, besides the reliable storaedge role, and IS EXPOSED to the internet

2 Likes

hah, judging from the smiley - this is a very unadvised thing to do?

1 Like

General rule of thumb is not to expose your NAS to the internet unless you’re doing it through a VPN.

I’m not confident enough in my own terrible execution of firewall solutions to give any real advice to others. Let alone then running virtually on my NAS.

I think (level 1 techs had some fun videos on THE FOBIDDEN ROUTER where they go into details about running your Router on a hypervisor. They didn’t virtualize it on TrueNAS and unless you’re a hardware nerd you can likely skip the build details… but combine the knowledge there with some general info on how to virtualize on TrueNAS in general & you should have a start.

Wendell does into some details on why maybe you shouldn’t, goes into how to do it, and links to his forums where such heresy might be better supported. I’d argue the crowd here is (rightfully) more conservative; we love our data & want it away from risks.

Edit: I keep saying ā€˜router’ when you’re asking for ā€˜firewall’ because I’m too used to opnsense where it is frankly both. I think Wendell goes over pfsense - others can argue about which is better.

These are just my foundational 101 recommendations that don’t actually give you a direct answer as to ā€˜how’, because you’ll have to learn a lot to get it working for your specific usecase & I don’t know if anyone would walk you through the entire way.

Edit 2: If this isn’t just for fun on a homelab, but instead production environment - then uhh… just don’t.

1 Like

thank you for a detailed answer. I am watching the video now.

I do have a question - why not expose truenas scale to the internet?
I get it that you dont want to expose your NAS to the internet, but Scale is really not just a nas, and, how are you even going to run docker containers or vm’s without doing so?

I do plan to block a lot of traffic, but my main concern here is - - is there something I dont understand about truenas scale? Is it inherently unsafe to expose it to the internet? Has it not been built with security in mind, and are there a lot of exploits?

From what I have seen, it uses the port 80 or 443 for the webpanel, and I can lock them behind a vpn so it can only be reached with the vpn. I can also close every other port, and as a normal course of acation I alsways locke the port 22 to my vpn ip as well.

Are there any other problems with this? My idea is to maybe get a couple of IPs from my datacenter and bound one to the NAS itself – that will only be accessible from my VPN IP, and use others for other VM’s I’m gonna have inside…

Do you see any security risks or potential probelms with this setup?

Thanks.

TrueNAS, and FreeNAS before it, has had a hypervisor for 7+ years now.

TrueNAS doesn’t have a firewall. Never had it, never will. You could install one in a VM (use whatever software you like), but it isn’t part of TrueNAS.

An exceedingly poor design.

What makes you say that?

You put TrueNAS behind something like Opnsense

Ya but you will run into bootstrapping issues as you would have to access everything from a jail and not the host directly

Some people skydive without a parachute as well… dosent make it a viable and safe strategy…

Personally I restrict access to TrueNAS to a dedicated VLAN, then I have a separate VLAN that a reverse proxy can access and route WAN traffic to jails running software that need WAN access such as Wireguard. For LAN access I use the same proxy but I use local DNS overrides so that I dont have to reflect NAT.

Route for public access is
WAN - proxy - untrusted VLAN - jails

Having truenas behind an OPNsense or PfSense firewall which itself is a VM hosted on TrueNAS more or less works fine.

Ideally you hardware pass through two NIC ports. One upstream, another to your switch… and your TrueNAS is then connected to the switch.

It’s nice to be able to use TrueNAS snapshots to rollback your router if you choose :wink:

The problem is losing internet when you update TrueNAS :wink:

2 Likes

With Proxmox, you can set your storage disks as passthrough devices to your TrueNAS VM to alleviate your concerns here. I ran TrueNAS Core for years in this configuration and it worked without issue.
https://pve.proxmox.com/wiki/Passthrough_Physical_Disk_to_Virtual_Machine_(VM)

it’s interesting how every forum needs to have one of you - someone that replies to every topic but brings zero value :tada:

as far as I am aware it was introeduced in scale? plus is super unbaked, feels like something that was added recently, if it was there for 7 + years, thats quite concerning…

You put TrueNAS behind something like Opnsense

did you read my post in its entirety?

Ya but you will run into bootstrapping issues as you would have to access everything from a jail and not the host directly

I can see you are not even using TrueNAS scale… no worries, but scale experience might be a bit better here
do you have experience with scale? how would you set it up in this case?
thanks …

__
on a broader topic
I am really concerned with the amount of low quality flame posts on this forum…

So glad you joined this forum to lecture us. ā€œI don’t like the answerā€ is not the same as ā€œthe answer wasn’t helpful or valuable.ā€

I answered your questions, clearly, correctly, and succinctly: TrueNAS (CORE or SCALE) does not have, never has had, and in all likelihood never will have any firewall capabilities. If you want them, you’ll need to use a different system, perhaps in a VM though that really isn’t ideal. If you have further questions, feel free to ask them, preferably after searching both this and the old forums and reviewing the docs. But I don’t think you’re going to need to worry about my ā€œzero valueā€ responses in the future.

First of all - thatnks for a constructive answer
Right, what is your experience with this setup? Do you prefer OPNsense or pfSense and why? I have been contemplating this as - seemingly the only reasonable option, but not entirely sure how it should be setup.

I might be able to get up to 3 x NIC for my server plus a switch if needed…

What do you mean about loosing internet? As I’ve stated its a server in a datacenter, so, idealy I would want TrueNAS to have always on internet connection and have VM’s go thry a firewall. I can lock TrueNAS everything to my personal IP so that fixes the access and security to the main server.

I was thinking something in line with

TrueNAS - connects directly to the datacenter router
VM’s and pfsence go to a switch and from it to the datacenter router

Would this be feaseable?

I would still prefer to skip pfsence if possbile, and do the routing in the freenas os if possible , so I’ll just state this again, but – as far as I can tell - its not quite as possible?

well my friend, I joined to find a comunity of people dabbling in TrueNAS wizardry, but - I’ve had experiences with people posting like you do before. Usually very low on knowledge or skill, but quick to flame topics. So I know what I am up for. Thank you for your contribution so far, and have a lovely day

Experience was succinctly provided above :wink:

I’ve been running this setup for about 8 years on a variety of TrueNAS installs.

I use pfsense, but should probably switch to OPNsense

You setup a router/firewall as a vm. The nas is then connected to the vm for internet. Or whatever. Thus when the vm is not running… no internet.

In my setups the entire lan runs through that router vm.

A valid approach.

It may be possible, it I wouldn’t recommend it. In my experience attempting to bend TrueNAS to your will like that doesn’t end well.

Install containers, dockers, VMs and sandboxes on top of the TrueNAS foundation and use those to effect your requirements.

1 Like

well that’s very reassuring!
why do you want to switch to OPNsense? I was leanin more towards pfSense but appreciate your opinion on this?

Right, I’ve seen people do it this way before, but in my case it might be more beneficial to have NAS be directly conneted, and have VMs go thru a router, this way I dont loose NAS access after updating it (again - datacenter)

Thanks :smiley:
How would I handle docker containers in this case? Can I force them go thru a firewall as well? On a broaded note, do you find this setup a bit convoluted compared to lets say proxmox virtualisation where theese options are readily avaliable already? I am leaning more towards turenas, as I like the idea of my data being the baremetal layer, but am aware that all of theese things could be done somewhat easier on a different OS… so if you had some experience / oppinions in this regard too it would be much appreciated :hugs:

yeah, I agree with that, hacking a NAS seems like a pretty bad idea
I was wondering if there was a way that is less hacky, and more… ā€˜in line’ sort of… but I guess not perhaps… …

right.

BTW – since you have extensive experience testing this setup with a VM router, what are your worst experiences? other than loosing intenrnet ? have you had things break pretty bad, and how? what should I know before going forward with this

Right, I know about this, and - maybe it is even a more recommended setup than the one I am thinking of pursuing…

could you go into detail why you would recommend going this route, as opposed to truenas scale for both? *(more power obviously…)

would you personally consider using truenas scale for both, since you already have experience with your setup where you use proxmox for vms? what would you miss the most, and what would be a dealbraker / hard to mitigate - thing?

thanks

It honestly works pretty well.

As said, I put everything physically behind the router, by having the nas run to a switch that runs back to a separate port on the hardware which is passed into the virtual router.

The biggest issue was starting other VMs after the router was up… which I solved with a script.

But I also have BMC IPMI on the management interface.

Having hardware in a data center where you don’t have hands on…

wow amazing

I can reach the server with a console even it the network breaks , but I am not very keen on doing so …

so, I have a question, even in this setup, when you update truenas, if you have your router set to autostart, than, your truenas should get back up to internet, even if - it looses connection briefly, right? or no?

Yes