Qemu supports networks and just like normal hardware, if your network device has support build into the kernel (not as a module, unless you build those modules and know how to load them) should work.
To get basic network working, the current buildscipt and setup of qemu will use basic networking. The IP will be 10.0.2.15 and you can reach the internet if your host and qemu allows other virtual machines aswell.
Build and/or start a instance with a mac adress of choice
./build.sh -net <macaddr>for example
./build.sh -net 52:55:00:d1:55:01Will run a VM with that specific macaddr (you need to change the ip inside or do DHCP trickery).
To use a bridge setup (wich I wanted to try anyway) and be able to ping another virtual machine do the following: Create a bridge and 2 taps (1 tap for a virual machine, either eth0/or wireless for internet, or another tap for another virtual machine). As root (or use sudo)
ip tuntap add tap0 mode tap
ip tuntap add tap1 mode tapCreate the actual bridge
brctl addbr br0Add the two taps to the bridge
brctl addif br0 tap0
brctl addif br0 tap1Bring the interfaces up, so they actualy work.
ifconfig tap0 up
ifconfig tap1 up
ifconfig br0 upthen add a network device to your qemu instance, if using my buildscript, run the following
./build -net 52:55:00:d1:55:01The system should get an IP from your dhcp server (you can also add one using dnsmasq)
sometimes you need to change the ip of an instance, then inside one of the qemu instances, change to static ip for example:
ifconfig eth0 down
ifconfig eth0 up 10.0.2.16 netmask 255.255.255.0 upAnd now you should be able to ping eachother and do stuff. If you setup a DHCP server or add the bridge to a network with a DHCP server, you can set the instances to recieve a IP from the said DHCP server, which in the current version is the case.
To remove interfaces and shutdown stuff delete a tap (also for tap1 or eth0) and deteling the tap
brctl delif br0 tap0
tunctl -d tap0Bring the bridge down and remove it:
ifconfig br0 down
brctl delbr br0Now you can up your eth0 or wirelless again for internets or use a VM without these bridges and use usermode networking.
To flush the ip and be able to add eth0 of your host to the bridge:
ip addr flush dev eth0Checking out if the bridge has the right and all taps or interfaces you wanted:
brctl showMore details and tips can be found at:
- https://gist.github.com/extremecoders-re/e8fd8a67a515fee0c873dcafc81d811c
- https://wiki.qemu.org/Documentation/Networking#Tap
- https://wiki.archlinux.org/index.php/Network_bridge#With_bridge-utils
In case of dropbear, if the right keys are in place, starting with network support:
./build.sh -net 52:55:00:d1:55:01then inside the system:
dropbear -RYou should now be able to ssh into this (maybe remove the old known host ip and key from your hosts .ssh/known_hosts)
ssh root@192.168.66.6tip add the following to prevent a bloating knownhosts file.
-o "UserKnownHostsFile /dev/null"To ssh into your freshly build TeenyLinux, you simply type:
$ ssh root@192.168.66.6 -o "UserKnownHostsFile=/dev/null"The added -o option redirects the known host key to /dev/null, because each rerun of dropbear generates a new hostkey. These steps are not nececairy when reusing the hostkey (by supplying it during the init build fase etc.)