A cute little fox

Michael Jansen

Drive By Coding


2-Minute Read

I recently switched to Leap from 13.2. First time i have seen the next generation of kde and plasma. So far i like the experience. But i miss some stuff :(. If some dev out there needs an idea for his next little plasma widget project please consider porting service monitor. That widget alone could bring me back to kde4 :).

As i did a clean reinstall once again resolv.conf was not updated when starting my libvirt networks so no dns resolve of vm names. Not sure if that is a bug or expected behaviour but i had it with 13.2 too and consider it a REAL bug. Or at least major annoyance.

Adding the ip address statically to resolv.conf is not a option. This is a notebook so most services do not get started on default. Which includes libvirtd.

The solution i came up with is to add a libvirt hook that registers the libvirt dnsmasq instance with netconfig when starting libvirt networks and removing it when stopping it. Not much explanation … just code for your convenience.

The script could be improved i guess. Check if dhcp is configured for the network and so on or if dnsmasq is configured for the network in libvirt. But for me it works as is.

# vim: et sw=0
# See https://www.libvirt.org/hooks.html
# Get the configuration from STDIN
# Extract the interface and ip addr
iface=$(sed -ne "s/^.*bridge *name='\([a-zA-Z0-9_]*\).*$/\1/p;" <<<"${config}")
ipaddr=$(sed -ne "s/^.*ip *address *= *'\([0-9.]*\).*$/\1/p;"   <<<"${config}")
function check_suboperation() {
  local operation= shift;
  local expected= shift;
  if [ "${oper}" != "${expected}" ]; then
    echo "WARN: Unknown sub-operation ${oper} encountered!" >&2
    exit 1
case "${OPERATION}" in
    check_suboperation "${SUB_OPERATION}" "begin"
    netconfig modify -v --service libvirt --interface "${iface}" -v <<< "DNSSERVERS='${ipaddr}'"
    check_suboperation "${SUB_OPERATION}" "begin"
    netconfig remove -v --service libvirt --interface "${iface}" -v <<< "DNSSERVERS='${ipaddr}'"
exit 0

This script is put under the unlicense license.

Recent Posts



Freelancer, DevOps and Automation. Everything but Java.