Connect ESXi Host Directly to FreeNAS
Published on June 03, 2020
I have two servers: an ESXi host running several VMs and a FreeNAS server for backup storage. Each one has two physical NIC's.
Goal: establish a network between the two hosts that is strictly for ISCSi traffic between ESXi and a ZFS volume on FreeNAS
Create a ZFS on FreeNAS
- From the FreeNAS web UI, open Storage > Pools > Add
- Create a new ZFS volume called "backup2" (figure 1)
Configure Second NIC on FreeNAS
From the FreeNAS web UI, open Network > Add
Configure the second NIC with an IP address on a different network from the primary interface (figure 2)
Autoconfigure IPv6: Yes
IP Address: (e.g.) 192.168.3.200
Configure iSCSI for backup2
- From the FreeNAS web UI, open Sharing > Block Shares (ISCSI)
- Create a new portal group or edit the existing one to include the IP address of the secondary NIC (figure 3) and Save
- Create an initiator for ESXi, using the expected IP address of the ESXi host's second NIC
- Create an iSCSI Target called "backup2" that uses the portal group from step 2 and the initiator from step 3
- Create an extent for the "backup2" zvol
- Create an associated target that connects the backup2 target with the backup2 extent. Set the LUN ID to an otherwise unused number
Configure Second NIC on ESXi
Create a Virtual Switch for iSCSI using the unused NIC
Create a new Port Group for iSCSI, VLAN ID 0
Create a new VMKernel w/ the iSCSI Switch and the iSCSI Port Group
IPv^ Autoconfigure: Yes
Connect ESXi to the backup disk on FreeNAS through iSCSI
From the ESXi host, navigate to Storage > Adapters
Click "Software iSCSI" and enter the IP address of the second NIC on the FreeNAS server as a Dynamic Target, then click "Save Configuration" and wait a few moments for the ESXi host to initiate a connection to the FreeNAS host
Rescan and Refresh adapters, then click "Software iSCSI" again. Now, if the configuration is correct, the Freenas host will appear in the "Static Targets" section of the form.
You should also now see the FreeNAS iSCSI disk appear on the "devices" tab of the Storage control panel.
If it says "Normal, Degraded" under the Status column, this is because there is not a redundant network connection to the iSCSI host. Adding a second uplink to the vSwitch that services iSCSI would resolve this issue, but otherwise it should be fine in normal home lab circumstances.
You should also see the backup2 disk on the Datastores tab of the Storage control panel.
Now you can browse the disk from the ESXi web interface and use it to store VM images, hard disks, and other resources.
ESXi has no knowledge of the state of the FreeNAS server so you must be conscious of when ESXi is using resources located on FreeNAS. If FreeNAS shuts down or the connection with ESXi is lost unexpectedly, active VM's on ESXi will continue to run in an error state and data loss may occur.
As long as ESXi is not using resources on FreeNAS is it acceptable to shut down the FreeNAS server. ESXi will show error messages as it can no longer reach the iSCSI host, but they will go away once the connection is re-established.