Skip to content

Instantly share code, notes, and snippets.

@j-keck
Created July 5, 2014 06:26
Show Gist options
  • Save j-keck/e402ef8452a9312465e6 to your computer and use it in GitHub Desktop.
Save j-keck/e402ef8452a9312465e6 to your computer and use it in GitHub Desktop.
how to disable dhcp server (dnsmasq-base) on ubuntu
dnsmasq from package 'dnsmasq-base' starts with a (from libvirt) generated configuration: /var/lib/libvirt/dnsmasq/default.conf.
this configuration file is not directly editable because it gets overwritten from libvirt.
there is no possibility to set 'no-dhcp-interface=eth0' per 'libvirt'.
# ###########################################################
# deactivate dhcp in dnsmasq per libvirt
# dnsmasq listen on port 53 (dns) and 67 (dhcp)
j@ubuntu:~$ sudo netstat -taupen | grep -E ':53|:67'
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 0 9817 1218/dnsmasq
udp 0 0 192.168.122.1:53 0.0.0.0:* 0 9816 1218/dnsmasq
udp 0 0 0.0.0.0:67 0.0.0.0:* 0 9813 1218/dnsmasq
# dump virsh network config
virsh net-dumpxml default > default-net-org.xml
# remove dhcp section in config
sed '/<dhcp>/,/<\/dhcp>/d' default-net-org.xml > default-net-without-dhcp.xml
# load new config
virsh net-define default-net-without-dhcp.xml
# restart network (regenerates /var/lib/libvirt/dnsmasq/default.conf) and restart dnsmasq
virsh net-destroy default
virsh net-start default
# dnsmasq listen only on port 53 (dns)
j@ubuntu:~$ sudo netstat -taupen | grep -E ':53|:67'
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 0 9673 1202/dnsmasq
udp 0 0 192.168.122.1:53 0.0.0.0:* 0 9672 1202/dnsmasq
# ###########################################################
# reactivate dhcp in dnsmasq per libvirt
# load original config
virsh net-define default-net-org.xml
# restart network (regenerates /var/lib/libvirt/dnsmasq/default.conf) and restart dnsmasq
virsh net-destroy default
virsh net-start default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment