Notes on Virtualbox 4.3.30 and OS X 10.8.5 for CentOS 7

Virtualbox 4.3.30 on OS X 10.8.5 with CentOS 7 guest VMs work ok on my notebook for web development, but setup was a little fussy.

I use VMs for:

  1. general web development and testing, to stay off the production environment
  2. destructive performance testing (intrusive changes to source code and configurations that require VM rollback to undo, most of which will never be commmitted.) This is great for work on profiling, i18n, caching, mod_rewrite rules, etc.
  3. accelerating automation testing, since a VM can boot in 10 seconds on my Mac with SSD, and VM creation is scriptable. This is a huge win.
  4. working offline (no-Wifi areas.)


  • “Host” is your Mac notebook. It runs Virtualbox under Mac OS X.
  • “Guest” is the VM running under Virtualbox. A guest can be any operating system, but in this case we’re using CentOS 7.x.

Getting Started

  • check Internet for known software issues first
  • update to the latest version of Virtualbox

Choose Network Topology

I wanted to run my web site in a VM, viewable from the Mac browser and have the VM be able to run ‘yum update’, so needed host => guest and guest => Internet routing. There’s 2 networking choices that match those requirements:

  1. Bridged – easiest and works best if a Mac network adapter is always connected, like in the office, or at home if your Wifi access point is always on
  2. NAT – always works, but you have to NAT from host => guest (ie. => You can use Mac’s ipfw or ipf firewalls to then NAT from 80 to 8000, making it seamless:

    sudo ipfw add 100 fwd,8080 tcp from any to any 80 in


  • under “Machine … Settings”, choose “Bridged Adapter”
  • guest IP address will come from Virtualbox DHCP server, usually the guest IP address is
  • on the host, you just use the guest’s real IP address from above
  • if you bridge to the Airport interface (en0), and the host Wifi is off, you lose your guest lease (ie. no routing inside or outside guest VM)
  • binds to a host’s physical interface (conceptually speaking)
  • no NAT needed or available in Virtualbox settings
  • the Virtualbox DHCP address is 192.168.x.100


  • under “Machine … Settings”, just choose NAT, not “NAT Network”
  • guest IP address will come from Virtualbox DHCP server, usually or
  • host IP address will be (NATTed to guest address above)
  • click on “Port Forwarding” button and use host ports above 1024 (usually 2222 for ssh and 8000 for HTTP)


  • the Virtualbox manual is a reference, not a tutorial. After reading this blog post, the manual is useful to fill in details.
  • disable CentOS 7 firewall with ‘service firewalld stop’
  • view CentOS 7 interfaces with ‘ip a’
  • if one networking topology doesn’t work for you, try another. No need to reboot the VM.
  • if you spend more than an hour without success, try VMware Fusion. It covers my use case automatically.


  • do ‘tail -f /var/log/messages’, disable “Cable Connected”, click “OK”, and watch as DHCP lease is lost. Then click on “Cable Connected”, click “OK” to restore
  • if using Bridged on en0, do ‘tail -f /var/log/messages’, do “Turn Wi-fi Off” on Mac, and watch as DHCP lease is lost. Then turn Wifi back on.

Network Security

  • use strong passwords if you value what’s inside the VM
  • enable guest firewall with ‘service firewalld start’
  • TCP wrappers is an easy and effective filtering method



    ALL: ALL

Simulating Production

You can update /etc/hosts to have your browser access your web site in a VM:


# Bridged

But I find that Firefox gets less confused with permanent redirects, etc. by prefixing the hostname:


# Virtualbox NAT Topology (don't forget to use ports 2222 and 8000 from host => guest!)
# Virtualbox Bridged Topology


Take advantage of Virtualbox’s clone and snapshot features. What does “Cable connected” checkbox change?
Port Forwarding in Mac OSX Mavericks
Port Forwarding in Mac OS Yosemite

This entry was posted in Linux, Open Source, Oracle, Tech. Bookmark the permalink.

Leave a Reply

Your email address will not be published.

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