You are not logged in.

#1 2025-11-02 20:29:12

presko
Member
Registered: 2025-11-02
Posts: 2

[solved] dns using qemu

running arch (or alpine) using qemu always break the dns resolving, even:
- setting the /etc/resolv.conf on 1.1.1.1 on the host and/or the vm
- using qemu -nic dns=1.1.1.1 or not
but pinging 9.9.9.9 works

I also tryed some tap/bridge witchcraft using chatgpt but no result

here is my main script:

#!/bin/bash
set -eux

# from vm to make a shared folder
# mount -t 9p -o trans=virtio hostshare /mnt

ISO_URL="https://mirror.arizona.edu/archlinux/iso/latest/archlinux-x86_64.iso"
ISO=${1:-$(basename $ISO_URL)}
IMG=${2:-disk_qemu.qcow2}
SIZE=${3:-16G}
RAM=${4:-2G}
CPUS=${5:-2}
SHARE=${6:-$PWD/share}

mkdir -p "$SHARE"
echo "iso = $ISO"
[ -f "$ISO" ] || wget "$ISO_URL"
[ -f "$IMG" ] || qemu-img create -o nocow=on -f qcow2 "$IMG" "$SIZE"

qemu-system-x86_64 \
  -enable-kvm \
  -m "$RAM" \
  -cpu host \
  -smp "$CPUS" \
  -boot d \
  -cdrom "$ISO" \
  -drive file="$IMG",format=qcow2 \
  -device virtio-vga \
  -display default,show-cursor=on \
  -virtfs local,id=share,path="$SHARE",security_model=none,mount_tag=hostshare

Thanks for any help

Last edited by presko (2025-11-03 06:52:01)

Offline

#2 2025-11-03 06:51:30

presko
Member
Registered: 2025-11-02
Posts: 2

Re: [solved] dns using qemu

the first ip in /etc/resolv.conf where wrong
(and the rotate option in /etc/resolv.conf doesn´t work)

a little bug from qemu

regards

Offline

Board footer

Powered by FluxBB