Move dnsmasq logic to a separate file