I mentioned in an earlier post that it is possible to use the command line to set the particular bridge adapter required to run VirtualBox, resolving an error that aborts start-up of the virtual machine.
Which adapter is in use depends on how the host machine is expecting to connect to the internet, even if it is not actually connected at the moment. Different airport and ethernet cards identify themselves using (in theory) different MAC addresses and will be assigned different BSD interface names, "en0", "en1", and so on. (These names are always of the format [letters][integer].) Since interface names are assigned at system start-up, they may occasionally be different from what you are used to seeing, so it is not a good idea to treat them as fixed.
To direct VirtualBox to use a particular interface — en0
, for instance
— for a virtual machine "himself", use
vboxmanage modifyvm himself --nic1 bridged --bridgeadapter1 en0
at the command line.
But sometimes it isn't easy to figure out which interface to use. On models of MacBook Air that have no built-in ethernet card, an external (USB) ethernet adapter is needed, and different USB adapters will have different MAC addresses, meaning that they will each be assigned different interface names. How do you know which interface name should be passed to VirtualBox?
Active interface names are reported by the network interface
configuration tool ifconfig
when run without options. You can pipe
that output through awk
to return just the active en-
interface name
to standard output:
ifconfig | awk -F: '/^en/ { print $1 }'
If you like, you can pass the output of that whole expression to
vboxmanage
in a one-line instruction:
vboxmanage modifyvm himself --nic1 bridged --bridgeadapter1 `ifconfig | awk -F: '/^en/ { print $1 }'`
That should configure VirtualBox correctly so that the virtual machine
will boot successfully. The only caveat is that if the virtual machine
is already running, you will get an error. Occasionally, when even
running ipconfig getifaddr
does not return an IP address for the
active interface name, I have found it helpful to reboot my hardware and
run the filesystem consistency check, fsck
.
[end]