-
Notifications
You must be signed in to change notification settings - Fork 181
Usage on fedora hosts
Vagrant and vagrant-lxc are now in yum.
sudo dnf|yum install vagrant vagrant-libvirt vagrant-lxc
Read this blog post by the Fedora packager for more info.
Out of Date: This page is for Fedora 20 and earlier versions of Vagrant + vagrant-lxc.
There is a known issue with SSH for some base boxes, please keep an eye on GH-171 for the latest information
- Fedora 20 x86_64
- Vagrant 1.3.4
- Vagrant-LXC 0.6.3
$ sudo yum install lxc lxc-extra redir
- /etc/systemd/system/lxc-net.service
[Unit]
Description=Bridge interface for LXC Containers
[Service]
Type=oneshot
# Bring up bridge interface
ExecStart=/sbin/brctl addbr lxcbr0
ExecStart=/sbin/ip address add 192.168.150.1/24 dev lxcbr0
ExecStart=/sbin/ip link set lxcbr0 up
RemainAfterExit=yes
# Bring bridge interface down
ExecStop=/sbin/ip link set lxcbr0 down
ExecStop=/sbin/brctl delbr lxcbr0
- /etc/systemd/system/lxc-dhcp.service
[Unit]
Requires=lxc-net.service
Requires=sys-devices-virtual-net-lxcbr0.device
After=sys-devices-virtual-net-lxcbr0.device
[Service]
ExecStart=/sbin/dnsmasq \
--dhcp-leasefile=/var/run/lxc-dnsmasq.leases \
--user=qemu \
--group=qemu \
--keep-in-foreground \
--listen-address=192.168.150.1 \
--except-interface=lo \
--bind-interfaces \
--dhcp-range=192.168.150.2,192.168.150.254
[Install]
WantedBy=default.target
- Enable lxc-dhcp.service
$ sudo systemctl enable lxc-dhcp.service
Credits for systemd configuration go to @riccieri
- Open firewall application.
- Switch to permanent configuration mode.
- On public zone:
- Enable masquerading.
- Enable DHCP in services
- On trusted zone:
- Add lxcbr0 to interfaces tab.
- On top tab Direct Configuration add the following rule:
- ipv: ipv4
- table: mangle
- Chain: POSTROUTING
- Priority: 0 (Change it to fit your needs)
- Args: -p udp --dport bootpc -j CHECKSUM --checksum-fill
NOTE: The last step of adding a rule is only needed if running Debian (or other distros) with ancient DHCP clients.
- Reboot :-)
This method doesn't require creating an additional bridge and dnsmasq configuration, and it adheres more closely to the Fedora default lxc configuration. However it requires tweaking your Vagrantfile to override the default lxc configuration in the base box.
sudo yum install libvirt-daemon
sudo systemctl start libvirtd
config.vm.provider :lxc do |vm|
vm.customize 'network.link', 'virbr0'
end
PROTIP: You can add that snippet to your $HOME/.vagrant.d/Vagrantfile
so all vagrant-lxc machines you use have it configured properly