Hallo,
ich benutze seit kurzem LXD Container und bin soweit sehr, sehr zufrieden. Die Dokumentation (english) ist hervorragend und die Kommandozeilenbedienung IMHO sehr einfach. Bei Netcup habe ich einen Root-Server (KVM) und eine zusätzliche IPv4 nur für den Container bestellt. Da LXD derzeit am besten unter Ubuntu 15.10 Wily läuft (lxd-stable repo einbinden nicht vergessen), musste ich noch ein Wily-Image hochladen. Nachdem ich im VCP die IPv4 dem Server zugeordnet habe, bin ich einfach dieser Anleitung hier gefolgt:
KVM mit Nutzung aller IPs - the easy way – Hetzner DokuWiki
Ich bin der Anleitung nicht direkt gefolgt. Statt zusätzlich eine Bridge anzulegen, habe ich das Netzwer-Interface auf dem Host durch die Bridge ersetzt, also iface ens3 usw auskommentiert. Die Anleitung kann man trotzdem so umsetzen. Ich habe statt einem statischen Setup für den Host DHCP genommen. Da funktioniert auch mit der Bridge. Außer: Weil ich kein anderes interface mehr habe, habe ich auf dem Host statt "bridge_ports none" lieber "bridge_ports ens3" angegeben. Da sollte man sich daran halten, welche Schnittstelle, also z.B. eth0, ens3, usw. vorher dort eingetragen ist.
"The easy way" stimmt. Ich persönlich finde LXD viel einfacher als KVM, weil man sich um noch weniger kümmern muss. Die Container können eigene Firewalls laufen lassen. Man muss nur die entsprechenden Module (iptables, z.B.) auf dem Host laden, weil die Container selbst keine Module nachladen dürfen. Und so kann man Container bequem mit eigener IPv4 als vollständige Server laufen lassen.
Für den LXD-Container muss man noch ein Profil anlegen, damit der Container sich an die neue Bridge hängt. Im default-Profil hängt sich LXD an lxbr0 und bekommt eine 10.0.3.x zugeteilt.
Hier noch ein paar Links zu LXD:
Linux Containers - LXD - Getting started - command line
lxd/image-handling.md at master · lxc/lxd · GitHub
lxd/command-line-user-experience.md at master · lxc/lxd · GitHub
lxd/configuration.md at master · lxc/lxd · GitHub
Es sieht schwerer aus, als es ist. Es gibt ganz wenig zu konfigurieren.
So sieht meine /etc/network/interfaces auf dem wily Host aus:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
#auto ens3
#iface ens3 inet dhcp
auto br0
iface br0 inet dhcp
bridge_ports ens3
bridge_stp off
bridge_fd 0
bridge_maxwait 0
up route add -host 37.120.x.x/32 dev br0
Das habe ich bei meiner /etc/sysctl.conf auf dem wily Host hinzugefügt (Anmerkug: ipv6-Setup fehlt noch woanders, ist aber hier schon hinterlegt):
net.ipv4.ip_forward=1
net.ipv6.conf.all.forwarding= 1
net.ipv6.conf.br0.forwarding = 1
net.ipv6.conf.default.forwarding = 1
net.ipv4.conf.all.send_redirects = 0
Testweise habe ich als Gast ebenfalls Ubuntu 15.10 Wily angelegt. Es laufen aber auch Debian und CentOS problemlos.
Mein /etc/network/interfaces auf dem Gast:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
#auto eth0
#iface eth0 inet dhcp
auto eth0
iface eth0 inet static
address 37.120.x.x
netmask 255.255.255.255
# gateway und pointopeoint sind die address vom Host oben
gateway 37.120.x.x
pointopoint 37.120.x.x
dns-nameservers 46.38.225.230 8.8.8.8
Das Gast-Profil habe ich so angelegt:
lxc profile create GUEST
lxc profile edit GUEST
### This is a yaml representation of the profile.
### Any line starting with a '# will be ignored.
###
### A profile consists of a set of configuration items followed by a set of
### devices.
###
### An example would look like:
### name: onenic
### config:
### raw.lxc: lxc.aa_profile=unconfined
### devices:
### eth0:
### nictype: bridged
### parent: lxcbr0
### type: nic
###
### Note that the name is shown but cannot be changed
name: GUEST
config: {}
devices:
eth0:
nictype: bridged
parent: br0
# 'parent' ist hier der Name der
# Bridge aus /etc/network/interfaces vom Host
type: nic
Ich denke, dass LXD mit Ubuntu 16.04 Xenial Xerus starke Verbreitung finden wird. Die o.g. Anleitung sollte auch für xenial funktionieren.
Anmerkung: Ich habe bei Netcup mehrfach angefragt und wurde freundlich ermutigt Container auf dem Root-Server anzulegen. Seitens Netcup gibt es also keine Einwände. Viel Spaß beim Containern.