====== LXC Simple Bridge configuration ======
This document is based on:\\
- Tux4u(r)/Penguin Suite: PS-wheezy\\
- PS-app: emu-lxc 1.0.4
===== 1. Overview =====
{{ linux:applicaties:lxc-bridge-450x517.png }}
More info:\\
[[linux:applicaties:lxc:lxc-introduction#lxc_networking_scenarios|LXC Introduction: LXC Networking scenarios]]
===== 2. Host network configuration =====
==== 2.1 /etc/network/interfaces ====
- Comment out the primary interface "eth0"
- Configure a virtual bridge device
- Configure the hosts IP-address on this virtual bridge device
- Reboot the host
## /etc/network/interfaces
# The primary network interface
#allow-hotplug eth0
# auto eth0
# iface eth0 inet dhcp
# LXC eth0 bridge
auto br0=br0-bridge
iface br0-bridge inet static
address 192.168.1.101
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.254
dns-nameservers 192.168.1.254
dns-search mydom.com
bridge_ports eth0
bridge_fd 0
bridge_maxwait 0
===== 3. LXC Container configuration =====
==== 3.1 Create new Container ====
=== 3.1.1 /etc/lxc/veth-br0.conf ===
This config file preconfigures a new LXC Container with a
Virtual Ethernet device:
lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = br0
* The default LXC config file preconfigures a new Container with the loopback interface only.
=== 3.1.2 Create Container ===
# lxc-create -n Container_name -f /etc/lxc/veth-br0.conf -t debian
* Option "-t debian" creates the container using the Debian Stable template script
==== 3.2 Customize the Container's network configuration ====
The "debian" template script creates a full functional Debian system
for the LXC Container.
This Debian system is capable of configuring it own network.
=== 3.2.1 LXC Container: Fixed IP-address option ===
By default the Debian Container configures its "eth0" interface using DHCP.
If you need a fixed IP-address configuration:
- Go to "/var/lib/lxc/Container_name/rootfs/"
- Edit "etc/network/interfaces" and comment out the "eth0" lines.
- Go to "/var/lib/lxc/Container_name/"
- Edit the LXC Container "config" file and define a fixed IP-address
== Detailed instructions ==
Edit "etc/network/interfaces" and comment out the "eth0" lines:
## /etc/network/interfaces
auto lo
iface lo inet loopback
## Comment out when using a fixed IP-address
# auto eth0
# iface eth0 inet dhcp
Define a fixed IP configuration in the Container's "config" file:
## /var/lib/lxc/Container_name/config
lxc.network.ipv4 = 192.168.1.102/24
lxc.network.ipv4.gateway = 192.168.1.254
===== 4. Start LXC Container =====
Start the Container in deamon mode (-d):
((Omitting option "-d" will connect your terminal to the console of the
running Container.))
# lxc-start -n Container_name -d
====== . ======
Copyright (c) 2014 Integrated Services; Tux4u.nl\\
Author: Marjan Waldorp; lxc/lxc-simplebridge 2014-09-01