danb35 / freenas-iocage-nextcloud

Script to create an iocage jail on FreeNAS for the latest Nextcloud 28 release, including Caddy, MariaDB or PostgreSQL, and Let's Encrypt
GNU General Public License v3.0
252 stars 71 forks source link

Script does not respect "vnet_default_interface" parameter in config file #143

Closed omid-1985 closed 3 years ago

omid-1985 commented 3 years ago

I'm running nextcloud jail in a separate em0 network interface (not VLAN, and not to be confused with INTERFACE or JAIL_INTERFACE parameters). If I create jail manually and set vnet_default_interface to em0, everything does work, and it communicates with my DMZ network. However, since there is no vnet_default_interface parameter pull from config file, adding vnet_default_interface="em0" or vnet_default_interface=em0 in config file create a nextcloud jail with vnet_default_interface=auto and therefore script fails to communicate with DNS server. Screenshot from 2020-09-09 13-01-23 Screenshot from 2020-09-09 13-00-36

omid-1985 commented 3 years ago

Fixed my issue by adding: vnet_default_interface="em0" dhcp="1" at the end of this line: if ! iocage create --name "${JAIL_NAME}" -p /tmp/pkg.json -r "${RELEASE}" interfaces="${JAIL_INTERFACES}" ip4_addr="${INTERFACE}|${IP}/${NETMASK}" defaultrouter="${DEFAULT_GW_IP}" boot="on" host_hostname="${JAIL_NAME}" vnet="${VNET}" vnet_default_interface="em0" dhcp="1"

Also, in my DHCP server, added jail MAC address to reserve the same jail IP address that I entered in nextcloud-config. For some reason selecting different NIC port for jails on FreeNAS causing ping to public domain fails if I use static IP in jails, that's why I had to add dhcp="1" for jail.

omid-1985 commented 3 years ago

Anyone who my above comments might mislead them, PLEASE DO NOT USE the above method for putting DMZ NIC on your Freenas for security reasons! Methods above will work, but it adds your DMZ nic in bridge0 next to the other interfaces which is at odds with the DMZ principle. The correct method to have an isolated NIC for jails is to create new Bridge in your FreeNAS interface (for example bridge22) with your separate NIC as a member. Then only use JAIL_INTERFACES parameter to assign it into your jail. For Example: JAIL_INTERFACES="vnet0:bridge22"

devinitnz commented 3 years ago

I found this helpful, thank you. In my case I am using link aggregation, and VLANs. I found setting the vnet_default_interface="none" in the jail script and using JAIL_INTERFACES="vnet0:bridge22" in the nextcloud-config produced the results I needed. Would be helpful if the "vnet_default_interface" was a configurable option.