diff --git a/home/scripts/lxc/lab-create.sh b/home/scripts/lxc/lab-create.sh index 73fd99e..0616f01 100644 --- a/home/scripts/lxc/lab-create.sh +++ b/home/scripts/lxc/lab-create.sh @@ -15,6 +15,11 @@ CONTAINER_IP="10.100.0.${NEXT_OCTET}" echo "Creating LXC container ${CONTAINER} (${CONTAINER_IP})..." 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) cat >> "/var/lib/lxc/${CONTAINER}/config" < "/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 -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" cat > "/var/lib/lxc/${CONTAINER}/rootfs/etc/netplan/10-lxc.yaml" <