Code: Alles auswählen
root@bubu ~ # lxc-attach -n db passwd
New password:
Retype new password:
passwd: password updated successfully
root@bubu ~ # ssh root@10.0.3.249
root@10.0.3.249's password:
Permission denied, please try again.
root@10.0.3.249's password:
Code: Alles auswählen
lxc-console -n db :(
Connected to tty 1
Type <Ctrl+a q> to exit the console, <Ctrl+a Ctrl+a> to enter Ctrl+a itself
Code: Alles auswählen
root@bubu ~ # lxc-attach -n db ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
4: eth0@if5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:16:3e:77:a8:e0 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 10.0.3.249/24 brd 10.0.3.255 scope global dynamic eth0
valid_lft 2286sec preferred_lft 2286sec
inet6 fe80::216:3eff:fe77:a8e0/64 scope link
valid_lft forever preferred_lft forever
je 2 container laufen auf einer bridge
Code: Alles auswählen
root@bubu ~ # lxc-ls -f
NAME STATE AUTOSTART GROUPS IPV4 IPV6 UNPRIVILEGED
db RUNNING 1 - 10.0.3.249 - false
drupal RUNNING 1 - 10.0.3.81 - false
mail RUNNING 1 - 192.168.122.63 - false
proxy RUNNING 1 - 192.168.122.83 - false
Code: Alles auswählen
$ sudo apt-get install -qy libvirt-clients libvirt-daemon-system iptables ebtables dnsmasq-base
$ sudo virsh net-start default
$ sudo virsh net-autostart default
Code: Alles auswählen
cat /etc/default/lxc-net
LXC_BRIDGE="lxcbr0"
LXC_ADDR="10.0.3.1"
LXC_NETMASK="255.255.255.0"
LXC_NETWORK="10.0.3.0/24"
LXC_DOMAIN=""
Code: Alles auswählen
ip r
default via 116.202.112.129 dev enp35s0 onlink
10.0.3.0/24 dev lxcbr0 proto kernel scope link src 10.0.3.1
116.202.112.128/26 via 116.202.112.129 dev enp35s0
116.202.112.128/26 dev enp35s0 proto kernel scope link src MEINEIP
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1
Code: Alles auswählen
root@bubu ~ # cat /var/lib/lxc/db/config
# lxc.apparmor.profile = generated
# lxc.apparmor.allow_nesting = 1
lxc.net.0.type = veth
lxc.net.0.hwaddr = 00:16:3e:77:a8:e0
lxc.net.0.link = lxcbr0
lxc.net.0.flags = up
lxc.rootfs.path = dir:/var/lib/lxc/db/rootfs
# Common configuration
lxc.include = /usr/share/lxc/config/debian.common.conf
# Container specific configuration
lxc.tty.max = 4
lxc.uts.name = db
lxc.arch = amd64
lxc.pty.max = 1024
lxc.start.auto = 1
Code: Alles auswählen
cat /usr/share/lxc/config/debian.common.conf
# This derives from the global common config
lxc.include = /usr/share/lxc/config/common.conf
# Doesn't support consoles in /dev/lxc/
lxc.tty.dir = lxc
# When using LXC with apparmor, the container will be confined by default.
# If you wish for it to instead run unconfined, copy the following line
# (uncommented) to the container's configuration file.
lxc.apparmor.profile = unconfined
# If you wish to allow mounting block filesystems, then use the following
# line instead, and make sure to grant access to the block device and/or loop
# devices below in lxc.cgroup.devices.allow.
#lxc.apparmor.profile = lxc-container-default-with-mounting
# Extra cgroup device access
## rtc
lxc.cgroup.devices.allow = c 254:0 rm
## tun
lxc.cgroup.devices.allow = c 10:200 rwm
## hpet
lxc.cgroup.devices.allow = c 10:228 rwm
## kvm
lxc.cgroup.devices.allow = c 10:232 rwm
## To use loop devices, copy the following line to the container's
## configuration file (uncommented).
#lxc.cgroup.devices.allow = b 7:* rwm
Code: Alles auswählen
cat /etc/lxc/default.conf
lxc.apparmor.profile = generated
lxc.apparmor.allow_nesting = 1
lxc.net.0.type = veth
lxc.net.0.link = lxcbr0
lxc.net.0.flags = up
Code: Alles auswählen
cat /etc/default/lxc
# LXC_AUTO - whether or not to start containers at boot
LXC_AUTO="true"
# BOOTGROUPS - What groups should start on bootup?
# Comma separated list of groups.
# Leading comma, trailing comma or embedded double
# comma indicates when the NULL group should be run.
# Example (default): boot the onboot group first then the NULL group
BOOTGROUPS="onboot,"
# SHUTDOWNDELAY - Wait time for a container to shut down.
# Container shutdown can result in lengthy system
# shutdown times. Even 5 seconds per container can be
# too long.
SHUTDOWNDELAY=5
# OPTIONS can be used for anything else.
# If you want to boot everything then
# options can be "-a" or "-a -A".
OPTIONS=
# STOPOPTS are stop options. The can be used for anything else to stop.
# If you want to kill containers fast, use -k
STOPOPTS="-a -A -s"
USE_LXC_BRIDGE="true" # overridden in lxc-net
[ ! -f /etc/default/lxc-net ] || . /etc/default/lxc-net