Proxmox VE inside VirtualBox: Difference between revisions

From Proxmox VE
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
= How to install  =
= General =
 


* WARNING: ''Article in development''
** '''There are several issues with the networking in this article though the bit of "install inside VirtualBox is okay'''"
*** You can install using Bridging while we sort this out, but this will not survive network changes.
** For general setup, please comment on http://forum.proxmox.com/threads/19966-Proxmox-under-Virtualbox
** For network issues, http://forum.proxmox.com/threads/20054-Proxmox-under-Virtualbox-no-outbound-networking
* Instructions assume VirtualBox 4.3.16 or higher
* Instructions assume VirtualBox 4.3.16 or higher
* Much credit goes to the authors of the article on orestad-linux.se
* The article refers to Proxmox VE 4.x (i.e. for lxc containers only, OpenVz is not supported any more)


== Motivation ==
Running Proxmox VE as productive environment is not really possible, but for development and testing purposes, it can be useful to install PVE inside a virtual machine on e.g. a laptop. Wanting to use Virtualbox as a host for Proxmox on a laptop is a [http://forum.proxmox.com/google.php?cx=partner-pub-1240956337013298%3A0281164794&cof=FORID%3A9&ie=ISO-8859-1&q=virtualbox&sa.x=-1192&sa.y=-47&siteurl=forum.proxmox.com%2F&ref=&ss=1399j312179j10 common wish] but can be tricky to get right.
For development and testing purposes, it can be useful to install PVE inside a virtual machine on e.g. a laptop. Wanting to use Virtualbox as a host for Proxmox on a laptop is a [http://forum.proxmox.com/google.php?cx=partner-pub-1240956337013298%3A0281164794&cof=FORID%3A9&ie=ISO-8859-1&q=virtualbox&sa.x=-1192&sa.y=-47&siteurl=forum.proxmox.com%2F&ref=&ss=1399j312179j10 common wish] but can be tricky to get right.


Laptops use usually (only) WLAN connections which can be tricky because their network address continually change, and sometimes disappear, whereas desktops can assign a static ip address on a stable network. This can cause loss of stability unless an extra network is set up.
Laptops use usually (only) WLAN connections which can be tricky because their network address continually change, and sometimes disappear, whereas desktops can assign a static ip address on a stable network. This can cause loss of stability unless an extra network is set up.


== Goal ==


For accessing the internet use NAT - an address would be assigned by VirtualBox's DHCP service, usually something like 192.168.x.x or 10.0.x.x - but this would keep changing and completely disappear when WLAN loses connection. Instead, to have it under control we won't use DHCP from the WLAN but rather we will manually set up a separate subnet and manually assign a static IP address for the VM containing PVE.


== Prerequisites / Assumptions ==
= Network Considerations =
 
For accessing the internet use NAT - an address would be assigned by VirtualBox's DHCP service, usually something like 10.0.x.x, totally independent from host's network access (works as a small LAN which connects just the VBox virtual Proxmox and the NAT service).
 
Since the "main" Proxmox network address should be under user's control it's recommended to use a vitual HostOnly LAN; but it depends of the currecnt situation you may have.
 
= Prerequisites / Assumptions =
 
For PVE inside Virtualbox to work well it's strongly recommended (otherwise it may work but can be extremely slow) that
For PVE inside Virtualbox to work well it's strongly recommended (otherwise it may work but can be extremely slow) that
* your laptop needs to support HW acceleration (to be activated in BIOS, but check it your CPU supports it)
* your laptop needs to support HW acceleration (to be activated in BIOS, but check it your CPU supports it)
Line 26: Line 26:
* These instructions suppose the reader has minimal knowledge of networking, advanced configuration options that assume more knowledge are at [[Network Model]].
* These instructions suppose the reader has minimal knowledge of networking, advanced configuration options that assume more knowledge are at [[Network Model]].


== Containers as target ==
= Containers and simple KVM as target =
 
You can run Containers (OpenVZ) in PVE without any problems. It's also possible to configure KVM (Virtual Machines)... you can run these as well if they don't have any graphical interface and don't consume to much CPU resources (tested e.g. with [http://slaxrouter.sourceforge.net/slax-router slax-router]); be careful: in all other cases the Virtual Machine will freeze and can block your guest system too!


You can run lxc Containers in PVE without any problems. It's also possible to configure KVM (Virtual Machines)... you can run these as well if they don't have any graphical interface and don't consume to much CPU resources (tested e.g. with [http://slaxrouter.sourceforge.net/slax-router slax-router]); be careful: in all other cases the Virtual Machine will freeze and can block your guest system too!


=== Create Host-Only Network in Virtualbox===
KVM hardware virtualization does not work and must not be set! The reason is that with VirtualBox nested hardware virtualization support is not possible.


This network will be to permit traffic from the laptop to the PVE in Virtualbox. We set it up before installing PVE.
= Install and Run PVE =
 
In Virtualbox, there may be a Host-Only network already configured. This is set up at the Preferences > Network > Host-only Networks tab.
Each adapter has an IPv4 address + a IPv4 Network Mask, addresses can be served by a VirtualBox DHCP server, Proxmox PVE is best set up with a static address on the Host-Only network.
 
We are editing vboxnet0.
We don't need a DHCP Server.
 
For example
[[File:Virtualbox_Host-Only_network.png]]
 
 
Check from the host machine:
  $ ifconfig
        vboxnet0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        ether 0a:00:27:00:00:00
        inet 172.24.0.100 netmask 0xffffff80 broadcast 172.24.0.127
 
== Install PVE ==
1. Create a new Virtualbox Virtual Machine for Proxmox
1. Create a new Virtualbox Virtual Machine for Proxmox


Line 66: Line 47:
** IDE - Select Empty - click IDE Secondary - select the disk symbol, pick ISO for Proxmox
** IDE - Select Empty - click IDE Secondary - select the disk symbol, pick ISO for Proxmox
* Network:  
* Network:  
** Adapter 1: NAT (attention: '''NOT''' NAT-network!!)
** Adapter 1: Host-only Adapter, vboxnet0; recommended leave the advanced settings as they are (Paravirtualized Network (virtio-net)).
** Adapter 2: Host-only Adapter, vboxnet0; recommended leave the advanced settings as they are (Paravirtualized Network (virtio-net)).
** Adapter 2: NAT (attention: '''NOT''' NAT-network!!)
 
The order of the adapters matter.
 
This means for access ''to'' PVE VirtualBox's "Host-only Network" we go via "Host-only Adapter". For access to outside (internet) ''from'' PVE use VirtualBox's "NAT".


'''Do not use''' (it's not reliable!)
'''Do not use''' (it's not reliable!)
* "NAT network" (note the additional word "network"!), nor
* "NAT network" (note the additional word "network"!), nor
* "Bridged Adapter" (to WLAN)
* "Bridged Adapter" (to WLAN)
== Start the newly created Virtual Machine ==
# This will install Proxmox from the DVD ISO; pick the drive you created
# At the last step in PVE set up you will be asked for an IP address. Choose a static address in the IPv4 Network.
[[File:Proxmox_in_Virtualbox_Network_Setup.png]]
# Once the installer has finished, eject the ISO from the virtual DVD drive
# Shutdown the VM
=== On your laptop (the host running Virtual Box),  Define the Subnet for NAT ===
On command line. (Assuming your machine's name is "proxmox-vm")
* Create the Nat Subnet:
VBoxManage modifyvm "proxmox-vm" --natnet1 "192.168.11.0/24"
In VirtualBox' Machine Settings:
* Set Adapter 1 to "NAT"
Sample results from:
VBoxManage showvminfo proxmox-vm
NIC 1:          MAC: 0800277A6644, Attachment: NAT, Cable connected: on, Trace: off (file: none), Type: virtio, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: allow-all, Bandwidth group: none
NIC 1 Settings:  MTU: 0, Socket (send: 64, receive: 64), TCP Window (send:64, receive: 64)
NIC 2:              MAC: 080027A1CCAC, Attachment: Host-only Interface 'vboxnet0', Cable connected: on, Trace: off (file: none), Type: virtio, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none
== Start the installed Proxmox Virtual Machine ==
Now the virtual machine containing proxmox has started we need to reconfigure networking based on the static network independent of the WLAN settings.
== Configure the Network ==
=== Changing the Default Network ===
Proxmox default network is set up at the last stage of configuration to e.g. IP address 172.24.0.101. The WEB GUI then runs on port 8006 answering to https.
During installation PVE's Default Network is set to eth0 on bridge adapter vmbr0. You will need to change this so that the NAT network will be connected to the first virtual NIC.
The result we want is to use eth1 / vmbr0.
You can this adapt in WEB GUI after installation. We will change things around so that instead of all traffic being routed over the WLAN bridge (i.e. containers IP addresses appear on the WLAN),  internet is accessed from Proxmox and CTs via NAT, Proxmox to your laptop and vice versa goes by "Host only" network. Access from the laptop to CTs also goes via "Host Only", but gets an additional hop in virtual Proxmox host.
In summary, we will set up the PVE virtual machine in VirtualBox:
* eth0 = "Adapter 1" connected with NAT - address 192.168.11.15/24, gateway 192.168.11.2, DNS 192.168.11.3
* eth1 = "Adapter 2" connected with "Host only" - address 192.168.4.2/24
* vmbr1 (not bridged to any NIC in virtual Proxmox host) - address 192.168.9.1/24
=== On your laptop (the host running Virtual Box), Give a route to the CTs ===
This says "any traffic in the 9.x network should route via .4.2"
Your syntax may vary, and you may need something like the following to make the route permanent:
* OS X:
sudo route add -net 192.168.9.0/24 -gateway 192.168.4.2
* http://superuser.com/questions/756134/how-to-direct-ip-route-through-specific-interface-in-os-x
* http://apple.stackexchange.com/questions/126164/how-to-make-custom-routes-survive-reboots
* Check:
netstat -rn
* Linux:
sudo route add -net 192.168.9.0/24 gw 192.168.4.2
* PC:
??
Test:
$ netstat -rn
  Destination        Gateway            Flags        Refs      Use  Netif Expire
  192.168.9          192.168.4.2        UGSc            0        0    en1
=== Configure Proxmox to talk to both networks ===
==== In PVE, define a new Network Linux Bridge ====
This is going to bridge (send & receive) traffic that arrives on eth0 so that it looks like it originates from the NAT Subnet address (in this case 192.168.11.15) and sent to the default gateway (in this case 192.168.11.2)
[[File:Create_Linux_Bridge_for_Virtual_Box_Private_Network.png]]
Assuming the NIC connected to "NAT" is eth0.
* Make a bridge called vmbr1
* Bridge eth0 to it
* Assign an address from the NAT subnet to it, e.g. 192.168.11.15
* Set default gateway to "2" in the NAT subnet, e.g. 192.168.11.2
=== In the OpenVZ Containers ===
* venet0 address 192.168.11.16, 17 etc.
* veth NIC bridged to vmbr1 address 192.168.9.2,3 etc
* route to laptop with
route add -net 192.168.4.0/24 gw 192.168.9.1
Note: all traffic not specifically for the host laptop goes out via the NAT
?? Does this mean that this route has to be manually added for each new CT?
=== Network in Containers or KVMs ===
In PVE's virtual machines you can achieve access to both networks by bridging your NAT subnet address to either vmbr0 (for Internal Network) or to direct IP addressing (venet0 ; for Containers only, don't set both networks with venet0!).
== Try it! ==
=== Hit the PVE web interface ===
[[File:PVE_started_in_Virtualbox.png]]
https://172.24.0.101:8006/#v1:0:18:4::::::
=== Test access to network addresses ===
# From the laptop you should be able to ping the static ip address you assigned
$ ping 172.24.0.101
PING 172.24.0.101 (172.24.0.101): 56 data bytes
64 bytes from 172.24.0.101: icmp_seq=0 ttl=64 time=0.579 ms
64 bytes from 172.24.0.101: icmp_seq=1 ttl=64 time=0.710 ms
64 bytes from 172.24.0.101: icmp_seq=2 ttl=64 time=0.411 ms
# From the PVE machine you should be able to see the bridge
[[File:Network_from_within_PVE.png]]
# But because the network is host-only, only the laptop can see the VM containing PVE
# Test for how you ensure you see the containers goes here
== Diagnostics ==
=== View your Routes from the Host ===
Windows
route print
Mac OS X: use the netstat command:
netstat -rn
Sample:
172.24/25              link#12            UC                2        0 vboxnet
172.24.0.127.rdns ff:ff:ff:ff:ff:ff      UHLWbI          0        7 vboxnet
=== View your Routes from the PVE ===
netstat -rn
=== View your Routes from the Container ===




== Get DNS Server and Default Gateways ==
Mac:
  cat /etc/resolv.conf | grep nameserver
  route -n get default


== References ==
Then start the newly created Virtual Machine and Proxmox VE will be installed and can be used as any hardware installed Proxmox VE (but note the limitations mentioned above).
* http://orestad-linux.se/proxmox/
* https://wiki.debian.org/NetworkConfiguration
* https://wiki.debian.org/BridgeNetworkConnections
* http://www.microhowto.info/howto/bridge_traffic_between_two_or_more_ethernet_interfaces_on_linux.html
* http://forum.proxmox.com/threads/5722-open-VZ-container-has-trouble-reaching-the-internet
* http://archive.gregk.me/2010/working-on-vm-server-while-offline/
* http://askubuntu.com/questions/293816/in-virtualbox-how-do-i-set-up-host-only-virtual-machines-that-can-access-the-in
* http://technology.amis.nl/2014/01/27/a-short-guide-to-networking-in-virtual-box-with-oracle-linux-inside/
* http://translate.google.com/translate?hl=en&sl=de&u=https://forum.hosteurope.de/viewtopic.php%3Ff%3D64%26t%3D12125&prev=/search%3Fq%3D%2522route%2B-A%2Binet%2522%2Bproxmox%26safe%3Doff%26client%3Dsafari%26rls%3Den%26biw%3D1177%26bih%3D761
* http://forum.proxmox.com/threads/3440-Venet-Interface-some-problem
* http://forum.proxmox.com/threads/15874-Default-network-config-with-eth0-vmbr0-on-LAN-can-t-get-eth1-up-with-public-static
* http://www.rackspace.com/blog/vms-vlans-and-bridges-oh-my-part-1/

Revision as of 13:02, 10 October 2016

General

  • Instructions assume VirtualBox 4.3.16 or higher
  • The article refers to Proxmox VE 4.x (i.e. for lxc containers only, OpenVz is not supported any more)

Running Proxmox VE as productive environment is not really possible, but for development and testing purposes, it can be useful to install PVE inside a virtual machine on e.g. a laptop. Wanting to use Virtualbox as a host for Proxmox on a laptop is a common wish but can be tricky to get right.

Laptops use usually (only) WLAN connections which can be tricky because their network address continually change, and sometimes disappear, whereas desktops can assign a static ip address on a stable network. This can cause loss of stability unless an extra network is set up.


Network Considerations

For accessing the internet use NAT - an address would be assigned by VirtualBox's DHCP service, usually something like 10.0.x.x, totally independent from host's network access (works as a small LAN which connects just the VBox virtual Proxmox and the NAT service).

Since the "main" Proxmox network address should be under user's control it's recommended to use a vitual HostOnly LAN; but it depends of the currecnt situation you may have.

Prerequisites / Assumptions

For PVE inside Virtualbox to work well it's strongly recommended (otherwise it may work but can be extremely slow) that

  • your laptop needs to support HW acceleration (to be activated in BIOS, but check it your CPU supports it)
  • in virtual machine's settings the above is activated by System > Acceleration > Hardware Virtualization: Enable VT-x/AMD-V

It has to be run as Linux Debian (64-bit) guest.

  • The assumption of this article is that the PVE installation needs to be accessible only from the laptop.
  • These instructions suppose the reader has minimal knowledge of networking, advanced configuration options that assume more knowledge are at Network Model.

Containers and simple KVM as target

You can run lxc Containers in PVE without any problems. It's also possible to configure KVM (Virtual Machines)... you can run these as well if they don't have any graphical interface and don't consume to much CPU resources (tested e.g. with slax-router); be careful: in all other cases the Virtual Machine will freeze and can block your guest system too!

KVM hardware virtualization does not work and must not be set! The reason is that with VirtualBox nested hardware virtualization support is not possible.

Install and Run PVE

1. Create a new Virtualbox Virtual Machine for Proxmox

Sample settings:

  • Name: Proxmox-vm
  • OS Type: Linux
  • Version: Debian (64 bit)
  • Memory: 6GB
  • Disk: Use a SSD if possible. Preallocated might provide faster access.

2. Edit the settings

  • Audio: disable
  • Storage:
    • IDE - Select Empty - click IDE Secondary - select the disk symbol, pick ISO for Proxmox
  • Network:
    • Adapter 1: Host-only Adapter, vboxnet0; recommended leave the advanced settings as they are (Paravirtualized Network (virtio-net)).
    • Adapter 2: NAT (attention: NOT NAT-network!!)

Do not use (it's not reliable!)

  • "NAT network" (note the additional word "network"!), nor
  • "Bridged Adapter" (to WLAN)


Then start the newly created Virtual Machine and Proxmox VE will be installed and can be used as any hardware installed Proxmox VE (but note the limitations mentioned above).