FreeNas: How to Bridge Nics like a Switch and DHCP-serve them

Discussion in 'Guides' started by RageBone, Aug 6, 2019.

  1. RageBone

    RageBone Active Member

    Jul 11, 2017
    Likes Received:
    In the wake of the Jellyfish "it just works out of the box etc BS", scenario is as follows.

    You have a FreeNas box with multiple Nic-ports that you are directly connecting to the client devices.
    Possibly a 10Gbit Rj45 or in my case, Mellanox CX3s set to 40GbE.

    For maximum comfort, all clients should be able to reach the NAS under the same IP.
    That is Behavior of a network-switch with the exception that a separate one, is a bit much when the NAS can be made to behave the same.
    For instance additional NICs for the NAS-switch could cost less then a respective network-switch.
    This doesn't take up additional space and might be lower in power-consumption.
    One apparent downside to this solution is that all clients can now also reach each other through the NAS, and all of this puts more load on the NAS, but for me that isn't of concern.

    Why should you need to manually configure the clients IP?
    Automatic configuration of IP addresses via DHCP it is!
    In addition, PXE enables the clients to boot from the NAS if desired and configured.

    Lets begin with the configuration of FreeNas as a "Switch".
    The Bridge Interface.
    Since FreeNas is an appliance and scripts can't simply be put and executed on it, the following are my System-Tunables.
    Format is variable, value, type. comment and enable are up to you.

    cloned_interfaces, bridge9, rc
    ifconfig_bridge9_aliases, inet IP/Mask, rc
    ifconfig_bridge9, addm Nic1 addm Nic2 .... addm NicX , rc
    It might be necessary to UP all the devices, just in case you run into issues where things aren't ping-able. For example
    ifconfig_NicX, up, rc
    bridge9 because FreeNas itself creates bridges and taps "on the fly" for VMs and other stuff, so i chose that number to not be in direct conflict.

    FreeNas sadly isn't jet able to create Bridges in the UI, or list them, or use their IP as a selection anywhere.
    Shares need to be bound to to also be reachable by the bridge.

    The DHCP Server
    In short,
    FreeNas doesn't come with some kernel-modules needed for DHCP to work, Jails won't therefore work.
    So create a new VM with what ever OS you like, FreeBsd in my case. There is sadly no way around a VM that i know of.
    Add a Tap device to the cloned_interfaces and addm parts of the Tunables "tap9" for example and add it to the VM.
    The order of devices of the FreeNas dialog will be the same as inside the VM, and tap devices are easily addable there.

    Install your dhcpserver of choice, dnsmasq in my case, and configure it for your IP range on the tap interface.
    Add a static IP to the passed Tap device inside of the VM, start and enable autostart of the dhcpserver inside of the VM, and of the VM and you are Done.
    You should now have everything working.

    Did i miss anything?
    And yes, I'm not the first to write about this, but i thought it is time to share this little setup that seems so simple, still is way to complicated and not enough supported by FreeNas and UI, and maybe keep others from wasting time on BS.
    Like getting DHCP working inside a Jail.
    gb00s likes this.
  2. RageBone

    RageBone Active Member

    Jul 11, 2017
    Likes Received:
    support for bridging is now native in Freenas 11.3
    Last edited: Mar 17, 2020
    Patrick likes this.
Similar Threads: FreeNas Bridge
Forum Title Date
Guides Linux nmcli: how to configure a bridge on a team interface Jan 26, 2018

Share This Page