系統 - Debian - QEMU - 如何設定Host-only網卡



參考資訊:
https://alberand.com/host-only-networking-set-up-for-qemu-hypervisor.html

步驟如下:

$ sudo ip link add br0 type bridge
$ sudo ip addr flush dev br0
$ sudo ip addr add 192.168.100.50/24 brd 192.168.100.255 dev br0
$ sudo ip tuntap add mode tap user $(whoami)
$ ip tuntap show

$ sudo ip link set tap0 master br0
$ sudo ip link set dev br0 up
$ sudo ip link set dev tap0 up
$ sudo dnsmasq --interface=br0 --bind-interfaces --dhcp-range=192.168.100.50,192.168.100.254

設置網卡的方式可以任選下面其中一個

$ qemu -device e1000,netdev=network0,mac=00:00:00:00:00:00 -netdev tap,id=network0,ifname=tap0,script=no,downscript=no

$ qemu -device virtio-net-pci,netdev=n0,mac=FE:9c:37:4a:2c:93 -netdev tap,id=n0,ifname=tap0,script=no,downscript=no

設定Guest IP in QEMU

$ sudo ip addr add 192.168.100.224/24 broadcast 192.168.100.255 dev eth0