incomplete
VirtualBox Networking
Do you know vmWare player? With trainloads of running services even if you do not need them?
Well, this has advantages and disadvantages. The advantage is that the vmWare interfaces are running like real interfaces. So you can use them even if no VM is running. The disadvantage is, the services always are loaded in RAM, on boot time, so they always eat precious resources.
VirtualBox runs everything on demand when it is needed. Only the raw interface stays as it is, but there is no functionality loaded. This is good news.
When you start VirtualBox, nothing is startet either. So if you want to look at something, start something which needs something, the processes needed are then started automagically and then you can see all the process parameters. It is enlighting to look at the commandlines in RAM to see what's wrong. Easy debugging. Nice again.
Virtual Host Only networks
Under Global Settings you can find virtual network adapters. (This is nearly the same as you might know it from vmWare.)- The default one is called "VirtualBox Host-Only Network".
- The names are automatically numbered and it looks like you cannot change the interface name (under Windows). Note that you can rename the network names in Windows network settings, but the interface name is fixed.
- There is "VBoxManage hostonlyif create" command, but it is lacking a interface name option, too. So it looks like we have to live with those strange and hard to comprehend interface names for now.
- By default, they use a /24 of the range 192.168.0.0/16
- All adapters are "Host-Only" which means, they are like networks which are not connected anywhere but to the Host.
- They cannot directly communicate to the outside world, but they can communicate with the Host, of course, and with each VM which is accessing the same virtual interface.
- So you have to place your own (virtual) router into such a network to be able to have a fully routed subnet. This is very natural.
- If you need more than just DHCP, you probably(!) need your own (virtual?) DHCP server on such a subnet. For now I really have no idea how to control the DHCP server besides what is obviously implemented in VBoxManage. (There are some "secret" settings for DHCP, but I did not find a usable reference to them yet on the net.)
Other types of networks
VirtualBox provides 3 additional interfacesVirtualBox NAT interface
This interface is the default interface for Guests and very good documented in the VirtualBox help file. (This differs from how you might know it from vmWare.)- It is implemented on VirtualBox level. It has not much to do with the NAT built into Host, so it does not break your network settings, it just works.
- NAT is limited to what it can do. ICMP (ping) is said to work, TCP works too, of course, but already UDP has limited support. So on NAT you probably have problems with commands like "traceroute", "bing" or "nmap".
- The Host is not part of this NAT network, so you cannot connect from the Host to the Guest. While this might be annoying, as you cannot use Putty (and copy&paste) to connect to the Guest out of the box, this is an quite interesting feature. (A possible fix is, give the Guest a second HostOnly interface.)
- Under Linux all NATs of all users are separated in different IP ranges.
- The Host is not protected against the VMs, Guests can connect to the Host because NAT can access all interfaces accessible by the host.
- The helpfile tells how to change the IP of the NAT using VBoxManage. By default is uses a /24 out of the range 10.0.0.0/8
- Port forwarding is possible, however under Linux you cannot forward privileged ports as non-root user.
- I did not look how it is implemented under Linux. I expact that you can shield the Host against Guests using firewall rules.
- I did not check if Guests can communicate to each other on the NAT interface. I expect that this is possible, else user separation would not be needed.
- This section needs more examples.
- Is DHCP covered by the helpfile?
- Is it possible to have more than one NAT interface? I doubt.
VirtualBox Bridged Networking
There is a bridge implemented into VirtualBox, too. (This differs a bit from how you might know it from vmWare.) With this the Guest virtually sits on the same default interface as the host.- Look into the helpfile, there are important notes to Bridged networking.
- There is a way to bind the bridged interface to another adapter than the one the default route points to. I just do not know how.
- Is it possible to have more than one bridged interface? I doubt.
- It is probably a bad idea to run VirtualBox DHCP on such a bridged network, so it looks like it is not supported anyway.
VirtualBox Internal Networking
This is "Bridged Networking" without the bridge to the host.- This is a pure virtual interface, never seen by the Host, as it is not attached to any network. Only Guests can communicate on this network.
- You can have more than one internal network. They are identified by their name, this can be changed by the GUI or (untested)
VBoxManage modifyvm "VMNAME" --intnet0 "name"
- You can enable DHCP on this interface using something like (untested)
VBoxManage dhcpserver --netname --ip 0.0.0.0 --netmask 255.255.255.0 --lowerip 0.0.0.100 --upperip 0.0.0.199
VirtualBox other networking options
There are plugins providing other types of networks. I have never seen any, but one is described in helpfile.DHCP for IPv4
The important part is, that there is a DHCP server for such an interface. You probably want to change the IP of the adapter and the DHCP. And this is the tricky part.- Be sure that no VM uses the adapter you want to configure (such that the DHCP does not run). I had some bad lockups when this was the case.
- Then configure the IP of the adapter. Note that you can edit the IP on the standard windows setting, too, this should make no difference.
- You can enable DHCP for the interface. But the DHCP server only runs if a VirtualBox runs on such an interface, so you cannot use DHCP to configure the host (which does not make much sense)
- The important thing is that the DHCP server needs a differnt IP than the host! For example if your host is at .254 then put the DHCP to .253 or similar. Note that I usually put the routers to .254. Note that if you give the DHCP the same IP as the host (the interface) then you will see an IP address conflict and for example Windows will stop using the IP (that's a nice DoS, BTW).
- Set the netmask (normally the same as for the interface) and set the IP range the DHCP server shall hand out. That's straight forward.
- If you use Internet Connection Sharing then you (probably) do not need the VirtualBox DHCP running on the interface. However I did not try this yet.
- There is no safety net. If you do it wrong, it still works, but stays plain wrong, so nothing reasonable happens.
- I did not find a way to let the DHCP offer a gateway. So the DHCP does not have a default route.
- I did not find a way to specify "next server" (for PXE etc.). So if you need that, you probably must run a different DHCP for that.
- For PXE see PXE boot
- I am not really sure where the MAC address of the DHCP server hides. I did not look for a way to change the MAC of the VirtualBox network interface yet, but I think that should be possible.
IPv6
Well, I am not sure about this, as I did not test it yet.- For IPv6 you do not need DHCP. IPv6 uses autoconfiguration.
- IPv6 autoconfiguration is usually done via the MAC address (which is assumed to be unique WW). The adapter has got a (randomly chosen) MAC address, so that's no problem, however I am not sure the MAC really is a unique one.