Gebruikershulpmiddelen

Site-hulpmiddelen


linux:applicaties:lxc:lxc-simplebridge

LXC Simple Bridge configuration

This document is based on:
- Tux4u®/Penguin Suite: PS-wheezy
- PS-app: emu-lxc 1.0.4

1. Overview

2. Host network configuration

2.1 /etc/network/interfaces

  1. Comment out the primary interface “eth0”
  2. Configure a virtual bridge device
  3. Configure the hosts IP-address on this virtual bridge device
  4. 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:

  1. Go to “/var/lib/lxc/Container_name/rootfs/”
  2. Edit “etc/network/interfaces” and comment out the “eth0” lines.
  3. Go to “/var/lib/lxc/Container_name/”
  4. 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): 1)

# lxc-start -n Container_name -d

.

Copyright © 2014 Integrated Services; Tux4u.nl
Author: Marjan Waldorp; lxc/lxc-simplebridge 2014-09-01

1)
Omitting option “-d” will connect your terminal to the console of the running Container.
linux/applicaties/lxc/lxc-simplebridge.txt · Laatst gewijzigd: 2018/12/30 17:17 (Externe bewerking)