Integration of a VirtualBox VM into a LAN
Posted: 24. Nov 2010, 11:29
Hello,
I use VirtualBox 3.2.10 on a Host running Wndows 7 Pro 64 bits. I defined a virtual machine (VM) Ubuntu 10.10.
I would link this VM into the LAN.
The easiest solution (which was proposed by chopinhauer, in the french forum //forum.ubuntu-fr.org, whom I thank again) is to establish a network bridge in VirtualBox and in Windows 7.
1. In the settings of the VirtualBox VM (the VM being shut down), go to Network setting.
Adapter 1 (where "Activate the network adapter" is marked) [Sorry if my translation from French settings to English is not perfectly exact ; I use a french version].
In the field "Network access mode", NAT is prompted. You need to change it to "Bridge access". After, in my case, "MAC Bridge Miniport" appeared automatically in the field Name. It's not the usual situation. You would have automatically the name of your adapter, the Guest's physical adpater (in my case a Realtek one). If you have the name of your physical adapter, that's good : you have not to do the second step. In my case, I had not my physical adapter, probably because of a bad installation. If you have not (if you have MAC Bridge Miniport, don't worry : the second step will salve you.
Come back to the general settings page. You see now, for Network Adapter 1, "Intel PRO/1000 MT Desktop (bridge with the MAC Bridge Miniport interface)", or, better, instead of MAC Bridge Miniport, the name of your physical interface.
2. Do this step only if your physical adapter was not prompted in the first step and you have MAC Bridget Miniport instead. On the Host, in Windows 7 :
Go to Network and Share Center (by Configuration Pannel), and do "Modify parameters of the network adapter". Define a network bridge between the 2 adapters : the Host's physical adapter and the adapter "VirtualBox Host-Only Network". To do this, select both adapters (click on one, and Ctrl-Click on the other). Do a right-click on this selection and click on "Bridge connections".
An icon "Network bridge" is added. Few seconds later, the authentication will be done and the bridge will be usable.
In VirtualBox, when you start now the VM, le DHCP server of the LAN sets automatically to the VM an IP address of the LAN.
So, the VM (in my case, an Ubuntu) is now a station of the LAN and it can communicate with all other stations of the LAN.
There is another solution, a classic one, but I could not set it up : a route between 2 LANs. I explain it.
The default for the VM's adapter 1, in VirtualBox, is NAT (see above). In this case, VirtualBox sets to the VM an IP similar to 10.0.2.15 and it sets also to the Host a second IP as 10.0.2.2. So, the VM and the Host are members of a new network 10.0.2.0, added to the previous LAN 192.168.0.0 for instance and the Host is like a router (router being a machine on to LAN).
Thus we have 2 LANs which we have to connect by a route.
From the VM to the 192.168.0.0 LAN stations, the route is automatically established : you can ping all the stations of the 192.168.0.0 LAN. But, from the LAN stations to the VM, the ping does not pass. It is necessary to establish the routing on each stations (at least, it is so in Linux stations ; I did'nt try on Windows stations).
On Linux stations (Ubuntu 10.10), you have to do (being root ; in console mode, sudo su) the command :
route add -net 10.0.2.0/24 gw 192.168.0.2 (this last one being the Host's IP).
This would run (prompting the route table by route, you see that the routes are good).
But, in my case, this worked one time only ; in all others attempts, I allways had the answer to the ping :
From 192.168.0.2 : icmp_seq=1 Redirect Network (New nexthop: 192.168.0.1) this last one beeing the IP of the Netgear router which set the access to Internet and DHCP service for the LAN ; this IP is defined, in the route table, as the default.
I cound'nt solve this problem and I left it, because the network bridge solution is very easier.
I use VirtualBox 3.2.10 on a Host running Wndows 7 Pro 64 bits. I defined a virtual machine (VM) Ubuntu 10.10.
I would link this VM into the LAN.
The easiest solution (which was proposed by chopinhauer, in the french forum //forum.ubuntu-fr.org, whom I thank again) is to establish a network bridge in VirtualBox and in Windows 7.
1. In the settings of the VirtualBox VM (the VM being shut down), go to Network setting.
Adapter 1 (where "Activate the network adapter" is marked) [Sorry if my translation from French settings to English is not perfectly exact ; I use a french version].
In the field "Network access mode", NAT is prompted. You need to change it to "Bridge access". After, in my case, "MAC Bridge Miniport" appeared automatically in the field Name. It's not the usual situation. You would have automatically the name of your adapter, the Guest's physical adpater (in my case a Realtek one). If you have the name of your physical adapter, that's good : you have not to do the second step. In my case, I had not my physical adapter, probably because of a bad installation. If you have not (if you have MAC Bridge Miniport, don't worry : the second step will salve you.
Come back to the general settings page. You see now, for Network Adapter 1, "Intel PRO/1000 MT Desktop (bridge with the MAC Bridge Miniport interface)", or, better, instead of MAC Bridge Miniport, the name of your physical interface.
2. Do this step only if your physical adapter was not prompted in the first step and you have MAC Bridget Miniport instead. On the Host, in Windows 7 :
Go to Network and Share Center (by Configuration Pannel), and do "Modify parameters of the network adapter". Define a network bridge between the 2 adapters : the Host's physical adapter and the adapter "VirtualBox Host-Only Network". To do this, select both adapters (click on one, and Ctrl-Click on the other). Do a right-click on this selection and click on "Bridge connections".
An icon "Network bridge" is added. Few seconds later, the authentication will be done and the bridge will be usable.
In VirtualBox, when you start now the VM, le DHCP server of the LAN sets automatically to the VM an IP address of the LAN.
So, the VM (in my case, an Ubuntu) is now a station of the LAN and it can communicate with all other stations of the LAN.
There is another solution, a classic one, but I could not set it up : a route between 2 LANs. I explain it.
The default for the VM's adapter 1, in VirtualBox, is NAT (see above). In this case, VirtualBox sets to the VM an IP similar to 10.0.2.15 and it sets also to the Host a second IP as 10.0.2.2. So, the VM and the Host are members of a new network 10.0.2.0, added to the previous LAN 192.168.0.0 for instance and the Host is like a router (router being a machine on to LAN).
Thus we have 2 LANs which we have to connect by a route.
From the VM to the 192.168.0.0 LAN stations, the route is automatically established : you can ping all the stations of the 192.168.0.0 LAN. But, from the LAN stations to the VM, the ping does not pass. It is necessary to establish the routing on each stations (at least, it is so in Linux stations ; I did'nt try on Windows stations).
On Linux stations (Ubuntu 10.10), you have to do (being root ; in console mode, sudo su) the command :
route add -net 10.0.2.0/24 gw 192.168.0.2 (this last one being the Host's IP).
This would run (prompting the route table by route, you see that the routes are good).
But, in my case, this worked one time only ; in all others attempts, I allways had the answer to the ping :
From 192.168.0.2 : icmp_seq=1 Redirect Network (New nexthop: 192.168.0.1) this last one beeing the IP of the Netgear router which set the access to Internet and DHCP service for the LAN ; this IP is defined, in the route table, as the default.
I cound'nt solve this problem and I left it, because the network bridge solution is very easier.