Part 4: Configure Networking
You cannot connect to the new VMs yet. CBSD creates a
bridge interface the first time you create a VM. We need to add gateways for our cluster VLANs to that interface so we can route from the hypervisor to the VMs and vice versa. In most cases, CBSD will use the
4.1 Add Bridge Gateways
Note that these changes will not survive across reboots. I have not tested if adding a persistent entry for
/etc/rc.conf would work as expected with CBSD, as it manages the
4.2 Configure NAT
We can reach our VM just fine from the host, but the VMs can’t talk to the Internet because only the FreeBSD host can route to this
10.0.0.0/8 block. We will use
ipfw as a NAT (Network Address Translation) service. These steps will enable
ipfw with open firewall rules and then configure the NAT. These changes will take effect immediately. The service and kernel settings will persist across reboots, but the
ipfw firewall rules will not. See the
ipfw chapter about how to create and enable a firewall script.
Note that my host’s physical interface is named
em0. You may have to alter some commands if yours has a different name.
4.3 Configure Local DNS
We need a way to resolve our VM host names. We need to pick a private
.local DNS domain, configure an authoritative server for the domain, and then set up a local caching server that knows about our domain but can also still resolve external addresses for us. We will follow this
unbound tutorial closely.
unbound for recursive/caching DNS
FreeBSD has a caching (lookup-only) DNS service called
unbound in the base system. It will use the configured nameservers for external address lookups and the local
nsd service (configured next) for lookups to our private zone. Copy
unbound.conf and make any edits as necessary to IP addresses or your local zone name.
You will also want to update the FreeBSD host’s
/etc/resolv.conf to add your local domain to the
search list and add an entry for
4.3.2 Configure the Authoritative DNS Service
We will use
nsd, a lightweight, authoritative-only service, for our local zone. After copying the files, you can edit/rename the copied files before proceeding to make changes as necessary to match your local domain or IP addresses.