0

I'm trying to setup a qemu-kvm VM following this guide as a reference. The only change I did was install DHCP and git as additional target packages while configuring buildroot.

This is how I invoke qemu:

sudo modprobe kvm-intel && sudo qemu-system-x86_64 -kernel /arch/x86_64/boot/bzImage -nographic -drive format=raw,file=~/buildroot/output/images/rootfs.ext4,if=virtio -append "root=/dev/vda console=ttyS0 nokaslr" -m 512M -accel kvm -cpu host -smp 1 -netdev user,id=nd0,hostfwd=tcp::8080-:80 -device virtio-net,netdev=nd0 -s

After my VM is up and running I modify my /etc/network/interfaces/ file to add the following lines:

auto eth0
iface eth0 inet dhcp

Now, with these two changes, I see that my VM interfaces look like this

# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:56
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::fd5a:482c:3194:fa26/64 Scope:Link
          inet6 addr: fec0::28e6:7439:6d58:6246/64 Scope:Site
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:29 errors:0 dropped:0 overruns:0 frame:0
          TX packets:58 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:4401 (4.2 KiB)  TX bytes:6537 (6.3 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

I have a few questions about this setup:

  1. I'd like to know if there is a way to connect to this VM without hostfwd (since it doesn't seem to work)?
  2. My SSH keys get erased on every reboot. Is there a way to persist it?
  3. Speaking of persistence, why is it that my settings in /etc/network/interfaces persists while my SSH keys don't?

Keen to have some clarity on this rather user-hostile CLI tool since the documentation needs to be deduced and seems to be written for folks who have had their feet wet elsewhere already!

AjB
  • 890
  • 13
  • 34

0 Answers0