FreeBSD, Software

Setting up FreeBSD environment on virtualbox

Hi all, In this post we will review the procedure of setting up FreeBSD environment on virtualbox along with setting up Internet on the guest OS(this was pretty tricky!).BTW, my host OS is Ubuntu 14.04

So, i am assuming you have already installed virtualbox as per your host OS and has downloaded the FreeBSD amd64 iso image(If not you can do it from here and extract it appropriately to get a .iso file.

Installing FreeBSD on virtualbox

Installing FreeBSD on virtual box is pretty straight forward, just insert use the downloaded iso to boot up the VM with default hardware settings for 64 bit FreeBSD OS. Following will be the bootup window:

Just press enter and follow default procedure. Don’t attempt to configure network adapter at this stage ww’ll do it later after complete installation.

Note: Please don’t forget to remove the installation disc from virtual machine settings after complete installation. Otherwise, every time during bootup it will recall the install procedure.

Setting up Internet

We will be setting up host only adapter. Here’s the common disadvantages of different type of network adapter types available:

NAT
Requires port forwarding if you want to connect to the vm from the host.

Host-only
The vm can not access the internet, unless the host is a router.

Bridged
Exposes the vm to the network; not portable.

Adding a virtualbox Host-only adapter

In VirtualBox > Preferences > Network, set up a host-only network.

 

Click on scredriver icon to edit the adapter settings. Add a new adapter if vboxnet0 isn’t available

 

Disable DHCP server. Ckick on Ok and reboot the machine.

Also, on machine settings under network tab, select the settings as shown:

 

On host OS(Ubuntu)

After these, you can verify the configuration by netstat and iptables as

On Guest OS(FreeBSD)

First check the interfaces available to FreeBSD by ifconfig:

so, my interface name is em0.

Then, we need to edit rc.conf file by ee /etc/rc.conf and add the below line to rc.conf

So, finally here’s how my rc.conf looks like:

Then reload the configurations by running /etc/rc.d/netif restart

Now final thing needed to be done is adding a default gateway which can be added like :

That’s it it should now work! try ping 8.8.8.8.

Configuration can be verified by netstat as:

Notice the gateway mentioned. If gateway is not correctly setup errors like “no available route” will appear. Try pinging 192.168.56.1, if it worked and you still have no internet access you probably did some misconfig during packet forwarding in ubuntu.

Above procedure works for me, however, i had several issues while trying out other tutorials on internet. I guess, the best thing that help me debug out the problem was, Wireshark! It’s really awesome. Don’t hesitate to debug out problems and comment here with complete log in case of failure. Thanks.

Update:

Several common errors/issues:

SU:Sorry

Initially, with raw installation switching to root will give this error. One possible solution for this is to boot FreeBSD in single user mode and then enter the following commands:

and now, switching to root should work!

SSH From Host(Ubuntu) to Guest OS(FreeBSD in VirtualBox)

For this you should first have sshd_enable option enabled in your /etc/rc.conf file.

Then you need to add a port forwarding rule to VirtualBox network option like:

Now simply try ssh from your host machine like: ssh -p 2222 user_name@127.0.0.1 . If it shows ssh_exchange_identification: read: Connection reset by peer error try reloading rc.conf settings or restart the guest os.

References:

Tagged ,

3 thoughts on “Setting up FreeBSD environment on virtualbox

  1. If you want a FreeBSD distribution with a GUI you have these options (All come with a graphical installer similar to FreeBSD):

    http://www.trueos.org – iXsystems has been sponsoring FreeBSD for a long time now. This is a rolling release from the CURRENT branch so it has all the latest Video Drivers. This has ZFS and a ton of bells and whistels turned on by default. The default desktop isn’t everyones cup of tea (it’s new but it’s getting very good) but that can be easily changed using the package manager (is it still called AppCafe?). *warning* – I’ve had trouble developing on this in the past, especially with RTEMS.

    http://www.ghostbsd.org – This is a distro by a ericbsd. Currently he is matching RELEASE. Everything is nice and stable so far. I’ve got the RTEMS erc32 building on this platform. Ericbsd has been at this a while and has contributed alot to installers. Not surprisingly, he’s been hired by ixSystems! The consequence is he’s looking to port over to the TrueOS base on the CURRENT branch. I’d like him to support CURRENT too, so if you’re keen, you should step onto the forums (forums.ghostbsd.org) and spark up the conversation.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.