You are not logged in.

#1 2021-02-20 12:00:07

yellowhat
Member
Registered: 2011-09-17
Posts: 10

[Solved] Headless QEMU: no internet

Hi,
I would like to install Arch headless using QEMU. The host system is CentOS 8.3.

These are the command that I used to install Arch from iso:

ISO_FILE=/dev/shm/arch.iso
RAw_FILE=/dev/shm/vm.raw
VHD_FILE="${RAw_FILE%.*}.vhd"

sudo dnf install -y qemu-kvm qemu-img virt-manager libvirt libvirt-client virt-install
sudo usermod -aG kvm,libvirt "$(whoami)"
sudo systemctl restart libvirtd

qemu-img create -f raw "$RAw_FILE" 30G
curl -L http://mirrors.evowise.com/archlinux/iso/2021.02.01/archlinux-2021.02.01-x86_64.iso -o "$ISO_FILE"

/usr/libexec/qemu-kvm \
    -name "Arch VM" \
    -smp 2 \
    -m 4G \
    -cpu host \
    -drive file="$RAw_FILE",format=raw \
    -cdrom "$ISO_FILE" \
    -enable-kvm \
    -nographic

# Tap the "tab" key to edit boot parametersm add "console=ttyS0" to kernel command line parameters
# Use the root user

loadkeys uk
timedatectl set-ntp true
printf "o\nn\np\n1\n\n\nw\n" | fdisk /dev/sda
mkfs.xfs /dev/sda1
mount /dev/sda1 /mnt
pacman -Syy --noconfirm
pacman -S --noconfirm archlinux-keyring
pacstrap /mnt base linux linux-firmware
genfstab -U /mnt >>/mnt/etc/fstab
arch-chroot /mnt
ln -sf /usr/share/zoneinfo/UTC /etc/localtime
hwclock --systohc
echo "en_GB.UTF-8 UTF-8" >/etc/locale.gen
locale-gen
echo "KEYMAP=uk" >/etc/vconsole.conf
pacman -Syu --noconfirm dhcp
systemctl enable dhcpd4
echo "vm" >/etc/hostname
cat >/etc/hosts <<EOF
127.0.0.1 localhost vm vm.localdomain
::1       localhost
EOF
pacman -S --noconfirm grub

sed -e 's/GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 quiet"/GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 quiet console=ttyS0"/g' \
    -i /etc/default/grub

grub-install --target=i386-pc /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg
passwd

exit 
poweroff

Restarting the VM:

/usr/libexec/qemu-kvm \
    -name "Arch VM" \
    -smp 2 \
    -m 4G \
    -cpu host \
    -drive file="$RAw_FILE",format=raw \
    -enable-kvm \
    -k en-gb \
    -nographic

I am able to login into Arch but there is no network connectivity.

# dhcpd
Internet Systems Consortium DHCP Server 4.4.2
Copyright 2004-2020 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Not searching LDAP since ldap-server, ldap-port and ldap-base-dn were not specified in the config file
Config file: /etc/dhcpd.conf
Database file: /var/lib/dhcp/dhcpd.leases
PID file: /var/run/dhcpd.pid
Source compiled to use binary-leases
Wrote 0 class decls to leases file.
Wrote 0 deleted host decls to leases file.
Wrote 0 new dynamic host decls to leases file.
Wrote 0 leases to leases file.

Not configured to listen on any interfaces!

If you think you have received this message due to a bug rather
than a configuration issue please read the section on submitting
bugs on either our web page at www.isc.org or in the README file
before submitting a bug.  These pages explain the proper
process and the information we find helpful for debugging.

exiting.
# ip link set up lo
# ip link set up ens3
# dhcpd
Internet Systems Consortium DHCP Server 4.4.2
Copyright 2004-2020 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Not searching LDAP since ldap-server, ldap-port and ldap-base-dn were not specified in the config file
Config file: /etc/dhcpd.conf
Database file: /var/lib/dhcp/dhcpd.leases
PID file: /var/run/dhcpd.pid
Source compiled to use binary-leases
Wrote 0 class decls to leases file.
Wrote 0 deleted host decls to leases file.
Wrote 0 new dynamic host decls to leases file.
Wrote 0 leases to leases file.

No subnet declaration for ens3 (no IPv4 addresses).
** Ignoring requests on ens3.  If this is not what
   you want, please write a subnet declaration
   in your dhcpd.conf file for the network segment
   to which interface ens3 is attached. **


Not configured to listen on any interfaces!

If you think you have received this message due to a bug rather
than a configuration issue please read the section on submitting
bugs on either our web page at www.isc.org or in the README file
before submitting a bug.  These pages explain the proper
process and the information we find helpful for debugging.

exiting.

Any suggestions?

Thanks

Last edited by yellowhat (2021-02-20 12:17:48)

Offline

#2 2021-02-20 12:04:42

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,544

Re: [Solved] Headless QEMU: no internet

You're confusing dhcpd and dhcpcd. You don't want to be running a dhcp server inside the VM.

Offline

#3 2021-02-20 12:17:32

yellowhat
Member
Registered: 2011-09-17
Posts: 10

Re: [Solved] Headless QEMU: no internet

Thanks for the reply:

pacman -Syu --noconfirm dhcpcd 
systemctl enable dhcpcd 

Solved

Offline

Board footer

Powered by FluxBB