Snippets
lxc provider
On Linux, the lxc (Linux Containers) provider is a bit faster than full paravirtualisation. Currently this only works with Debian Stretch (or later) boxes.
To make this work, you'll need to install some additional packages:
# Install provider plugin from https://github.com/fgrehm/vagrant-lxc/
vagrant plugin install vagrant-lxc
# Install support for running containers on your host machine, plus NFS support
sudo apt-get install lxc nfs-kernel-server nfs-kernel-server
# Get the correct distro for vagrant box
vagrant box add debian/stretch64 --provider=lxc
Edit /etc/lxc/default.conf
and ensure it contains only these lines:
lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = virbr0
# The following might be necessary if you have LXC with apparmor support (true on Ubuntu)
lxc.aa_profile = unconfined
Now to run the boxes, you have two options: either set VAGRANT_DEFAULT_PROVIDER=lxc
in your environment or pass --provider=lxc
when bringing up a box for the first time.
libvirt provider
To use QEMU instead of VirtualBox, you need to install additional components:
# Install requirements for building vagrant-libvirt
sudo apt-get install libxslt-dev libxml2-dev libvirt-dev zlib1g-dev qemu-system-x86 qemu-kvm nfs-kernel-server libvirt-bin dnsmasq-base ebtables
# Install provider plugin from https://github.com/pradels/vagrant-libvirt
vagrant plugin install vagrant-libvirt
# Install host manager from https://github.com/smdahlen/vagrant-hostmanager
vagrant plugin install vagrant-hostmanager
Make yourself a member of the libvirtd group:
sudo gpasswd -a $USER libvirtd
Log out and in again for the group changes to apply.
Mutate debian/jessie or ubuntu/xenial64
There's no default libvirt debian/jessie and also no ubuntu/xenial64 box available, so you have to convert it yourself:
vagrant plugin install vagrant-mutate
vagrant box add debian/jessie64
vagrant mutate debian/jessie64 libvirt
Firewall
If you're using ferm(1), add this to INPUT
and FORWARD
:
interface (virbr0 virbr1 virbr2) ACCEPT;
And this to OUTPUT
and FORWARD
:
outerface (virbr0 virbr1 virbr2) ACCEPT;
Now either export VAGRANT_DEFAULT_PROVIDER=libvirt
before vagrant up
or run:
vagrant up --provider=libvirt
ArchLinux
Using iptables
and seeing errors like these in journalctl -af
(note: using VirtualBox here)?
iptables denied: IN=vboxnet0 OUT= MAC=... SRC=10.10.10.71 DST=10.10.10.1 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=25831 DF PROTO=UDP SPT=58215 DPT=111 LEN=64
Temporarily allow access as follows:
sudo iptables -A INPUT -i vboxnet0 -s 10.10.10.71 -d 10.10.10.1 -j ACCEPT
Comments (3)
You can clone a snippet to your computer for local editing. Learn more.
If you get this error :
run this command:
If you get this error:
run this command:
On Ubuntu 17.04
vagrant plugin install vagrant-libvirt
givesERROR: Failed to build gem native extension
. Runsudo apt-get install ruby-dev
to fix this.