I have re-built QEMU with VDE support. For the uninitiated, VDE attaches a virtual switch program (vde_switch) to a TAP device which allows multiple VDE-enabled programs to utilize a single TAP device.
My ultimate goal here is to be able to resolve my virtual machines by hostname such as "test1.qemu" "machineb.qemu", etc from my host -- this will ease configuration for me in many circumstances since I use DHCP via dnsmasq on the TAP interfaces.
Really this is probably a matter of not fully understanding how name resolution works, so I'm hoping to learn something out of this =)
Firstly, my dnsmasq configuration file:
user=nobody interface=tap0 except-interface=lo listen-address=192.168.1.1 #Assign IP's 192.168.1.2-192.168.1.253 for 8 hrs dhcp-range=192.168.1.2,192.168.1.253,255.255.255.0,192.168.1.255,8h pid-file=/var/run/dnsmasq_tap0.pid dhcp-leasefile=/var/lib/misc/dnsmasq.vde.leases domain=qemu server=/qemu/ #Only really run on tap0, needed so there is no confliction with #NetworkManager's dnsmasq bind-interfaces dhcp-authoritative dhcp-no-override strict-order
As you can see, I have configured dnsmasq to answer for "*.qemu" names. I can ping 192.168.1.1 properly, but as is stands, 'ping qemu' doesn't work. I assumed this was because my host machine didn't know how to resolve 'qemu', so I added it to the /etc/hosts file. Though, I'm not sure this is the proper way to do this. Of course, after adding the entry to /etc/hosts, qemu resolves but not i386.qemu (one of my VM's).
I guess a good starting point would be: how do I tell my machine to forward all *.qemu requests to the dnsmasq running on 192.168.1.1 (local interface tap0)?
Also, if it's any help, here is my /etc/network/interfaces entry for tap0:
auto tap0 iface tap0 inet static address 192.168.1.1 netmask 255.255.255.0 vde2-switch - pre-up /sbin/sysctl net.ipv4.ip_forward=1 pre-up /sbin/iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE up /usr/sbin/dnsmasq -C /etc/dnsmasq.d/vde-network --pid-file=/var/run/dnsmasq_tap0.pid --bind-interfaces post-down /bin/bash -c "kill -9 $(cat /var/run/dnsmasq_tap0.pid)" post-down /sbin/sysctl net.ipv4.ip_forward=0 post-down /sbin/iptables -t nat -D POSTROUTING -o wlan0 -j MASQUERADE