michaeljclark / busybear-linux

busybear-linux is a tiny RISC-V Linux root filesystem image that targets the VirtIO board in riscv-qemu.
93 stars 33 forks source link

Replace bridged networking with QEMU user networking emulation #22

Open 64kramsystem opened 3 years ago

64kramsystem commented 3 years ago

The current network setup is bridged, which is very brittle (due to differences between operating systems; for example, Ubuntu doesn't ship the bridge utilities by default), and also unnecessarily complex (besides the inherent complexity, up/down scripts are required).

Using the QEMU built-in user is trivial, and much more stable, since it doesn't require any change on the host system.

Change the etc/network/interfaces to be:

iface lo inet loopback

auto eth0
iface eth0 inet static
        address 10.0.2.15
        netmask 255.255.255.0
        broadcast 10.0.2.255
        gateway 10.0.2.2

Then, in the startup script, replace this:

  -netdev type=tap,script=scripts/ifup.sh,downscript=scripts/ifdown.sh,id=net0 \
  -device virtio-net-device,netdev=net0

with:

  -device virtio-net-device,netdev=usernet \
  -netdev user,id=usernet,hostfwd=tcp::10000-:22 \

and drop the ifup/down scripts.

And don't forget to update the README :smile:.