Score:0

QEMU hostfwd not working with multiple netdevs

cn flag

With the following command I am able to ssh into the virtual machine on localhost:10022.

/usr/bin/qemu-system-riscv64 \
        -M virt -accel tcg -m 8192 -smp 8 \
        -nographic \
        -bios RISCVVIRT.fd \
        -bios /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.elf \
        -kernel /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf \
        -drive file=riscv64.img,format=raw,if=virtio \
        -device virtio-net-device,netdev=net0 \
        -netdev user,dhcpstart=10.0.2.20,hostfwd=tcp::10022-10.0.2.20:22,id=net0

But for my tests I need multiple NICs

/usr/bin/qemu-system-riscv64 \
        -M virt -accel tcg -m 8192 -smp 8 \
        -nographic \
        -bios RISCVVIRT.fd \
        -bios /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.elf \
        -kernel /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf \
        -drive file=riscv64.img,format=raw,if=virtio \
        -device virtio-net-device,netdev=net0 \
        -netdev user,dhcpstart=10.0.2.20,hostfwd=tcp::10022-10.0.2.20:22,id=net0 \
        -device virtio-net-pci,netdev=devnet1,id=net1 \
        -netdev user,dhcpstart=10.0.2.30,id=devnet1 \
        -device virtio-net-pci,netdev=devnet2,id=net2 \
        -netdev user,dhcpstart=10.0.2.40,id=devnet2

The port localhost:10022 accepts connections but I am not able to reach the SSH server.

It is not a problem with ssh:

# systemctl status ssh
● ssh.service - OpenBSD Secure Shell server
     Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: e>
     Active: active (running) since Wed 2022-05-11 15:53:42 UTC; 41s ago
       Docs: man:sshd(8)
             man:sshd_config(5)
    Process: 637 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
   Main PID: 680 (sshd)
      Tasks: 1 (limit: 4433)
     Memory: 3.7M
        CPU: 449ms
     CGroup: /system.slice/ssh.service
             └─680 "sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups"

May 11 15:53:42 rv64 systemd[1]: Starting OpenBSD Secure Shell server...
May 11 15:53:42 rv64 sshd[680]: Server listening on 10.0.2.20 port 22.
May 11 15:53:42 rv64 systemd[1]: Started OpenBSD Secure Shell server.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.