Interconnexion de machine virtuelle sous Qemu sur une machine physique.
1/ Scripts ‘réseau’.
– Activation du réseau :
Ouvrir :
1_activateNetwork.sh
Ajouter :
#!/bin/sh sudo ip addr flush dev eth0 sudo ip link set eth0 up sudo ip link add name br0 type bridge sudo ip link set eth0 master br0 sudo ip addr add 192.168.1.3/24 dev br0 sudo ip link set br0 up sudo ip route add default via 192.168.1.1 sudo ip tuntap add tap0 mode tap sudo ip link set tap0 up sudo ip link set tap0 master br0 sudo ip tuntap add tap1 mode tap sudo ip link set tap1 up sudo ip link set tap1 master br0 sudo ip tuntap add tap2 mode tap sudo ip link set tap2 up sudo ip link set tap2 master br0 sudo ip tuntap add tap3 mode tap sudo ip link set tap3 up sudo ip link set tap3 master br0 sudo brctl show
– Désactivation du réseau :
Ouvrir :
6_desactiveNetwork.sh
Ajouter :
#!/bin/sh sudo ip link set dev tap0 down sudo ip link delete tap0 sudo ip link set dev tap1 down sudo ip link delete tap1 sudo ip link set dev tap2 down sudo ip link delete tap2 sudo ip link set dev tap3 down sudo ip link delete tap3 sudo ip link set br0 down sudo ip link delete br0 sudo ip addr add 192.168.1.3/24 dev eth0 sudo ip link set eth0 up sudo ip route add default via 192.168.1.1
2/ Scripts ‘machine virtuelle’.
– Lancement de la machine virtuelle n°1 :
Ouvrir :
4_station01.sh
Ajouter :
#/bin/sh qemu-system-i386 -enable-kvm -k fr -m 1024 -sdl -vga std -hda station01/vhda.img \ -net nic,macaddr=`source genmac.sh` -net tap,ifname=tap0,script=no \ -no-quit
– Lancement de la machine virtuelle n°2 :
Ouvrir :
4_station02.sh
Ajouter :
#/bin/sh qemu-system-i386 -enable-kvm -k fr -m 1024 -sdl -vga std -hda station02/vhda.img \ -net nic,macaddr=`source genmac.sh` -net tap,ifname=tap1,script=no \ -no-quit
2/ Autres scripts.
– Génération d’une adresse MAC :
Ouvrir :
genmac.sh
Ajouter :
#!/bin/sh printf 'DE:AD:BE:EF:%02X:%02X\n' $((RANDOM%256)) $((RANDOM%256))
3/ Test.
3/ Lien.
Qemu : Aucune connexion à internet pour l’hôte : https://forum.ubuntu-fr.org/viewtopic.php?id=2007864
Comments are closed, but trackbacks and pingbacks are open.