起動時に、-net をつけると良い
-net user
何も考えずに、何も考えないでつける。
qemu system nic "10.0.2.2" dhcp
ブリッジを使いたいときは
-nic bridge,br=br0,model=virtio-net-pci
sudo qemu-system-aarch64 \ -m 2G \ -nographic \ -enable-kvm \ -machine virt-6.2 \ -cpu host \ -nic bridge,br=br0,model=virtio-net-pci \ -drive if=pflash,format=raw,readonly=on,file=/usr/share/AAVMF/AAVMF_CODE.fd \ -drive if=pflash,format=raw,file=AAVMF_VARS.fd \ -drive file=user-data.img,format=raw \ -drive file=ubuntu-22.04-server-cloudimg-arm64.img
macvtap を使いたいときは
macvtap を作ってから接続する。
sudo ip link add link eth0 name qeth0 type macvtap mode bridge sudo ip link set qeth0 up sudo brctl addbr br0 sudo brctl addif br0 qeth0 ## 後片付け sudo brctl delbr br0 sudo ip link set qeth0 down sudo ip link del link dev qeth0
いくつかの設定をする。
qemu -net nic,model=virtio,addr=d2:70:02:ea:91:d9 -net tap,fd=3 3<>/dev/tap44
https://slankdev.hatenablog.com/entry/2017/12/14/210335によると。
-net nic -net tap,ifname=vtap0 -net nic -net tap,ifname=vtap0
-net nic,model=virtio,macaddr=$(cat /sys/class/net/qeth0/address) -net tap,fd=3 3<>/dev/tap$(cat /sys/class/net/qeth0/ifindex)
-netdev tap,fd=3,id=hostnet0 3<>/dev/tap44 \ -device virtio-net-pci,netdev=hostnet0,id=net0,mac=d2:70:02:ea:91:d9 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=46:71:e9:e3:88:12,bus=root.2 6<>/dev/tap6
sudo qemu-system-aarch64 \ -m 2G \ -nographic \ -enable-kvm \ -machine virt-6.2 \ -cpu host \ -net user,hostfwd=tcp::2222-:22 \ -net nic,model=virtio,macaddr=$(cat /sys/class/net/qeth0/address) \ -net tap,fd=3 3<>/dev/tap$(cat /sys/class/net/qeth0/ifindex) \ -drive if=pflash,format=raw,readonly=on,file=/usr/share/AAVMF/AAVMF_CODE.fd \ -drive if=pflash,format=raw,file=AAVMF_VARS.fd \ -drive file=user-data.img,format=raw \ -drive file=ubuntu-22.04-server-cloudimg-arm64.img
-net tap,fd=3 3<>/dev/tap11
https://ahelpme.com/linux/howto-do-qemu-full-virtualization-with-macvtap-networking/