lxc patch 5

This commit is contained in:
2026-04-11 10:17:36 -04:00
parent 35de1c0f75
commit 793227b44e
+7 -2
View File
@@ -15,6 +15,11 @@ CONTAINER_IP="10.100.0.${NEXT_OCTET}"
echo "Creating LXC container ${CONTAINER} (${CONTAINER_IP})..." echo "Creating LXC container ${CONTAINER} (${CONTAINER_IP})..."
lxc-create -n "$CONTAINER" -f /etc/lxc/default.conf -t download -- -d ubuntu -r noble -a amd64 lxc-create -n "$CONTAINER" -f /etc/lxc/default.conf -t download -- -d ubuntu -r noble -a amd64
# write resolv.conf into rootfs before boot
mkdir -p "/var/lib/lxc/${CONTAINER}/rootfs/etc"
rm -f "/var/lib/lxc/${CONTAINER}/rootfs/etc/resolv.conf" # remove if symlink
echo "nameserver 8.8.8.8" > "/var/lib/lxc/${CONTAINER}/rootfs/etc/resolv.conf"
# assign static IP via LXC config (host-side, always works) # assign static IP via LXC config (host-side, always works)
cat >> "/var/lib/lxc/${CONTAINER}/config" <<EOF cat >> "/var/lib/lxc/${CONTAINER}/config" <<EOF
lxc.net.0.ipv4.address = ${CONTAINER_IP}/24 lxc.net.0.ipv4.address = ${CONTAINER_IP}/24
@@ -23,10 +28,10 @@ lxc.start.auto = 1
EOF EOF
# write resolv.conf into rootfs before boot # write resolv.conf into rootfs before boot
echo "nameserver 8.8.8.8" > "/var/lib/lxc/${CONTAINER}/rootfs/etc/resolv.conf" # echo "nameserver 8.8.8.8" > "/var/lib/lxc/${CONTAINER}/rootfs/etc/resolv.conf"
# disable any in-container networking that might fight us # disable any in-container networking that might fight us
rm -f "/var/lib/lxc/${CONTAINER}/rootfs/etc/netplan/"*.yaml 2>/dev/null rm -f "/var/lib/lxc/${CONTAINER}/rootfs/etc/netplan/"*.yaml 2>/dev/null || true
mkdir -p "/var/lib/lxc/${CONTAINER}/rootfs/etc/netplan" mkdir -p "/var/lib/lxc/${CONTAINER}/rootfs/etc/netplan"
cat > "/var/lib/lxc/${CONTAINER}/rootfs/etc/netplan/10-lxc.yaml" <<EOF cat > "/var/lib/lxc/${CONTAINER}/rootfs/etc/netplan/10-lxc.yaml" <<EOF
network: network: