2

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
2

So, I figured out the answer, and it was a bit of a facepalm moment.

I had a file called /etc/NetworkManager/dnsmasq.d/qemu which contained an incorrect DNS IP for my qemu dnsmasq instance (192.168.100.1 rather than 192.168.1.1). So, I think what was happening was that when I queried qemu, the default NetworkManager instance of netmask attempted to pass the query to 192.168.100.1 which didn't work for obvious reasons.

Once I changed the address to 192.168.1.1 in the config file and restarted NetworkManager (and thus its instance of dnamasq), everything works great! The /etc/hosts entry was not required as I had thought.

Now I just have to figure out how to resolve my VM host's hostname to my LAN address within my VM's rather than returning 127.0.1.1 which is incorrect from my VMs' perspective.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.