Browse Source

new: [host] debian 10 lxc configuration

Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>
pull/1/head
Valentin Lab 4 years ago
parent
commit
a58f06ebc9
  1. 43
      precise/host/hooks/install.d/50-lxc.sh

43
precise/host/hooks/install.d/50-lxc.sh

@ -6,3 +6,46 @@ apt-get install lxc -y --force-yes </dev/null
if ! [ -e ~/.ssh/id_rsa ]; then if ! [ -e ~/.ssh/id_rsa ]; then
ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa -q ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa -q
fi fi
## From: https://wiki.debian.org/LXC#Independent_bridge_setup
lxc_net="$(cat /etc/lxc/default.conf |
grep ^lxc.net.0.type |
cut -f 2 -d = |
xargs echo)"
if [ "$lxc_net" == "empty" ]; then
## Boggers, we are on default unconfigured networks for lxc
sed -ri 's/^lxc.net.0.type = empty/lxc.net.0.type = veth\nlxc.net.0.link = lxcbr0\nlxc.net.0.flags = up\nlxc.net.0.hwaddr = 00:16:3e:xx:xx:xx/g' /etc/lxc/default.conf
[ -e "/etc/default/lxc-net" ] || {
cat <<EOF > /etc/default/lxc-net
USE_LXC_BRIDGE="true"
# If you change the LXC_BRIDGE to something other than lxcbr0, then
# you will also need to update your /etc/lxc/default.conf as well as the
# configuration (/var/lib/lxc/<container>/config) for any containers
# already created using the default config to reflect the new bridge
# name.
# If you have the dnsmasq daemon installed, you'll also have to update
# /etc/dnsmasq.d/lxc and restart the system wide dnsmasq daemon.
LXC_BRIDGE="lxcbr0"
LXC_ADDR="172.101.0.1"
LXC_NETMASK="255.255.255.0"
LXC_NETWORK="172.101.0.0/24"
LXC_DHCP_RANGE="172.101.0.2,172.101.0.254"
LXC_DHCP_MAX="253"
# Uncomment the next line if you'd like to use a conf-file for the lxcbr0
# dnsmasq. For instance, you can use 'dhcp-host=mail1,172.46.0.100' to have
# container 'mail1' always get ip address 172.46.0.100.
LXC_DHCP_CONFILE=/etc/lxc/dnsmasq.conf
# Uncomment the next line if you want lxcbr0's dnsmasq to resolve the .lxc
# domain. You can then add "server=/lxc/172.46.0.1' (or your actual )
# to /etc/dnsmasq.conf, after which 'container1.lxc' will resolve on your
# host.
#LXC_DOMAIN="lxc"
EOF
}
service lxc-net restart
fi
Loading…
Cancel
Save